Posts

Showing posts from February, 2012

c# - Factorial Algorithm which uses no Big-Integer library -

i'm studing computer engineering , have hard task. we have develop c# application can calculate factorial of big numbers without bigint . mean big numbers, 123564891...82598413! . , don't have use permission use custom libraries (like bigint ) . researched , found few questions this, this question different others because have calculate really big numbers without custom libraries . found poormans algorithm . it's calculating 10000 . it's not enough us. with teammates, found solution . let's factorial of 123 . 123 string . , , sum 123 , 122 times (it's equal 123 x 122) . , sum result 121 times. goes until reach 1. so, sum 2 strings. we create algorithm summing strings. getting last char of first number (3 of 123) integer (we can use integer, not bigint) . , last char of second number integer (2 of 122). sum them , found result number's last char (result = x...x5) . last char first char. result number . know, should use while() or for() loop, ,

jquery - Flot Chart Tooltip Error - Tooltip Date is One Day Behind X-Axis Date -

i haven't been able understand why tooltip date off single day. believe x-axis correct, , i've been playing around it, killing me. how can fix this? i'm passing in json url endpoint variable jsondataurl. here example datapoint: [{date: "2013-01-01", value: 50}] and cssselector placeholder. here's code: $.getjson(jsondataurl, function(res) { var data = []; $.each(res, function(i, entry){ data.push( [new date(entry["date"]), entry["value"]] ); }); var opts = { yaxis: { min: 0}, xaxis: { mode: "time", timeformat: "%m-%d"}, series: { lines: { show: true }, points: { show: true } }, grid: {hoverable: true, clickable: true} }; $.plot($(cssselector), [data], opts); $(cssselector).bind("plotclick", function(event, pos, item) { if (item) { var x = parseint(item.datapoint[0]), y =

eclipse - How to use Akka project under Android -

i'm little bit desperate @ moment. i'm trying use akka project (written in scala) under android (in eclipse), whatever try, can't make work. simplicity created 2 projects: 1 akka project, created using sbt eclipse , imported eclipse, , 1 standard android project using project creation wizard. can reference akka-code android code, @ runtime noclassdeffounderror . appreciate if point out i'm doing wrong or in general use akka project in android app. i feel pain. spent hours trying sbt, proguard, scala, akka work, , recommend take @ project/build.scala here: https://github.com/fehguy/swagger-for-the-home/tree/master/android specifically proguard options: proguardoption in android := """ |-dontwarn scala.** |-keepclassmembers class * { | ** module$; |} |-keep class scala.collection.seqlike { | public protected *; |} |-keep public class * extends android.app.activity |-keep public class * exte

search - Searching by hash sha1 in bash script -

how use command find search file hash sha1 in bash script ? while find doesn't have option check sha1 of file natively, can make find execute sha1sum each file finds , use grep pick check sum looking for. example: find . -type f -exec sha1sum '{}' ';' | grep 7ceeeeaba7d7e22301dfc5d6707f0c7f3eeb55a8

python - "Value is Required" on arcpy.CalculateField -

i'm pretty new python, , trying write script use in arcgis 10.1 (arcpy); basic idea add new field (francis), check values in several other fields, if null (-99) output 0 francis, otherwise run simple computation.however, i'm getting error , having trouble moving beyond it: traceback (most recent call last): file "c:\gislab2\python\take_home\part1\prelim_if2.py", line 28, in arcpy.calculatefield_management(output_feature_class, "francis", "", "python_9.3", "") file "c:\program files\arcgis\desktop10.1\arcpy\arcpy\management.py", line 3128, in calculatefield raise e executeerror: failed execute. parameters not valid. error 000735: expression: value required failed execute (calculatefield). here's code # import arcpy module import arcpy print "start engines" # script arguments shapefile = "c:\\gislab2\\python\\take_home\\uscancer2000.shp" field_name = francis ou

javascript - YouTube API to play random video from tag -

i have youtube api got link... https://developers.google.com/youtube/iframe_api_reference it's working okay, looking way play random video based on tag...is possible? there tutorial on it? here code <!-- 1. <iframe> (and video player) replace <div> tag. --> <div id="player"></div> <script> // 2. code loads iframe player api code asynchronously. var tag = document.createelement('script'); tag.src = "https://www.youtube.com/iframe_api"; var firstscripttag = document.getelementsbytagname('script')[0]; firstscripttag.parentnode.insertbefore(tag, firstscripttag); // 3. function creates <iframe> (and youtube player) // after api code downloads. var player; function onyoutubeiframeapiready() { player = new yt.player('player', { height: '390', width: '640', videoid: 'u1

c++ - Setting Bit from Dynamic Array and Then Displaying it -

i have constructor creates bitarray object, asks user how many 'bits' use. uses unsigned chars store bytes needed hold many. wish create methods allow user 'set' bit, , display full set of bytes @ end. however, set method not seem changing bit, that, or print function (the overload) not seem printing actual bit(s). can point out problem please? constructor bitarray::bitarray(unsigned int n) { //now let's find minimum 'bits' needed n++; //if not "perfectly" fit //------------------------------------ehhhh if( (n % byte) != 0) arraysize =(n / byte); else arraysize = (n / byte) + 1; //now dynamically create array full byte size barray = new unsigned char[arraysize]; //now intialize bytes 0 for(int = 0; < arraysize; i++) { barray[i] = (int) 0; } } set method: void bitarray::set(unsigned int index) { //set indexed bit on barray[index/byte] |= 0x01 << (index%byte); } print overload: ostream &a

visibility - Android - why setVisibility doesn't work? -

i have togglebutton when pressed, hides/shows imageview: public void onclick(view v) { view view = (view) v.gettag(); imageview messagestatusimageview = (imageview) view.findviewbyid(r.id.messagestatusimageview); if (((checkablelinearlayout)v).ischecked()) { messagestatusimageview.setvisibility(view.gone); } else { messagestatusimageview.setvisibility(view.visible); } } the problem imageview not becoming visible again. does knows why? thanks in advance.

entity framework - One to Many Relationship with Join Table using EF Code First -

i have question how configure 1 many relationship join table using code first fluent api. have company, contact object both share common address object below class address { public int addressid ..... } class company { public int companyid ...... public virtual icollection<address> address } class contact { public int contactid ....... public virtual icollection<address> address } my expected db structure be company table companyid pk not null ..... contact table contactid pk not null ..... address table addressid pk not null ..... companyaddress table companyid not null addressid not null contactaddress table contactid not null addressid not null i able achieve using below fluent api modelbuilder.entity<company>() .hasmany(c => c.address) .withmany() .map(m => { m => m.mapleftkey("companyid") .maprightkey("addressid")

c# - Assigning first row from a generic list to an Object -

i have generic list<somecode> list containing multiple values. i trying pass first row in list object as: if(list.count==1) somecode sc = list[0]; can please tell me why happening? here class public class somecode { private int _somecodeid; private string _somecodeescription; private string _somecode; public int somecodeid { { return _somecodeid; } set { _somecodeid = value; } } public string somecodedescription { { return _somecodeescription; } set { _somecodeescription = value; } } public string code { { return _somecode; } set { _somecode = value; } } } i populate list list list. method contains object somecode sc = new somecode now when assign first row object if(list.count==1) somecode sc = list[0]; then values assigned except code. it takes items in list except first one. first item gets printed this: "sc.somecode= somecode"s how

mpi - How do I use MPI_Allgather -

i'm testing out mpi_allgather, , i'm getting strange results... following code gives me output of: "p0 received: 0,42,-1780253336,42,". correct result there 1st one, they're sending ranks. output should be: "0, 1, 2, 3,". i'm @ loss why isn't working expected. int main(int argc, char* argv[]) { int rank = 0; int size = 0; mpi_init(&argc,&argv); mpi_comm_rank(mpi_comm_world,&rank); mpi_comm_size(mpi_comm_world, &size); int* arr = new int[4]; mpi_allgather(&rank, 1, mpi_int, arr, 4, mpi_int, mpi_comm_world); if(rank == 0) { printf("p0 received: "); for(int i=0; i< 4; i++) printf("%i,", arr[i]); printf("\n"); } delete arr; mpi_finalize(); }

c# - Array value in a set of value ranges isn't displaying -

i'm trying make simple program display discount depending on how many items customer purchases. using system; using system.collections.generic; using system.linq; using system.text; namespace consoleapplication11 { class program { const int size = 4; static void main(string[] args) { int itemsbought = 0; double discountitem = 0; int[] items = new int[size] { 0, 10, 26, 61 }; double[] discount = new double[size] { 0.0, 0.05, 0.10, 0.15 }; inputitems(ref itemsbought); getdiscount(items, discount, ref itemsbought, ref discountitem); console.writeline("your discount {0}", discountitem); } private static void getdiscount(int[] items, double[] discount, ref int itemsbought, ref double discountitem) { int idx = 0; (idx = 1; idx >= items.length; idx++) { while (itemsbought >

c# - Reorder objects in a class -

i doing json parsing , have following results; { "alias": { "outlet_name": "outlet_name" }, "displayfieldname": "outlet_name", "feature": { "features": [ { "attribute": { "outlet_name": "cck 24-hr family clinic" }, "geometry": { "x": 17961.38, "y": 40715.6875 } }, { "attribute": { "outlet_name": "central clinic , surgery (bedok)" }, "geometry": { "x": 39091.43, "y": 34142.043 } }, { "attribute": { "outlet_name": "central clinic , surgery (hougang)" }, "geometry": {

Parallel MSBUILD - critical sections? -

my organization has huge builds run on build servers, building lots , and lots of msbuild projects linked projectreferences. need able build projects , configurations in parallel msbuild /m . my problem have project referenced large number of other projects, project not reentrant. if more 2 or more nodes try build project in parallel, fail. how can wrap 1 project, or it's target, inside critical section? what need this: <target> <entercriticalsection id=$(projectguid) /> <exec /> <leavecriticalsection id=$(projectguid) /> </target> the idea being if multiple msbuild nodes tried build project in parallel, 1 of nodes execution, , rest of nodes have wait (or go else). i suppose write custom msbuild tasks this, isn't there way of doing built msbuild system? === edit 4/5/13 . clarify, project building 3rd-party library build script provided it. rewriting build script make reentrant -- insuring each build used differe

MultiThreading locking up Java Swing GUI -

i'm working on project multiple user paint program , have run problem gui locking up. i have of program done except error, rather large program tried reproduce error in smaller program. in smaller program, have 2 jframes. both of them can drawn in clicking , dragging mouse. secondary jframe thread sleeps 10 seconds , sends have drawn other frame displayed. however, once main frame has received image secondary frame, gui locks , main frame can no longer drawn in. i'm using swingutilities.invokelater() method work with. while looking answers, found swingworker class, wanted see if there simple solution before undertook large rewrite of code try make work swingworker. thanks reading. code below. also, first time posting here. seemed having trouble formatting code, apologize in advance if comes out wrong. best fix it. package gui_thread_test; import java.awt.color; import java.awt.graphics; import java.awt.graphics2d; import java.awt.image; import java.awt.renderin

imagemagick - Configuring Imagick for PHP -

i want configure imagick php, don't know how. have these great tutorial sites learning how configure two, confused when read directions. i'm not using command prompt, adds confusion when direction says like: go imagick folder , type "phpize && ./configure && make && make install" or in root php source directory run ./buildconf –force rebuild configuration script i'd know if explain me how configure php imagick, explain clear directions non-technical user can follow. below tutorial websites, i'm using: http://www.ioncannon.net/php/75/how-to-compile-imagemagick-for-php-by-hand/ http://forum.directadmin.com/showthread.php?t=26443 so far, i've installed binary release of imagemagick & i've download + unzipped magickwandforphp-1.0.9-2 any appreciated. not using windows since...., if remember correctly in c:/php/ php.ini , add extension=php_imagick.dll edit: found this.. http://www.elxsy.com/20

search - CodeIgniter: How to join two table columns and use like active record for querying both? -

public function search($query, $limit) { // output $output = ""; // query $this->db->select("*"); $this->db->from("products"); $this->db->like("brand", $query); $this->db->or_like("model", $query); $this->db->limit($limit); $query = $this->db->get(); // 0 if ($query->num_rows() == 0) { $output .= "no results found"; return $output; } // result foreach ($query->result_array() $row) { // uri $uri2 = "{$this->base_url}specifications/{$row['brand']}-{$row['model']}"; $uri2 = str_replace(" ", "-", $uri2); // price format $row['price'] = number_format($row['price']); // image url $image = "{$this->base_url}assets/images/products/{$row['category']}-{$row['brand']}-{$row['

Ruby regex what does the \1 mean for gsub -

what \1 do? for example "foo bar bag".gsub(/(bar)/,'car\1') i believe has how use parentheses, i'm not sure. explain me? , can stuff \2? if so, do? each item surround parenthesis in searching part correspond number \1 , \2 , etc., in substitution part. in example, there's 1 item surrounded parenthesis, "(bar)" item, anywhere put \1 part inside parenthesis, swapped in. can put in \1 multiple times, handy if want repeat found item, legitimately write car\1\1\1 , "bar" swapped in 3 times. there's no use \2 because there's 1 item surrounded parentheses. however, if had (bar)(jar) , \1 represent "bar" , \2 represent "jar" . you things this: \1\2\1\2\2\1 which become: barjarbarjarjarbar here's real-world example comes in handy. let's have name list this: jones, tom smith, alan smith, dave wilson, bud and want change this: tom jones alan smith dave sm

android - Trying to connect tablet to local host files running PHP program -

i trying connect files via galaxy tab 2 10.1 version 4.1.1. have them on pc @ home , want connect local host. on computer localhost/insight_systems/waitstaffpos/waitstaffpos.php when put in pc's ip address , file names comes "no devices found, ip = 192.168.0.2 address of tablet. files php, ajax, javascript , html. seems issue waitstaffpos.php because can other folders fine. need special app on tablet allow these files. have looked online , people saying type in , nothing why error. appreciated. i connected wi-fi pc , tablet. ports not 100% sure ones listening in on. how determine ports , stuff? php files running pos (point of sale) system touch screens thought use local host , test on tablet.

fragment - option menu not clicked at first time in sherlockfragment -

i have used option menu in fragment.the problem when go first time fragment ,the option menu click event not called.but when go fragment.and again revist fragment option menu click event called... following code //creating option menu @override public void oncreateoptionsmenu(menu menu, menuinflater inflater) { super.oncreateoptionsmenu(menu, inflater); inflater.inflate(r.menu.newcarmenu, menu); } @override public boolean onoptionsitemselected(menuitem item) { //super.onoptionsitemselected(item); switch(item.getitemid()) { case r.id.menunewcar: _menuclickcallback.onmenuselected(); break; } return super.onoptionsitemselected(item); } please tell me why happen? right now, returning super.onoptionsitemselected(item) every time, selection being passed on. need return true when menuitem has been selected. try instead: switch(item.getitemid()) { case r.id.menunewcar:

ios - Present UIView over darkened UIWindow -

i trying present uiview while @ same time darkening rest of screen. however, having difficulty. code: uiwindow *window = [[uiapplication sharedapplication] keywindow]; self.viewtodarken = [[uiview alloc] initwithframe:cgrectmake(0, 0, 320, 568)]; [self.viewtodarken setbackgroundcolor:[uicolor blackcolor]]; [self.viewtodarken setalpha:0.0f]; [window insertsubview:self.viewtodarken abovesubview:self.hostview]; [self.hostview addsubview:self]; [uiview animatewithduration:0.25f delay:0.0 options:uiviewanimationcurvelinear animations:^(void) { [self setframe:[self destinationframe]]; if (self.viewtodarken) self.viewtodarken.alpha = 0.7f; }completion:^(bool finished) { [self notifydidshow]; }]; however, can't view darken placed below view adding (self). ideas why doesn't work? thanks! you adding viewtodarken

properties - Is there a succint way to get all the desciptors defined in a python class? -

is there simple method finding of descriptors in class type? if have code: class descriptor(object): def __init__(self): self._name = '' def __get__(self, instance, owner): print "getting: %s" % self._name return self._name def __set__(self, instance, name): print "setting: %s" % name self._name = name.title() def __delete__(self, instance): print "deleting: %s" %self._name del self._name class contrivedexample(object): name = descriptor() date = descriptor() how find out contrivedexample.name , contrivedexample.date exist outside class? you can iterate through class' __dict__ property, stores of defined names within class, , check type of value each name. descriptors = [m m,v in contrivedexample.__dict__.iteritems() if isinstance(v, descriptor)] # descriptors set ['name', 'date']

javascript - how can I tell when the scroll-bar is at a certain height? -

how can tell when scroll bar @ height meaning when there amount of space between top of scroll-bar , top of scroll-bar's track? and execute jquery code if value. let's when space between scroll-bar's , scroll-bar's track's top 50% of current viewport height alert "50% has been reached". element particular div, tag or body want check. element .scrolltop - pixels hidden in top due scroll. no scroll value 0. element .scrollheight - pixels of whole div. element .clientheight - pixels see in browser. var = element.scrolltop ; will position. var b = element.scrollheight - element.clientheight ; will maximum value scrolltop . var c = (a / b)*100 ; will percent of scroll [from 0 100] .

javascript - d3 line not drawing -

no matter can't line show up! even trying doesn't show on graph! var svg, myline; svg = d3.select(element).append("svg").attr("width", 400).attr("height", 400); myline = d3.svg.line(); svg.append("svg:path").attr("d", myline([[0, 0], [100, 100]])); i using d3 server: <script src="http://d3js.org/d3.v3.min.js"></script> perhaps should include stroke-width style.

syntax - Objective-C: Is it bad practice to use dot notation inside of a message? -

i couldn't find similar question decided ask (this may more appropriately asked on programmers, if apologize in advance). is bad practice use dot notation along message call, so: [self.view addsubview:otherview]; as opposed to: [[self view] addsubview:otherview]; i curious, looked tad bit strange don't see wrong it. i'm still relatively new objective-c , not familiar best practices of note yet. there's nothing wrong it. it's merely stylistic question. use whichever 1 prefer. (the dot notation, way, has advantage compiler throws error if you're calling undeclared property getter or setter dot notation, can potentially rid of strange run-time errors @ compile time.)

Angularjs-service data update -

this basic question on angularjs service. i've created simple app has following code. var app = angular.module('testapp', ['testservice']); app.config(['$routeprovider', function($routeprovider) { $routeprovider .when('/', {templateurl: 'partials/datadisplay.html', controller: testctrl}) .otherwise({redirectto: '/'}); }]); angular.module('testservice', []). factory('svctest', function($http){ var myservice = { getpeopleinfo: function() { $http.get('/test/app/data/getdata.php').success(function(data) { console.log("data : " + data.people); return data.people; }); } }; return myservice; }); function testctrl($scope, svctest) { $scope.people = svctest.getpeopleinfo(); } when '$http.get', getting data (and getdata.php returns valid json.).

controls - How do I put limits on OrbitControl - Three.js -

is there way put limits on orbitcontrols.js? imagine i'm creating above ground, wouldn't camera go below ground, know mean?! same things goes zoom in , zoom out. there way set variables limit that? cause don´t want camera getting close or far away. thanks lot. =) orbitcontrols source zoom in / zoom out this.mindistance = 0; this.maxdistance = infinity; where stop rotation : this.minpolarangle = 0; // radians this.maxpolarangle = math.pi; // radians don't let go below ground controls.maxpolarangle = math.pi/2;

Postgresql Select from values in array -

i converting multiple rows in array using array_agg() function, , need give array select statements condition. my query is, select * table id = all(select array_agg(id) table some_condition) but gives error, how can on come it.. the error has been cleared type casting array, using query this select * table id = all((select array_agg(id) table some_condition)::bigint[]) reference link

jquery - mobiscroll date picker show 29 days in march 2013. -

i used mobiscroll date picker in view.it works fine when select 30th march 2013 shows 29 days selectable.i don't it, there setting that.please me. in advance... i solved myself working code following $(function(){ $('#startdate').mobiscroll().date({ invalid: { }, theme: 'default', display: 'modal', mode: 'scroller', dateorder: 'mmd ddyy' }); });

Create a list of video in PHP using query string? -

i want create list of youtube video tutorial. don't want create every single page every video, see many website using query string don't know how use show me example. ===index.php=== <html> <body <a href="tutorial.php?id=10">first tutorial</a> <a href="tutorial.php?id=11">second tutorial</a> <a href="tutorial.php?id=12">third tutorial</a> </body </html> ===tutorial.php=== <?php $id = $_get['1']; **//so how display page , video here? //how determine id=10, id=11, id=12.....** ?> thanks i suggest pass actual video id index page like, <a href="tutorial.php?id=ozhvvougtom">first tutorial</a> than can directly use id youtube url, $id = $_get['id']; $videolink = "http://www.youtube.com/watch?v=".$id;

html - Adding horizontal scroll bar forcefully -

Image
i using joomla, in page want add horizontal scroll bar getting vertical scroll bar properly. web page screen shot inside portion coming iframe i want put horizontal scroll forcefully you have add css body {overflow-x: scroll;} or overflow-y element want give scroll bar to.

javascript - Joomla Modules jQuery conflict -

i have jquery conflict in 2 joomla modules. found below code in each of modules. please me resolve conflict? code in first module: <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script> //... <script type="text/javascript"> jquery(document).ready(function () { jquery('#jeyw<?php echo $module->id ?>').weatherfeed([<?php echo "'".$citycode[0]."'"; ($i=1; $i<count($citycode); $i++){echo ",'".$citycode[$i]."'";}?>],{ unit: '<?php echo $unit ?>', image: <?php echo $image ?>, country: <?php echo $country ?>, highlow: <?php echo $highlow ?>, wind: <?php echo $wind ?>, humidity: <?php echo $humidity ?>, visibility: <?php echo $visibility ?>, sunrise: <?php echo $sunrise ?>, sunset: <?php echo $sunset ?&

algorithm - All Possible Combinations from non uniform table, with only one value from each column -

background in grade 11 in school, required take 4 subjects , english list of predefined subjects. today, given grid helps make our combo, such can take 1 subject each column. the grid | economics | maths | psychology/politcal science | english | geography | | hindi/psychology | history | sociology | art | elective english | | maths | account | commerce | economics | english | | english | physics | chemistry | biology/computer applications/mecahnical drawing | maths | the problem i'm trying write program list out possible legal combinations table. rules are: english must present there must total of 5 subjects (english + 4) no 2 subjects can same column no subjects in final 5 may duplicate (note elective english , english separa

html - Cut out shape (triangle) from div and show background behind -

Image
i trying cut triangle out of div , show background behind div... not have thought possible, pros continue surprise me here thought worth shot :-) this achieve (sorry faint image): please not answer question 3 column solution or similar, more capable of achieving way... want know if there cool css tricks out there can achieve few graphics, if not no graphics, possible? you seperate triangle rectangle , go this: <div id="rectangle"><div id="mask"></div></div> #rectangle{width:300px; height:120px; position:relative; margin-top:100px; background: rgb(30,87,153); /* old browsers */ /* ie9 svg, needs conditional override of 'filter' 'none' */ background: url(data:image/svg+xml;base64,pd94bwwgdmvyc2lvbj0ims4wiia/pgo8c3znihhtbg5zpsjodhrwoi8vd3d3lnczlm9yzy8ymdawl3n2zyigd2lkdgg9ijewmcuiighlawdodd0imtawjsigdmlld0jved0imcawidegmsigchjlc2vydmvbc3bly3rsyxrpbz0ibm9uzsi+ciagpgxpbmvhckdyywrpzw50iglkpsjncmfklxvjz2ctz2vuz

c# - How can I retrieve name(Key) of applied template? -

i have template assigned button: <button x:name="btn_patmat" template="{staticresource patmat_button}" ... how can retrieve key/string/name of template said button? pseudocode: string = btn_patmat.template.???.tostring() well i'm afraid that's not possible because it's not intended wpf. there people wanted access x:name similar x:key , had give up. pls have @ so post , additional link . the workaround imagine reading templates resourcedictionary , instantiate each resource (if possible), find template (if it's e.g. style) , compare current instance of template found in control. seems pretty ugly solution , i'm not sure if it'll work without problems.

deferred - AngularJS Handle different error codes in different places -

i have service contains generic call $http ajax calls uses. here have "centralized" error handling status codes results in redirects. "fieldssync" service: return $http({ method: 'post', url: url, data: $.extend(defaultpostdata, postdata) }).error(function(data, status) { switch (status) { case 401: // "unauthorized". not logged in. redirect.tologinpage(); break; case 403: // "forbidden". role has changed. redirect.tologoutpage(); break; } }); when calling 1 of service functions controller return deferred object able hook more error callbacks able handle errors should result in kind of feedback user. controller: fieldssync.createfield(newfield).success(function(data) { ... }).error(function(data, status) { switch (status) { // <--- not want case 401: case 403: return; // these errors handled (=redirects

sockets - receiving a text file in udp in c -

i trying receive text file on udp socket , again save text file. code builds fine when run, output blank console , text file not created well. after research, found out ought give number of bytes received fwrite function tried use size_t type, didn't me :(. here code snippet: char file_buffer[100]; while(1) { // tranmsit data file / server_length = sizeof(struct sockaddr_in); if (sendto(sd, send_buffer, (int)strlen(send_buffer) + 1, 0, (struct sockaddr *)&server, server_length) == -1) { fprintf(stderr, "error transmitting data.\n"); closesocket(sd); wsacleanup(); exit(0); } size_t data=0; if(data=recvfrom(sd, file_buffer, buffer_size, 0, (struct sockaddr *) &server, &server_length)<0) { printf("error receiving file."); exit(1); } file *fp=null; fp = fopen("new_file.txt","w+"); fwrite(file_buffer, 1, data, fp);

file get contents - PHP file_get_contents breaks up at & -

solution because objective-c doesn't encode & (because reserved) should create own method. source: sending amp (&) using post obj-c for ios , android app use php script data. script has 1 argument link. script looks this: $link= urlvariable('link'); $source = file_get_contents($link); $xml = new simplexmlelement($source); //do stuff xml but when send link & symbol crashes on file_get_contents warning: file_get_contents(https://www.example.com/xxxx/name_more_names_) [function.file-get-contents]: failed open stream: http request failed! but full argument is name_more_names_&_more_names_after_the_ampersand.file i tried encoding link before sending file_get_contents no luck. also tried: function file_get_contents_utf8($fn) { $content = file_get_contents($fn); return mb_convert_encoding($content, 'utf-8', mb_detect_encoding($content, 'utf-8, iso-8859-1', true)); } with same results. does know why

java - EditText next Button keyboard -

i have layout user need write detailes in edittext placed in vertical linearlayout. however, everytime user need open keyboard, write on edittext , click on button in android , again click on next edittext , write detailes , again on , over. i want implement instead of opening , closing keyboard, instead of enter button on keyboard have next button after user entered detailes on spesific edittext , skip next edittext without closing , opening keyboard every time. i saw there apps has feature, didnt find how can implement it thanks alot here example of layout: <linearlayout android:layout_width="283dp" android:layout_height="match_parent" android:layout_marginleft="20dp" android:layout_marginright="20dp" android:orientation="vertical" > <textview android:id="@+id/aaa" android:layout_width="match_parent" andr

javascript - Is it possible to start/pause auto refreshing content? -

i using script auto refresh content every 10 seconds. var auto_refresh = setinterval( function () { $('#stats').load('stats.php').fadein("slow"); }, 10000); however, need add start/pause button start , pause refresh. how can ? in general sense can pause effect setinterval() adding flag: var paused = false, auto_refresh = setinterval(function (){ if (paused) return false; $('#stats').load('stats.php').fadein("slow"); }, 10000); $("#idofpausebutton").click(function() { paused = !paused; this.value = paused ? "restart" : "pause"; }); i find method simpler using clearinterval() pause , setinterval() again restart. obviously assumes use single button pause/restart: <input id="idofpausebutton" value="pause" type="button"> demo: http://jsfiddle.net/nnnnnn/nwa56/

html5 - data-bind="attr:{for:id()+'check'}" do not work for 2.3 android but work for 4.0+ android -

i using phonegap, html 5,knockout develop below code not work 2.3 android work 4.0+ android <input type="checkbox" data-bind="checked: ischecked,attr:{id:id()+'check'}" class="checkboxinput" /> <label data-bind="attr:{for:id()+'check'}"></label> may script error none of knockout data load after that. where code below (hard-coded without ko) works <input type="checkbox" id="test" class="checkboxinput" /> <label for="test"></label> thanks attention edward van raak just small change, single quotes? 'for':id() , work <label data-bind="attr:{'for':id()+'check'}"></label>

android - autobahn not working with tomcat 7 websocket -

sorry english. i want program native app in android connect server interactive comunications. websocket tegnology perfect fothis. have installed , working tomcat 7.0.39 in laptop ip 192.168.1.250. have tryed examples echo, snake, etc , works fine using ws://localhost:8080/.... , using ws://192.168.1.250:8080/... i'm using autobahn eclipse connect server. have installed apk in android mobile autobahn client websocket sample , connects withn ws://echo.websocket.org. the problem android server (in laptop) not work. android ws://echo.websocket.org works fine (i supose autobahn example works well), server works fine because de examples comes tomcat work fine. because have make intesive work information travel between server , clients, can't use javascript on server side, need java servlets or others work databases, files ando on. what wrong? firewall off, , wireshark show me how android client try connect laptop server ( don't anderstand wireshark info ) connection