Posts

Showing posts from August, 2013

jquery - How to set data values on Kendo Multi Select? -

i'm using kendo multi select. want load selected values multi select. how set data values in java script? have following script: $('#selectedfilters').kendomultiselect({ datasource: data, datatextfield: 'name', datavaluefield: 'value', filter: 'contains', placeholder: "add filter", delay: 0, minlength: 2, highlightfirst: true, ignorecase: true, change: function (event) { applyfilters(); }, }); you can use value() method setting values. example, give following html: <a href="#" id="button" class="k-button">select</a> <input id='selectedfilters'> and javascript: var data = [ { name : "name1", va

objective c - Best way to store iPhone data (custom NSObject) -

i have nsmutablearray in store objects called "address". address nsobject 4-5 properties ( nsstrings ). nsmutablearray shall contain maximum of 15 address object. what best way store array on iphone? core data ? nsuserdefaults ? should maybe store every address object itself, , not objects in 1 nsmutablearray ? in case should on iphone ? thanks. as @rog said, may use nsuserdefaults save data & should make object follow protocal nscoding for examplem if object "youobject" @interface youobject: nsobject { } @property (nonatomic, copy) nsstring *uid; @property (nonatomic, copy) nsstring *name; @end //implement 2 method - (id)initwithcoder:(nscoder *)decoder { if (self = [super init]) { self.title = [decoder decodeobjectforkey:@"uid"]; self.author = [decoder decodeobjectforkey:@"name"]; } return self; } - (void)encodewithcoder:(nscoder *)encoder { [encoder encodeobject:title forkey:@"uid&q

postgresql - PgSQL turning day-of-year back into date -

i trying determine how turn day-of-year date in pgsql. when this select date '2013-01-01' + interval '53 days' i timestamp: "2013-02-23 00:00:00" so how come when of following select extract(date (date '2013-01-01' + interval '53 days')) select extract(date (select date '2013-01-01' + interval '53 days')) i "error: timestamp units "date" not recognized"? besides why, how can want, date portion of result of original operation? use select (date '2013-01-01' + interval '53 days')::date or select cast(date '2013-01-01' + interval '53 days' date) postgresql's standard sql function "extract()" will operate on timestamps, a) "date" isn't valid argument extract(), , b) returns subfields, not collection of subfields. conceptually, date consists of collection of 3 subfields: year, month, , day. select extract(year curre

ElasticSearch geo distance filter with multiple locations in array - possible? -

let's have bunch of documents in elasticsearch index. each documents has multiple locations in array , this: { "name": "foobar", "locations": [ { "lat": 40.708519, "lon": -74.003212 }, { "lat": 39.752609, "lon": -104.998100 }, { "lat": 51.506321, "lon": -0.127140 } ] } according elasticsearch reference guide the geo_distance filter can work multiple locations / points per document. once single location / point matches filter, document included in filter. so, possible create geo distance filter checks locations in array? this doesn't seem work, unfortunately: { "filter": { "geo_distance": { "distance": "100 km", "locations": "40, -105" } } } throws " queryparsingexception[[myindex] failed find geo_point field [l

css - Change screen size using JavaScript -

using zurb foundation 's mobile-first experience, have developed responsive design. now, client requires explicit link "view desktop version" in footer, when site opened in mobile or tablets. there seems 2 options: drop foundation , create new css files (perhaps extract selected rules foundation core css grid); 1 desktop , 1 mobile. load css file based on cookies value or url query. (long method) modify screen size (max-width, min-width ..) using javascript, media query wrong info , loads right results? (imagination) is second option possible? there (easy) way it? yes, can modify meta tag. did project while , i've got piece of script/plugin on github: https://github.com/trolleymusic/minwidth - i've updated demos you. you must include modernizr or won't work you run this: minwidth(x); where x min width want be. on phone check out difference between 2 demo files: http://waynedurack.com/minwidth/demos/with.html vs http://wa

Google's python class -

i wondering if give me hand questions on google python class, based around lists. # a. match_ends # given list of strings, return count of number of # strings string length 2 or more , first # , last chars of string same. # note: python not have ++ operator, += works. def match_ends(words): print words # b. front_x # given list of strings, return list strings # in sorted order, except group strings begin 'x' first. # e.g. ['mix', 'xyz', 'apple', 'xanadu', 'aardvark'] yields # ['xanadu', 'xyz', 'aardvark', 'apple', 'mix'] # hint: can done making 2 lists , sorting each of them # before combining them. def front_x(words): return these questions, i've had several attempets , never got anywhere, wondering if could see answer , work backwards. thanks! george def match_ends(words): count = 0 item in words: if len(item) >= 2 , item[0] == item[-1]:

Why does PowerShell ISE hang on this C# program? -

if compile c# code exe file , run in windows command shell runs fine: outputting prompt, waiting on same line user input followed enter, echoing input. running in powershell v3 shell runs fine. if, however, run same exe file in powershell ise v3, never emits output write , hangs on readline . (as aside, emit output write if later followed writeline .) namespace consoleapplication1 { class program { static void main(string[] args) { system.console.write("invisible prompt: "); var s = system.console.readline(); system.console.writeline("echo " + s); } } } is ise bug or there property adjust make work...? the ise has no support console class. no support [console] class, try [console]::backgroundcolor = 'white'. in general, scripts should use host api's (write-host, instead of [console] class, work in both console, ise, remoting , other shells.

How to stick Title for ViewPager to the TOP. PagerTitleStrip Android -

i have strange me issue viewpager. i need add pagertitlestrip viewpager , put on top. try put layout_gravity = "top", reserves space on "bottom" , show title string on "top"! when put gravitity "bottom", displays correctly. here screens top - http://clip2net.com/s/4wdduj bottom - http://clip2net.com/s/4wdd8k viewpager - green pagertitlestrip - blue pager content match_parrent - red please me understand why happens. how stick top , dont have green space on bottom? thank you. here xml pager: <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <android.support.v4.view.viewpager android:id="@+id/pagertelefooninfo" android:layout_width="wrap_content" android:backgrou

python - error when trying to use pass keyword in one line if statement -

stumped works: if 5 % 2 == 0: print "no remainder" else: pass but not this: print "no remainder" if 5% 2 == 0 else pass syntaxerror: invalid syntax the latter not if statement, rather expression (i mean, print statement, rest being interpreted expression, fails). expressions have values. pass doesn't, because it's statement. you may seeing 2 statements ( print or pass ), interpreter sees differently: expr = "no remainder" if 5% 2 == 0 else pass print expr and first line problematic because mixes expression , statement. a one-line if statement different thing: if 5 % 2 == 0: print "no remainder" this can called one-line if statement. p.s. ternary expressions referred "conditional expressions" in official docs . a ternary expression uses syntax tried use, needs 2 expressions , condition (also expression): expr1 if cond else expr2 and takes value of expr1 if bool(cond)

css - Changing the background color on focused select box option does not work -

this selectboxit jquery plug-in, using jqueryui theme. i have set hover action: /* individual option hover action */ .selectboxit-option .selectboxit-option-anchor:hover { color: #ffffff; background-color: #ff0000; text-decoration: none; } that works fine. when hover mouse on options, red background white text. however, when this... .selectboxit-option:focus .selectboxit-option-anchor:focus { color: #ffffff; background-color: #ff0000; text-decoration: none; } ...nothing changes. i see demos on selectboxit's main web page have changing background colors keyboard focus...so missing? technically, each option doesn't use focus event, why focus pseudo selector not working you. jqueryui theme, "active" option adds ui-state-focus class, change "focus" css style, have rule this: .selectboxit-option.ui-state-focus { background: #ccc; }

dart - where should pubspec and how many with multiple apps -

suppose there need project 3 libraries , 2 apps. pub documentation i'm choosing structure below. apps different enough, though, desirable have own directory. documentation @ ( http://pub.dartlang.org/doc/#adding-a-dependency ) says put pubspec.yaml file @ top-level . top-level in context below project folder? if there 1 pubspec , @ /project level , shared libs, wouldn't mean users of of libs not apps unnecessarily require packages (like good_stuff , big_stuff)? /project /app /app1 (uses l1, package:good_stuff) /app2 (uses l1, l2, l3, package:big_stuff) /lib /l1 /l2 (uses package:pathos/path.dart) /l3 (uses l1 , l2) /src /l1 /l2 /l3 so, given desired setup, how many pubspec's , created satisfy these dependencies. packages you should put pubspec.yaml file in top level of package . in pub, package largest unit of self-contained code, , contains

javascript - jQuery .click event runs on page load -

i have jquery script in external file. im using update database. i've been practicing around , cannot right. .ajax call ran when button (labeled id "add") clicked, database updated everytime page refreshed , not when button clicked! can explain why? in advance $('#add').click( $.ajax({ url: 'test.php', success: function() { alert("added"); } }) ); update : @flo able working perfectly. here's final product: $(document).on('click','#add',function() { $.ajax({ url: 'test.php', success: function() { alert("added"); } }) }); i'm not 100% sure it, guess trigerring click stuff execute, instead of binding event ! i mean: $('#add').click($.ajax...) should not same as: $('#add').click(function (clickevent) { // update here ! $.ajax... }); but anyway, should prefer: $('#add&#

c# - how to delete image which is stored as varbinary format in database -

i have picturebox image , delete button. image stored in varbinary(max) format in database. how delete when delete button pressed? i'm using code save image database: byte[] data; using (system.io.memorystream stream = new system.io.memorystream()) { conn.open(); image img = picturebox1.image; img.save(stream, system.drawing.imaging.imageformat.jpeg); data = stream.toarray(); cmd.commandtext = "insert images values(@images)"; cmd.parameters.addwithvalue("@images", data); int res = cmd.executenonquery(); messagebox.show("success"); } i don't see why following wouldn't work. cmd.commandtext = "delete images id = x"; sending plain sql getting outdated , can down right dangerous when implemented ui improperly, should consider using linq http://en.wikipedia.org/wiki/language_integrated_query

c++ - Synchronization riddle with std::memory_order and three threads -

here problem std::memory_order rules in c++11, when comes 3 threads. say, 1 thread producer saves value , sets flag. then, thread relay waits flag before setting flag. finally, third thread consumer waits flag relay , should signal data ready consumer . here minimal program, in style of examples in c++ reference ( http://en.cppreference.com/w/cpp/atomic/memory_order ): #include <thread> #include <atomic> #include <cassert> std::atomic<bool> flag1 = atomic_var_init(false); std::atomic<bool> flag2 = atomic_var_init(false); int data; void producer() { data = 42; flag1.store(true, std::memory_order_release); } void relay_1() { while (!flag1.load(std::memory_order_acquire)) ; flag2.store(true, std::memory_order_release); } void relay_2() { while (!flag1.load(std::memory_order_seq_cst)) ; flag2.store(true, std::memory_order_seq_cst); } void relay_3() { while (!flag1.load(std::memory_order_acquire)) ; // following lin

sql - How to map rows of two tables to each other based on the relevance in MySQL? -

i have following tables in database: courses (whole data of sports classes), coursedata (with copies of courses.title , courses.description -- needed fulltext index / relevance search), sports (list of sports), , courses_sports (association table) -- see below. now want map courses relevance based sports , fill courses_sports data automatically. needs 2 steps. collect data apporiate select . write data association table. this post first step. have troubles writing query. i've tried: select courses.id, sports.id courses join coursedata on coursedata.id = courses.coursedata_id join sports on match (coursedata.title) against (sports.title) > 0 -- test -- sports on match (coursedata.title) against ('basketball') > 0 -- works. this query not working: error code: 1210 incorrect arguments against how implement mapping correctly? additional information: relevant tables courses field type

cocoa - Regex too greedy; eats nearly all my rows -

from xml-data: <row a1:height="17" ss:styleid="s139"> <cell ss:styleid="s69"><data ss:type="string">title1</data><namedcell ss:name="print_titles"/><namedcell ss:name="_filterdatabase"/><namedcell ss:name="print_area"/></cell> <cell ss:styleid="s70"><data ss:type="string">title2</data><namedcell ss:name="print_titles"/><namedcell ss:name="_filterdatabase"/><namedcell ss:name="print_area"/></cell> </row> <row a2:height="17" ss:styleid="s139"> <cell ss:styleid="s69"><data ss:type="string">title1</data><namedcell ss:name="print_titles"/><namedcell ss:name="_filterdatabase"/><namedcell ss:name="print_area"/></c

python - Tkinter example code for multiple windows, why won't buttons load correctly? -

there must obvious why code wrong. i'm hoping able point out. i new @ python , newer @ tkinter. can tell? ; ) the reason using classes sample code me jist of things, inserted larger program. i tried keep simple possible. want program to: open window press of button. close newly opened window press of button. import tkinter tk tkinter import * tkinter import ttk class demo1( frame ): def __init__( self ): tk.frame.__init__(self) self.pack() self.master.title("demo 1") self.button1 = button( self, text = "button 1", width = 25, command = self.new_window ) self.button1.grid( row = 0, column = 1, columnspan = 2, sticky = w+e+n+s ) def new_window(self): self.newwindow = demo2() class demo2(frame): def __init__(self): new =tk.frame.__init__(self) new = toplevel(self) new.title("demo 2") new.button = tk.button( t

Checking out a git branch while in a path that exists only in the initial branch -

can me make sense of quirk i've found git? here's how reproduce quirk: $ mkdir git-test && cd git-test $ git init initialized empty git repository in /tmp/git-test/.git/ $ echo hello > world $ git add world $ git commit -m'first commit' [master (root-commit) 5f68103] first commit 1 file changed, 1 insertion(+) create mode 100644 world cool, right far; let's branch off: $ git checkout -b a_branch $ mkdir a_dir $ echo foo > a_dir/bar $ git add a_dir/bar $ git commit -m message [a_branch (root-commit) 2fbef71] message 1 file changed, 1 insertion(+) create mode 100644 a_dir/bar ok, here comes quirk! $ cd a_dir $ pwd /tmp/git-test/a_dir $ git checkout master switched branch 'master' $ pwd /tmp/git-test/a_dir wtf!? path not exist in branch! $ ls total 0 even ls seems work... $ cd .. $ ls world the directory `a_dir' has magically disappeared! how possible? if understand correctly, has not git. your curre

google app engine - NDB Modeling One-to-one with KeyProperty -

i'm quite new ndb i've understood need rewire area in brain create models. i'm trying create simple model - sake of understanding how design ndb database - one-to-one relationship: instance, user , info. after searching around lot - found documentation hard find different examples - , experimenting bit (modeling , querying in couple of different ways), solution found: from google.appengine.ext import ndb class monster(ndb.model): name = ndb.stringproperty() @classmethod def get_by_name(cls, name): return cls.query(cls.name == name).get() def get_info(self): return info.query(info.monster == self.key).get() class info(ndb.model): monster = ndb.keyproperty(kind='monster') address = ndb.stringproperty() = monster(name = "dracula") a.put() b = info(monster = a.key, address = "transilvania") b.put() print monster.get_by_name("dracula").get_info().address ndb doesn't accept joins, &qu

c++ - "Invalid argument" with message queue operations -

i'm trying send 1kb string on message queue between parent process , forked child. unfortunately, calls msgsnd , msgrcv , etc. returning -1 , causing einval error. i found error (in case of msgsnd , example) occurs when msqid invalid, message type argument set @ <1, or msgsz out of range. upon testing, far can tell, msgget returning valid id number , type set fine. there must problem buffer ranges, thought set them correctly. in code, have added comments explain (sorry of frantically-added #includes): #include <errno.h> #include <stdio.h> #include <iostream> #include <stdlib.h> #include <string.h> #include <string> #include <cstring> #include <sys/msg.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include <sys/time.h> #include <sstream> #define perms (s_irusr | s_iwusr) #define numbytes 1024 //number of chars (bytes) sent using namespace std; //special stru

Read Image Metadata from single file with Java -

i want read image metadata single file. tried following code: http://johnbokma.com/java/obtaining-image-metadata.html when run it, build successful nothing happens. public class metadata { public static void main(string[] args) { metadata meta = new metadata(); int length = args.length; ( int = 0; < length; i++ ) meta.readanddisplaymetadata( args[i] ); } void readanddisplaymetadata( string filename ) { try { file file = new file( filename ); imageinputstream iis = imageio.createimageinputstream(file); iterator<imagereader> readers = imageio.getimagereaders(iis); if (readers.hasnext()) { // pick first available imagereader imagereader reader = readers.next(); // attach source reader reader.setinput(iis, true); // read metadata of first image iiometadata metadata = r

html - can't find my file after file upload in php -

i using following php script upload file: <?php $dest_dir="c:\users\maria\documents\it-learning"; foreach ($_files $file_name => $file_array) { echo "path: ".$file_array['tmp_name']."<br/>\n"; //output "c:\windows\temp\phpb4c9.tmp" instead echo "name: ".$file_array['name']."<br/>\n"; echo "type: ".$file_array['type']."<br/>\n"; echo "size: ".$file_array['size']."<br/>\n"; if (is_uploaded_file($file_array['tmp_name'])) { move_uploaded_file($file_array['tmp_name'], $dest_dir.$file_array['name']) or die ("file exists can't moved"); echo "file uploaded successfully."; } else { echo "file not exist."; } } //single file fine. opened single file ?> the output this: path: c:\windows\temp\phpb4c9.tmp

javascript - Meteor.userId from the client - changing shows user email, correct behavior? -

i looking @ question's answer regarding changing userid client side , following along not getting expected results; meteor.userid changeable i followed steps 1 through 5 fine no issues set userid() user i'd logged out in separate browser using meteor.default_connection.setuserid('usersfjhjdskfh'); rather display spinny in place of email address since server shouldn't returning data, displayed actual user's email address i'd used there. (it did not however, bring party information , show on map). is intended behavior , missed point of last answer given in december or has changed? (i'm running meteor 0.6.2 , both insecure , autopublish removed example) im assuming want change user's _id , not change logged in user via id. change user id like meteor.users.update(meteor.userid(), {$set:{_id:<new id>}}); assuming have correct permissions in place meteor.users.allow . should change _id of current logged in user. the prev

Rails form select from two options with a button - custom form implementation -

i have website want users able select type of user during registration process. specifically, implementation want have 2 buttons on signup page, 1 called "seller" , 1 called "buyer". the user should able select 1 button , once clicked, should stay highlighted (i know jquery not issue). the selection should stored in column in users model called :type. it seems pretty straightforward, "f.select" form method seems implement dropdown menu, wondering how can achieve implementation of 2 buttons. since you're going use jquery, add hidden field type , create 2 links , style them buttons, , use jquery update value of type when user clicks 1 of "buttons".

statistics - Degree of Freedom of Markov Chains -

i have set of 5000 strings of length 4, each character in string can either a, b, c, or d. 0-order markov chain (no dependency), makes 4*1 array of columns a, b, c, d. 1-order markov chain (pos j depends on previous pos i), makes 4*4 matrix of rows ai, bi, ci, di; , columns of aj, bj, cj, dj. 2-order markov chain (pos k depends on pos j , pos i), makes 4*4*4 matrix of dimensions ai, bi, ci, di; aj, bj, cj, dj; , ak, bk, ck, dk [or makes 16*4 matrix of dimensions aij, bij, cij, dij; ak, bk, ck, dk]. 3-order markov chain (pos l depends on pos k, pos j, , pos i), makes 4*4*4*4 matrix of dimensions ai, bi, ci, di; aj, bj, cj, dj; ak, bk, ck, dk; al, bl, cl, dl [or makes 64*4 matrix of dimensions aijk, bijk, cijk, dijk; al, bl, cl, dl]. what number of parameters 4 orders? have few ideas, want see others think. thank advice!! as pointed out in comments, answer contained in question. general formula number of independent parameters specify markov model of k-th order n po

matlab - Image enhancement using edge extraction -

Image
we can extract edge of image in matlab using function edge() question how can recombine edge original image image enhanced edges increase sharpness of image. what looking exists! the image filter in question called 'unsharp mask'. uses edge data of image sharpen it. elucidate, in manner of sorts use difference of image , blurred version of , use sharpen image. can read more here . to use it, following: >> my_image = imread('lena.jpg'); >> subplot(1,2,1); >> imshow(my_image); >> subplot(1,2,2); >> imshow(imfilter(my_image,fspecial('unsharp'))); this yeild: as can see, second image visibly sharper , done "adding" edge data original image through use of unsharp mask.

c - Can multithreading be implemented on a single processor system? -

i have followed concept multithreading can implemented on multiple processors system there more 1 processor assigned each thread , each thread can executed simultaneoulsy. there no scheduling in case each of thread has separate resources dedicated it. recenetly read somewhere can multithreading on single processor system well. correct? , if yes difference between single processor , multiple processor systems? of course can done on single-processor system, , in fact it's easier way. works same way running multiple processes -- kernel, via timer interrupt or other similar mechanism, suspends one, saving machine state, , replacing previously-saved state of -- difference being 2 threads of same process share same virtual memory space, making task-switch more efficient. multi-threading on multi-processor systems more difficult, since have issues of simultaneous access memory multiple cpus/cores, , nasty memory synchronization issues arise out of that.

css - twitter bootstrap span not aligning properly -

for reason, when apply spans spans not align proper grid. doesn't seem matter type of element apply span to, in case inputs. want them align themselves, doing wrong? fiddle here: http://jsfiddle.net/fkqsj/ <div class="row-fluid"> <div class="span12"> <input type="text" class="span4" placeholder="first" /> <input type="text" class="span4" placeholder="middle" /> <input type="text" class="span4" placeholder="last" /> </div> </div> <div class="row-fluid"> <div class="span12"> <input type="text" class="span4" placeholder="city" /> <input type="text" class="span2" pla

ios - How to create a game loop in Sparrow and refresh the display each frame cycle? -

i've been scouring web past 2 days trying find complete example of how use built-in game loop features in sparrow ios development. working on tower defense type of game school project. player controls gun turret in center of screen while tanks enter screen randomly 4 sides. here link screen shot: https://www.dropbox.com/s/sqleuqza9dcgiqs/ios%20simulator%20screen%20shot%20apr%2019%2c%202013%2010.53.54%20pm.png i have "tankmanager" class creates , handles instances of "tank" class storing instances of tank in nsmutablearray called "activetanks", , put "tankimage" "tanksprite" nested in "tankmanagersprite" nested in main "_contents" sprite. can see in image @ link above, show fine. i want animate tanks. reading understand need have game loop calls method every fraction of second. according sparrow wiki ( http://wiki.sparrow-framework.org/manual/animation ), use sparrow's built-in game loop featur

php - mysql getting max min values across multiple tables -

i want price range products 2 tables. table1 (products): pid | products_name | products_model 1 | product 1.....| model 1 2 | product 2.....| model 2 table2 (products_prices): pid | nerchant_id | price | sale_price | sale_start_date | sale_expire_date 1 | rvtbv | 11.90 | 0 | null | null 1 | qnunu | 11.90 | 9.90 | 2013-05-01 | 2013-12-31 1 | yolor | 12.90 | 10.90 | 2013-04-01 | 2013-12-31 2 | rvtbv | 20.90 | 0 | null | null 2 | qnunu | 29.90 | 25.90 | 2013-04-01 | 2013-12-31 2 | yolor | 29.90 | 0 | null | null how result price range this: pid | products_name | products_model | min_price | max_price 1 | product 1.... | model 1 ...... | 10.90 ... | 12.90 2 | product 2.... | model 2 ...... | 20.90 ... | 29.90 i using main query products data table1 loop php foreach product min max values depending on sale start ,

html - Textarea is not showing in php. What is error? -

i have following script print textarea , text that. when page loaded, textarea not appear when while condition true. problem? $seq_query = "select * `mcsm`.`conseq_human` `mcsm_id`='$mcsm_id';"; $seq_result = mysql_query($seq_query); print '<table border="0" align="left" style="margin-left:207px"><tr><th align="left">conserved sequence</th></tr>'; if(!$conseq = mysql_fetch_array($seq_result)) { print "<tr><td><p>not sufficient information yet.</p></td></tr></table>"; } else { while($conseq = mysql_fetch_array($seq_result)) { print "<tr><td><textarea name='seq_textarea' cols='100' rows=''>".$conseq['consequence']."</textarea></td></tr> <tr><td>based on msa of ".$conseq['msa_no_of_seq']." sequenc

java - Encryption and decryption of a audio/video file using AES(128) -

i writing program sends audio/video file server data encrypted , sent client on socket. in client part, data extracted , decrypted , stored file.the data getting encrypted , decrypted well,but decrypted file not playing properly. can help? code follows server: public class ser_enc { private static int packet_count; private static int packet_size=1024; public static void main(string args[]) throws ioexception, nosuchalgorithmexception, nosuchpaddingexception, invalidkeyexception { system.out.println("hi iam server"); serversocket ss=new serversocket(2001); socket s=ss.accept(); bufferedreader in=new bufferedreader(new inputstreamreader(s.getinputstream()));//sockin outputstream pw= s.getoutputstream(); string filename=in.readline(); system.out.println("the file requested " +filename); string loc="f://files//source_files//"+filename; file file=new file(loc); if(file.exists())

java - Image does not load in external WebBrowser (Firefox) -

i have created dynamic webproject , using following code upload image , retrieve same location.now when trying run application in external browser shows rectangle box instead of image.getting loaded in external web browser gives error. import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.iterator; import java.util.list; import java.util.random; import java.util.regex.matcher; import java.util.regex.pattern; import java.sql.*; import org.apache.commons.fileupload.servlet.servletfileupload; import org.apache.commons.fileupload.disk.*; import org.apache.commons.fileupload.*; public class uploadimage extends httpservlet { private static final long serialversionuid = 1l; public void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { printwriter out = response.getwriter(); boolean ismultipart = servletfileupload.ismultipartcontent(request); system.out.println(&qu

java - Enlarging JFrame/JPanel Programmatically -

i have been working on java 2d game , halfway through noticed screen , sprites small. enlarging them hand pain. is possible enlarge jframe or jpanel , of it's contents when using java 2d draw images panel? graphics2d providing image re-size feature follows : bufferedimage resizedimage = new bufferedimage(img_width, img_height, type); graphics2d g = resizedimage.creategraphics(); g.drawimage(originalimage, 0, 0, img_width, img_height, null); g.dispose(); according articles, if want increase re-sized image quality, can add renderinghints follows : bufferedimage resizedimage = new bufferedimage(img_width, img_height, type); graphics2d g = resizedimage.creategraphics(); g.drawimage(originalimage, 0, 0, img_width, img_height, null); g.dispose(); g.setcomposite(alphacomposite.src); g.setrenderinghint(renderinghints.key_interpolation,renderinghints.value_interpolation_bilinear); g.setrenderinghint(renderinghints.key_rendering,renderinghints.value_render_quality); g.se

c# - WCF Rest 400 bad request image size -

i have searched on , tried solutions nothing seem work me. bad 400 request when uploading image bigger 64k. working stopped working. no code change or change config file well. else affect config file settings ? here config file <system.web> <customerrors mode="off"/> <compilation debug="true" targetframework="4.0" /> <httpruntime maxrequestlength="2147483647"/> </system.web> <system.servicemodel> <services> <service behaviorconfiguration="webhttpbehavior" name="ezfindwcfservice.ezfindwebservice"> <endpoint address="" behaviorconfiguration="ezfindwcfservice.ezfindwebserviceaspnetajaxbehavior" binding="webhttpbinding" contract="ezfindwcfservice.ezfindwebservice" /> </service> </services> <behaviors> <endpointbehaviors> <behavior

android - Force font size -

Image
in app there lot of strings, used sp size. yesterday increased fonts size in system-preferences of android , size bigger in app, not me because strings in app big. there solution force font size regardless of operating system? thanks lot i not sure why want app ignore system setting. feature people have difficulty reading small text sizes. and have not once come across solution lets app override feature. if absolutely must try , override same anyway, i think ( see note @ end ) changing current sp values dp should in, theory, ignore settings. ( some changes. see update ) the sp used font size ( android:textsize ) honor settings user might override entire system. developer, should account situation making sure layouts account , accommodate such change. if choose still ignore in app... each own. note: place emphasis on i think because developer wants app liked , appreciated, wouldn't consider such override , hence never ventured test if works. please

php - how to retrive value from jquery ui slider and store them into database? -

hi im new javascript , ajax. problem when move slider value,the value should stored database , response should value stored. have searched many questions asked here still cant figure out yet. great. here html code <head> <script> $(function() { $( "#slider-range-max" ).slider({ range: "max", min: 1, max: 10, value: 2, slide: function( event, ui ) { $( "#amount" ).val( ui.value ); } }); $( "#amount" ).val( $( "#slider-range-max" ).slider( "value" ) ); $.ajax({ type:"post", url:"myslider.php", data:"vote="+$( "#slider-range-max" ).slider( "value" ), success:function(response) { alert(voted); } }) }); </script> </head> and myslider.php connection of database, <?php require 'connection.php'; $vote="

sql - Using a select case statement to compare field values -

i using select case statement compare 2 columns. 1 value returned table valued function , other database column. if first value of preferred first name null need show value of firstname view aliased column. dont know if syntax right. can tell me if right , or better way it? (select case when ( select asstring dbo.getcustomfieldvalue('preferred first name', view_attendance_employees.filekey) ) = null view_attendance_employees.firstname else ( select asstring dbo.getcustomfieldvalue('preferred first name', view_attendance_employees.filekey)) end) firstname, you can use isnull function here: select isnull(.. massive subquery here..., firstname)

asp.net - How do I show column type Date/Time in VB GridView -

Image
i using database in access 2010. , using visual studio 2005. have data in column of type "date/time" this: and show in gridview <asp:templatefield headertext="date" sortexpression="date_request"> <itemtemplate> <asp:label id="label_date" runat="server" text='<%# bind("date_request") %>'/> </itemtemplate> </asp:templatefield> <asp:templatefield headertext="time" sortexpression="time_request"> <itemtemplate> <asp:label id="label_time" runat="server" text='<%# bind("time_request") %>'/> </itemtemplate> </asp:templatefield> then displays this: i don't know why not showing same database. show me how make trhem display same? replace of above code following code. <asp:boundfield datafield="date_request" dataformatstring="{0:d}" headertext

sql - alter column from time with time zone to timestamp -

i having trouble changing column called end_date in table called key_request time time zone timestamp in postgres database . have tried using following code: alter table key_request alter column end_date type timestamp time zone using end_date::timestamp time zone i keep getting following error: error: cannot cast type time time zone timestamp time zone any idea of how can adjust query work? i woul in series of steps alter table, adding new column end_date1 time time zone copy date end_date (old) end_date1 alter table, droping old end_date column alter table,reaming end_date1 end_date