Posts

Showing posts from January, 2012

php strange behavior while changing value -

having snippet buffering events. $temp = array(); while ($row = $source) { $temp[] = $row; // `add_day` means how many of next days add buffer $d = new datetime($row->date); ($i = 0; $i < $row->add_day; $i++) { $d->modify('+1 day'); $row->date = $d->format('y-m-d'); $temp[] = $row; // print_r($row) --> it's ok. `date` has proper value. } } while tracking single event, seems fine. in result - $temp array, rows forcycle have same date value. (the last one.) e.g. $data = { date: '2015-07-01', add_day: 2 } result: $temp[0] = { date: '2015-07-03'} $temp[1] = { date: '2015-07-03'} $temp[2] = { date: '2015-07-03'} where doing mistake?? you keep overwriting value date in object. since array has references same object return same value. for ($i = 0; $i < $row->add_day; $i++) { $d->modify('+1 day');

c# - Cast int[] into MyType[] where MyType inherited from Enum? -

i try cast int array int[] rights array rights[] , rights enum example... can other type rights inherited enum . got final type in type variable. can create enum[] array not final rights[] array methodinfo.invoke(obj,param.toarray()) . list<object> param = new list<object>(); parameterinfo pi = ... if (pi.parametertype.isarray && pi.parametertype.getelementtype().isenum) { list<enum> enums = new list<enum>(); foreach (int in gettabint()) { enums.add((enum)enum.toobject(pi.parametertype.getelementtype(), i)); } param.add(enums.toarray()); // got enum[] not rights[] } thank helping me! you need create array of appropriate type. since type isn't known @ compile time, must use array.createinstance() . can use helper method. public array toenumarray(type type, icollection values) { if (!typeof(enum).isassignablefrom(type)) throw new argumentexception(string.format("type '{0}'

mongodb - Meteor Data Model in Mongo -

i'm evaluating server side frameworks , i'll glad hear think following problem meteor: i have working system built mongodb, nodejs , angular. i've design data models in mongo according needs of system , common sense. example, system based around concept of project contain several components have proejcts collection , inside documents looks like { _id: objectid('123'), name: "project a", components: [ { comptype: "type-a" }, { comptype: "type-b" } ] } now i'm evaluating meteor server side framework , after playing while, reading documentation , looking @ examples see in simple todos example instead of modeling data list contain todos in it modeled 2 separate collections. i understand done purpose of allowing ddp sync data required specific client feels wrong take projects collection , split sake of helping ddp, because means i'm modeling database according front-end needs , not

c - Linker error with flex -

i finished compiling , installing flex macbook pro , tried compile file using flex. following error: ld: library not found -lfl clang: error: linker command failed exit code 1 (use -v see invocation) make: *** [myhtml2txt] error 1 i believe -lfl linker flex, why getting error, , how can fix it? you missing add libflex or libfl. main error ld: library not found -lfl tells library missing. l in -lfl denotes library. adding library not see error

java - How to use BitmapShader without repeat -

Image
i working on drawing app, want draw heart shape user finger touch mobile screen. setup bitmapshader below code //initialize bitmap object loading image resources folder bitmap fillbmp = bitmapfactory.decoderesource(context.getresources(), r.drawable.heart); fillbmp = bitmap.createscaledbitmap(fillbmp, 20, 20, false); //initialize bitmapshader bitmap object , set texture tile mode shader= new bitmapshader(fillbmp, shader.tilemode.repeat, shader.tilemode.repeat); then assign shader paint object. paint.setshader(preset.shader); i have setup touch listener track user finger. on user touch draw on canvas object as. path path = new path(); path.moveto(mid1.x, mid1.y); path.quadto(midmid.x, midmid.y, mid2.x, mid2.y); canvas.drawpath(path, paint); this give me this where heart shape croped , these repeated. want not these repeated , never croped this. thanks in advance. i had bit of trouble uploading git, now, i'll post solution here. here

python - Werkzeug and class state with Flask: How are class member variables resetting when the class isn't being reinitialized? -

i'm trying write flask extension needs persist information between requests. works fine when run werkzeug single process when run multiple processes odd behavior don't understand. take simple application example: from flask import flask app = flask(__name__) class counter(object): def __init__(self, app): print('initializing counter object') self.app = app self.value = 0 def increment(self): self.value += 1 print('just incremented, current value ', self.value) counter = counter(app) @app.route('/') def index(): in range(4): counter.increment() return 'index' if __name__ == '__main__': #scenario 1 - single process #app.run() #scenario 2 - threaded #app.run(threaded=true) #scenario 3 - 2 processes app.run(processes=2) for first 2 scenarios behaves expect: counter object initialized once , increments every request '/' route. when run

Localization/Language preferences doesn't change widget's language in android -

in application let users change language of application.i this: public void onupdate(context context, appwidgetmanager appwidgetmanager, int[] appwidgetids) { // there may multiple widgets active, update of them final int n = appwidgetids.length; (int = 0; < n; i++) { updateappwidget(context, appwidgetmanager, appwidgetids[i]); int appwidgetid = appwidgetids[i]; //get sharedpreferences sharedpreferences sharedpreferences = preferencemanager.getdefaultsharedpreferences(context); //get default local first initialization string defaultlanguage = context.getresources().getconfiguration().locale.getlanguage(); configuration configuration = new configuration(); //check language preference everytime oncreate of activities, if there no choise set default language locale newlocalelanguage = new locale(sharedpreferences.getstring("newlanguagepref",defaultlanguage)); //finall

Thymeleaf form validation with spring MVC -

Image
this has been asked few times of them did not answer question. have been trying different functionalities work thymeleaf 2 days , been unsuccessful. have been able work spring-boot, right using spring-mvc. first show dependencies <%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %> <%@ page contenttype="text/html;charset=utf-8" language="java" %> <html xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>create new account</title> <link th:href="@{/resources/css/loginform.css}" href="/resources/css/loginform.css" rel="stylesheet" type="text/css"/> </head> <body> <form action="#" th:action="@{/createnewaccount}" th:object="${user}" method="post"> <table> <tr> <td>na

apache spark - Exception: could not open socket on pyspark -

whenever trying execute simple processing in pyspark, fails open socket. >>> myrdd = sc.parallelize(range(6), 3) >>> sc.runjob(myrdd, lambda part: [x * x x in part]) above throws exception - port 53554 , proto 6 , sa ('127.0.0.1', 53554) traceback (most recent call last): file "<stdin>", line 1, in <module> file "/volumes/work/bigdata/spark-custom/python/pyspark/context.py", line 917, in runjob return list(_load_from_socket(port, mappedrdd._jrdd_deserializer)) file "/volumes/work/bigdata/spark-custom/python/pyspark/rdd.py", line 143, in _load_from_socket raise exception("could not open socket") exception: not open socket >>> 15/08/30 19:03:05 error pythonrdd: error while sending iterator java.net.sockettimeoutexception: accept timed out @ java.net.plainsocketimpl.socketaccept(native method) @ java.net.abstractplainsocketimpl.accept(abstractplainsocketimpl.java:404)

android - Add a line after the fragment in the LinearLayout -

i trying add line after man fragment in linearlayout distinguish between map area , yellow area below map black line appear? how can add line after map fragment? i appreciate helo. map.xml <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffff00"> <fragment android:layout_width="match_parent" android:layout_height="500dp" android:id="@+id/map" android:name="com.google.android.gms.maps.supportmapfragment"/> <view android:layout_width="fill_parent" android:layout_height="2dp" android:background="#181407"/> </linearlayout> try setting android:orientation vertical . cause view appear below fragment, not right of it.

class - PHP: Get static method reference -

i want reference of static method static method in same class, php interprets 2 lines (see example code below) access constant. not possible reference static methods in php? class foo { public static function test() { self::bar(); // calling (not referencing) works $bar_reference = self::bar; // error: undefined class constant 'bar' } public static function bar() { echo "hello"; } } foo::test(); $bar_reference = foo::bar; // error: undefined class constant just clarify again: not want call static method - want reference it. you can create callable this: class foo { public static function test() { $bar_reference = array(__class__, 'bar'); // call $bar_reference(); } public static function bar() { echo "hello"; } } foo::test(); $bar_reference = foo::bar();

assembly - Printing "array" from .bss in gdb -

my nasm x86 assembly code contains following: ; code should mimic following c-code: ; int a[10]; ; (int = 0; < 10; i++){ ; a[i] = i; ; } section .data arraylen dd 10 section .bss array resd 10 section .text global main main: mov ecx, 0 mov eax, 0 loop: inc ecx mov dword [array+eax*4], ecx inc eax cmp ecx, arraylen jl loop end: mov ebx, 0 mov eax, 1 int 0x80 now want check whether code works in gdb. however, how print array ? print array returns $1 = 1 . print array + x unfortunately arithmetical operation, i.e. e.g. print array + 50 prints 1+50 = 51 , not non-existent 51st array element. you can do: (gdb) x/10 &array 0x8049618: 1 2 3 4 0x8049628: 5 6 7 8 0x8049638: 9 10 ps: code broken, need cmp ecx, [arraylen] .

PHP code to encode DB data in JSON not working -

i'm stuck php code. want access table in database , retrieve data in json format. therefore, tried following code : <?php $con = mysqli_connect("......","username","pwd","dbname"); if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $sql = "select * users"; if ($result = mysql_query($con, $sql)) { $resultarray = array(); $temparray = array(); while($row = $result->fetch_object()) { $temparray = $row; array_push($resultarray, $temparray); } echo json_encode($resultarray); } mysqli_close($con); ?> however, it's getting me empty page. worked once special number of row in table, not efficient might guess. does have idea why i'm getting weird results? edit 1 : i tried add code : echo json_encode($resultarray); echo json_last_error(); and it's returning me 5. seems error data encoding in table. therefo

php - Storing BLOB images in sql database for a SMALL website. - mysql -

there many questions on stack overflow on whether storing images in db worth big websites , poeple no. making small website potentially hold 20 images. have spent alot of time setting images uploaded database around 20 - 200 images - (around 10 - 50 kib) slow down website if have images stored on database blob file. i likes structure of db can add/edit/delete images rather going through hassle of storing images on web server. so uploading 20-200 images around 10 - 50 kib, slow down website , how slower get? the possible slow down depends on environment. should negligible when php implementation right. but browser caching may cut down page load time. so, have implement http stuff related browser caching, e.g. http head, http etag, etc. then, it's easier store images local files, implement simple add/edit/delete operations, , let complicated caching stuff web server.

PHP mysql - Get corresponding user with post -

i'm trying return blog_post,blog_title mysql databse need user , his/her's data (in seperate array's) the output should like array( 'blog1' => array( 'title' => 'this title', 'post' => 'this blogs content', 'user' => array( 'username' => 'name', 'lastname' > 'lastname' ) ), 'blog2' => array( 'title' => 'this title', 'post' => 'this blogs content', 'user' => array( 'username' => 'name', 'lastname' > 'lastname' ) ) ) using mysql there no way of doing in 1 query because mix 2 tables. i have tried using left_join,right_join , selecting multiple tables like select * blogs a, users b b.id = a.id then have tried using foreach , while loop. $post

dataframe - Altering order and names of data-frame by row in r -

i have data-frame looks following: > disintegrationbehavior gden degree 1.txt 0.45000000 0.7083333 14.txt 0.58333333 0.5000000 11.txt 0.50000000 0.4166667 12.txt 0.50000000 0.6666667 13.txt 0.25000000 0.5000000 i remove .txt row names, add "team" in front of every row number, , order results row number (or whichever order easier) final result looks like: > disintegrationbehavior gden degree team1 0.45000000 0.7083333 team11 0.50000000 0.4166667 team12 0.50000000 0.6666667 team13 0.25000000 0.5000000 team14 0.58333333 0.5000000 thank you! you do s <- sub(".txt", "", rownames(df), fixed = true) rownames(df) <- paste0("team", s) df[order(as.numeric(s)), ] # gden degree # team1 0.4500000 0.7083333 # team11 0.5000000 0.4166667 # team12 0.5000000 0.6666667 # team13 0.2500000 0.5000000 # team14 0.5833333 0.5000000 data: df <- structure(list(gden = c(0.45, 0.58333

c++ - Efficient least significant set bit of "biginteger" class -

i'm writing boardgame engine , wrote 10x10 bitboard class. class holds array of 2 uint64's , implements various bit operations. important operation didn't implement yet lsb() . know can lsb() on first integer , if it's 0 on second. however, checking if it's 0 seems redundant. efficient way implement lsb() ? edit: current code is: char s = lsb64(b_[0]); if (s == 0 && b_[1] != 0) { s = lsb64(b_[1]) + 64; } return s; lsb64() here returns 1 + index of bit are there performance improvements make? note if condition false. if expect inputs have bit set in lower 64 bits, have profile execution. following avoids 2 lsb64 calls. return b_[0] ? lsb64(b_[0]) : (b_[1] ? 64 + lsb64(b_[1]) : 0); possible solutions lsb64 can found in related question .

javascript - Trying to remove duplicates from list not working -

i want print usernames of email addresses supplied in <textarea> , without duplicates. <textarea id="emailtextarea" rows ="10" cols="25" > sara@yahoo.com adam@yahoo.com todd@yahoo.com henry@yahoo.com wright@yahoo.com sara@yahoo.com adam@yahoo.com todd@yahoo.com </textarea> <body onload="emailsort()"> <script> //email sort function function emailsort(){ //get data textarea var emaillist = document.getelementbyid("emailtextarea").value; //put array var emaillistarray = emaillist.split("\n"); //remove extension , duplicates var usernamesarray = emaillistarray.map(function(val, index, arr) { var username = val.slice(0, val.indexof('yahoo.com')); if(!val[username]) val[username] = true; return emailusers; }); //sort list var sortedusernames = usernamesarray.sort(); //print out list document.write(s

PHP Regex Multiple Links Paragraph Display Domain Only -

the following code changes every link within paragraph clickable [external link] instead. i have run twice catch both http , https. 1) there way turn single line? 2) how change instead of [external link] display domain name only? google.com actual link may longer. reason use [external link] shorten longer urls. //regular http links $text = preg_replace('/(^|[^"])(((f|ht){1}tp:\/\/)[-a-za-z0-9@:%_\+.~#?&\/\/=]+)/i', '\\1<a href="\\2" target="_blank">[external link]</a>', $text); //https links $text = preg_replace('/(^|[^"])(((f|ht){1}tps:\/\/)[-a-za-z0-9@:%_\+.~#?&\/\/=]+)/i', '\\1<a href="\\2" target="_blank">[external link]</a>', $text); you can add ? make "s" optional. https://regex101.com/r/lorv7s/1/ $text = preg_replace('/(^|[^"])(((f|ht){1}tps?:\/\/)[-a-za-z0-9@:%_\+.~#?&\/\/=]+)/i', '\\1<a href="\\

string - Removing single dot path names in URL in C -

i'm making function in apache module supposed fix urls thrown @ it. i'm trying remove single dot path names. for example, if url is: http://example.com/1/./2/./3/./4.php then want url be: http://example.com/1/2/3/4.php however i'm stuck logic. i'm using pointers in effort make function run fast possible. i'm confused @ logic should apply @ lines //? added end of them. can give me advice on how proceed? if hidden manual online? searched bing , google answers no success. static long fixurl(char *u){ char u1[10000]; char *u11=u1,*uu1=u; long ct=0,fx=0; while (*uu1){ *u11=*uu1; if (*uu1=='/'){ ct++; if (ct >=2){ uu1++; break; } } else { ct=0; } } while (*uu1){ if (*uu1!='/') { //? if (*uu1!='.') { *u11=*uu1; u11++; } //? } //? uu1++; } *u11='\0'; strcpy(u,u1); return fx; } you forget ahead

javascript - Multiple .active classes for navigation with jQuery -

i have simple page uses jquery hide , show content. have 3 links, , 3 divs related 3 links. when click 1 of links div displayed. jquery script adds .active class link can show link active. my problem need have 3 different .active classes, 1 each link, can have different background image when it's active. here jquery code runs all: <script type='text/javascript'>//<![cdata[ $(window).load(function(){ $('.link').click(function(e) { e.preventdefault(); // remove active classes: $('.active').removeclass('active'); $(this).addclass('active'); // hide content: $('.content').fadeout(); $('.logo').fadeout(); // show requested content: var content = $(this).attr('rel'); $('#' + content).fadein(); }); });//]]> </script> i couldn't figure out how create jsfiddle, have link dev page here: http://agoberg.tv/kiosk/

Problems not suitable for machine learning -

i know there lot of problem suitable machine learning, problem not suitable it? when should not use machine learning? too broad question so, i'll try answer theoretically: problem in ml generalization on unseen data, has pattern, because can info (predict label, cluster) new unseen data if learned distribution before. theoretically can force machine learn task has non-random distribution relative available features, need have enough data desired accuracy. that's why it's impossible in practice. because capture hard distribution rules need have big variative (more universal), or more specific (but it's includes own knowledge data) model, , learn model without overfitting need have big dataset, of need have powerful computational resources , on. if interested in more detailed explanation theoretical aspect, can watch lectures caltech, starting caltechx - cs1156x learning data . also there theoretical equations predict generalization abilities of model r

ruby on rails - How To Create Clothing Items Model - Different Sizes for Shoes, Shirts, Jeans ect -

im creating online retail store. just wondering how of professionals go creating clothes model. problem shoes have different sizes mens 8,9,10,12 ect. shirts have 38,40,42 chest. jeans have 32, 34,36. dresses have size 6, 8 ect. how go making clothing items model. when creates , item, first click on category want. lets shoes, brings down list of shoe sizes , can put in quantity each shoe size have , other attributes price , ect. you can use polymorphic associations solution looking for. case can create models shown below # models class commonsize < activerecord::base belongs_to :common_sizable, :polymorphic => true end class shoe < activerecord::base has_many :common_sizes, :as => :common_sizable end class dress < activerecord::base has_many :common_sizes, :as => :common_sizable end class shirt < activerecord::base has_many :common_sizes, :as => :common_sizable end # contro

computer vision - Possible to use a deep learning network on a collection of still images? -

i have collection of thousand trading cards different pictures on them. have database of high resolution scans of every 1 of these trading cards have ever been printed. i'd feed scanned images deep learning network, such if hold 1 or more of cards in front of camera, able identify one(s) holding. it looks jetpac might place me start. have experience machine learning, numerical analysis, not image processing. examples i've seen far show people filming thing they're interested in identifying, , being able identify it. but, able dump folder of images in training data instead? lastly, i'm aiming implement on system of raspberry pi 2's i've networked work in parallel. i'm not sure jetpac explicitly able support distributed computing, figure may able split video feed multiple feeds, , run each feed separate instance of jetpac on separate rpi. am thinking problem right way? different approach more practical? help!! edit: fear of sounding question gener

javascript - Local storage for events when click button X Close on window chat box? -

i novice, now, learning html5. i buiding window chat box using css. want function facebook'chatbox. specificly, when click button "x" on window chat box on tab1 close on tab2,tab3,tab4,....tab n of browser. also operate same hiding window. think need use local storage problem, don't know how please me ! step 1: create database , tables it. need table store users. need other tables store user status. when user logged in, user associated user table , status table(s) having foreign key user table. step 2: need develop service on server-side handle post requests. these requests either update status or ask latest status. step 3: on client-side, need polling repeatedly latest status. step 4: whenever status changes, refresh ui components. step 5: handle ui events. instance, when click on x, status update should sent server tab needs closed. other tabs latest status when next polling request gets response , ui refreshed. easier said done, these ste

Android webview loading data performance very slow -

hi working on 1 application, in using android webview. whenever launch webview activity, loading data in string html format test.txt file. test.txt file contains 2.5 mb data, after loading test.txt file, if slide screen end read data , press back. subsequent launch of webview activity taking more time render data. in first launch of webview taking minimal time. not getting error/exception/crash in between launching activity. i using android api level 18 , above note: did lot of research on issue. tried solution android webview slow , android webview performance no use. i can't make android:hardwareaccelerated="true" <-- why because has lot of side effects (still used one, no changes found on issue). i can't use webview.getsettings().setrenderpriority(renderpriority.high); setrenderpriority() --> method deprecated in api level 18. not recommended adjust thread priorities, , not supported in future versions. my datalo

Amazon S3 sync Deleting excluded files -

i have 2 buckets, bucket , bucket b. bucket contains javascript files , bucket b contains mix of javascript , other file types. trying sync of js files bucket b. i using following: aws s3 sync s3://bucket-a s3://bucket-b --delete --exclude "*" --include "*.js" i assuming leave bucket b exact copy of of js files. above command start deleting of non js files in bucket b. when run following command: aws s3 sync . s3://bucket-b --delete --exclude "*" --include "*.js" with current directory containing copy of bucket a, bucket b have same js files bucket , non js files not affected. why command functioning differently when syncing local bucket compared bucket bucket? edit: added cli input/output reproduce problem. darrrens-mbp:testfolder darren$ aws --version aws-cli/1.7.4 python/2.7.9 darwin/14.4.0 darrrens-mbp:testfolder darren$ aws s3 ls s3://tmp-test-bucket-a 2015-09-01 11:40:44 2 test1.js 2015-09-01 11:40

antlr4 - How to define a token which is all those characters in set A, except those in sub-set B? -

in rfc2616 (http/1.1) definition of 'token' in section '2.2 basic rules' given as: token = 1*<any char except ctls or separators> from section, i've got following fragments, , want define 'token': lexer grammar acceptencoding; token: /* (char excluding (ctrl | separators)) */ fragment char: [\u0000-\u007f]; fragment ctrl: [\u0000-\u001f] | \u007f; fragment separators: [()<>@,;:\\;"/\[\]?={|}] | sp | ht; fragment sp: ' '; fragment ht: '\t'; how approximate hypothetical 'excluding' operator definition of token ? there no set/range math in antlr. can combine several sets/ranges via or operator. typical rule number of disjoint ranges looks like: fragment letter_when_unquoted: '0'..'9' | 'a'..'z' | '$' | '_' | '\u0080'..'\uffff' ;

angularjs hide vertical scrollbar for mobile devices -

i developing application using bootstrap , angular js. i have left side dynamic navigation bar containing more data.(customer numbers) my requirement is, don't want show scroll bar mobile devices. should visible scroll bar when scrolling. how achieve functionality angular? <!-- sidebar --> <div id="sidebar-wrapper"> <ul class="sidebar-nav"> <li class="sidebar-brand"> <a href> customer view </a> </li> <li ng-repeat="customer in customerdata" ng-class="{activeblock: $index == selected}"> <a href data-toggle="tab">{{customer.customernumber}}</a> </li> </ul> </div> <!-- /#sidebar-wrapper -->

java - Error retrieving parent for item in Android Studio -

new android development. have created "hello world" project in android studio (version 1.3.1). experimenting how show logs , see how app run. here have in mainactivity.java automatically created android studio , added log tag. public class mainactivity extends appcompatactivity { private static final string tag = "mjmessagefromactivities" @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); log.i(tag, "oncreate"); } @override public boolean oncreateoptionsmenu(menu menu) { getmenuinflater().inflate(r.menu.menu_main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { int id = item.getitemid(); if (id == r.id.action_settings) { return true; } return super.onoptionsitemselected(item); } } when run app se

pointers - C - Segmentation Fault while Creating Binary Tree Using recursion -

i trying write simple program of creating binary tree using pointers in c , unable find problem code. receiving segmentation fault on second insertion. the program takes input of 5 numbers , creates binary tree using array input.sample run : here output of program enter 5 elements : 45 78 89 32 46 in generatebst in insert going right sub tree in insert segmentation fault please me resolve error. thank you. #include <stdio.h> #include <stdlib.h> typedef struct node { int value; struct node * lst; struct node * rst; }node; void printbst(node *root){ puts("in printbst"); if(root == null){ return; } printbst(root->lst); printf(" %d ", root->value); printbst(root->rst); } void insert(node **root, int element){ puts("in insert"); if((*root)->value > element){ puts("going left sub tree"); insert(&(*root)-

javascript - Need to replace my data from json to csv file -

i'm working json file need replace csv file. need use library or can change jquery json csv? i've tried no luck not working. my javascript code th $(document).ready(function() { $.ajax({ url: 'somefile.json', type: "get", datatype: "json", success: function (data) { $(".score-text").each(function( index, value ) { value.innertext = data['box'+(index+1)].total; }); $(".data").each(function( index, value ) { var boxindex = math.floor(index/4); width = data['box'+(boxindex+1)]['bar'+(index+1-boxindex*4)]; value.innertext = width; value.style.width = width; }); } }); }); i'm using csv array getting errors code $(document).ready(function() { $.ajax({ url: "somefile.csv", success: function (csvd) { data = $.csv2array(csvd); }, d

c - How to access a structures' members outside of its original function? -

i working on project creating structures inside of separate function main() . after being created , added member (variable) information structure variable, need able return pointer structure in can access reference , printing. i including code , please simple possible new structures. #include <stdio.h> #include <stdlib.h> #include<string.h> typedef struct _car { char color[20]; char model[20]; char brand[20]; int year; struct _car *eptr; } car; car* readcars(char* filename); /* * */ int main(int argc, char** argv) { car *cars; car *eptr; cars = readcars(argv[1]); printf("%s%s%s%s", cars->color, cars->brand, cars->model, cars->color); return (exit_success); } car* readcars(char* filename) { file *file = fopen(filename, "r"); int year; char color [20], model [20], brandx[20]; car car1; car car2; car *carptr; car *car2ptr; if (file == null) {

android - Error:non static method 'edit' cannot be referenced in static context -

public class navigationdrawerfragment extends fragment { public static final string pref_file_name="testpref"; private actionbardrawertoggle mdrawertoggle; private drawerlayout mdrawerlyout; private boolean muserlearneddrawer; private boolean mfromsavedinstancestate; public navigationdrawerfragment() { // required empty public constructor } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout fragment return inflater.inflate(r.layout.fragment_navigation_drawer, container, false); } public void setup(drawerlayout drawerlayout,toolbar toolbar) { mdrawerlyout=drawerlayout; mdrawertoggle=new actionbardrawertoggle(getactivity(),drawerlayout,toolbar,r.string.drawer_open,r.string.drawer_close){ @override public void ondraweropened(view drawerview) { super.ondraweropened(drawerview); } @

html - Image overlapping on border in Safari -

this has stumped us. think first time ever did image container border-radius: 50% , image inside resizes in scale when rollover. managed keep image in container image still overlaps border of container. please see link reference. a { display: block; height: 160px; width: 160px; } .image-wrapper { border: 6px solid red; display: block; border-radius: 50%; height: 100%; overflow: hidden; position: relative; z-index: 99; } a:hover img { -webkit-transform: scale(1.25); -ms-transform: scale(1.25); transform: scale(1.25); } img { transition-property: all; transition-duration: 1s; transition-timing-function: cubic-bezier(0.19, 1, 0.22, 1); -webkit-backface-visibility: hidden; -webkit-transition-property: all; -webkit-transition-duration: 1s; -webkit-transition-timing-function: cubic-bezier(0.19, 1, 0.22, 1); -webkit-transform: scale(1); -ms-transform: scale(1); transform: scale(1); }

cURL image upload using multipart/form-data -

i have been 1 month dealing following code post image using curl remote server. function post_file($url) { $file_url = "6.jpg"; $eol = "\r\n"; $boundary = '111151173914518'; $body=""; //init curl body $body.= '-----------------------------'.$boundary. $eol; $body .= 'content-disposition: form-data; name="input1"' . $eol . $eol; $body .= "left" . $eol; $body.= '-----------------------------'.$boundary. $eol; $body.= 'content-disposition: form-data; name="input2"' . $eol . $eol ; $body .= "right" . $eol; $body.= '-----------------------------'.$boundary. $eol; $body.= 'content-disposition: form-data; name="input3"' . $eol . $eol ; $body .= "up" . $eol; $body.= '-----------------------------'.$boundary. $eol; $body.= 'content-disposition: form-data; na

java - How to handle multi resolution images in slideshow? -

i use code slideshow, , it's working 100%, problem image resolution if resolution high no problem if low image shown in bad shape. and code : public class easyview_v1 { public static timer tm = null; public static file[] f = new file("c:/ma7moud/my projects/rami/netbeans/web applications/thechatserverapp_3/web/images/brugges2006/big").listfiles(); public static void main(string[] args) { jpanel panel5 = new jpanel(); jlabel pic = new jlabel(); pic.setsize(new dimension(610, 695)); //call function setimagesize try { setimagesize(f.length - 1, f, pic); } catch (exception e) { system.out.println(e.tostring()); joptionpane.showmessagedialog(null, "images directory not found", "error", joptionpane.error_message); joptionpane.showmessagedialog(null, "plz check images directory , try again", "attention", jopt

Shopify - started getting 404 exceptions when updating variants -

i've had first shopify store running month now, using php batch script either create new products , variants, or update , when needed existing web-based product management system. seems have been running fine i've noticed i'm getting exception thrown when updating variants. i'm sure has been working fine (been able update variant needed) bit of figuring out why failing now. here's example: shopifyapiexception object ( [method:protected] => put [path:protected] => /admin/variants/4294967295.json [params:protected] => array ( [variant] => array ( [price] => 8.00 [sku] => 2217 [id] => 2217 [product_id] => 21880 [inventory_management] => shopify [inventory_policy] => deny [inventory_quantity] => 1 [option1] => plain \/ ex [option2] => strictly rhythm

Does R's package support unicode rd file? -

my platform is: win7 64 rtudio r3.1.3 devtools 1.8.0 rxygen2 4.1.1 i trying make package of own. need describe function unicode. used roxygen2 generate rd file. code simple(i removed real function know how make package): xxxx means comment made unicode. #' eastchoice #' @param fn.kind wind xxxxxx #' @param estchoice.path wind #' @return data.frame #' @export #' @examples #' getindbyeastchoice("20150108.csv") getindbyeastchoice <- function(fn.kind){ d <- data.frame(a=c(1,2,3), b=c(4,5,6)) dt <- data.table::data.table(d) } when check(devtools) r code, failed. following error information given: * checking pdf version of manual ... warning latex errors when creating pdf version. typically indicates rd problems. latex errors found: ! package inputenc error: unicode char \u8:��<87> not set use latex. see inputenc package documentation explanation. type h <return> immediate help. at first thought roxygen2 not

javascript - Node.js Express: loading JSON file only on server startup -

i'm working on express.js app should load api definition file (most swagger file in json format). i've created middleware, should parse json file via fs.readfile() , json.parse() in order check user's permissions on accessing resource. each time request performed, middleware gets same json file , parses it, piece of work. possible load json file, parse , store internal object in sort of global configuration , reload in case modified not perform same operation on each request? of course, create function (pseudo code): var jsondata=null; function getconfiguration() { if (!jsondata) { jsondata= readfilesync(...); } return jsondata; } module.exports.getconfiguration=getconfiguration; or, @aleksandrm commented, can "import" using require :

c# - Converting a byte[]-Array to ANSI -

i trying convert byte[] blob in mssql database windows-1252 ansi format using c# , microsoft lightswitch, , return results file download. this thought should work... i'm creating string with system.text.encoding v_unicode = system.text.encoding.unicode; system.text.encoding v_ansi_windows_1252 = system.text.encoding.getencoding(1252); string v_content_1252 = v_ansi_windows_1252.getstring(system.text.encoding.convert(v_unicode, v_ansi_windows_1252, v_unicode.getbytes(v_content))); byte[] ansiarray = v_ansi_windows_1252.getbytes(v_content_1252); and write in database. when try retrieve with int v_fileid = int32.parse(context.request.querystring["p_fileid"]); datatablename v_fexpd = servercontext.dataworkspace.applicationdata.datatablename_singleordefault(v_fileid); memorystream memstream = new memorystream(v_fexpd.inhalt); string v_content= system.text.encoding.getencoding(1252).getstring(v_fexpd.content); context.response.clear(); context.response.content

WinJS - rating control renders weirdly in Firefox -

Image
i'm trying out winjs following tutorial on official page here . unlike ie11 , chrome on firefox 40.0.2 goes wrong - second star in rating control rendered either invisible or partially visible. i simplified example , replicated issue in jsfiddle can't figure out causes problem, since when tried remove different parts of css , html magically disappeared wasn't wanted: adding rating control results in preceeding control render incorrectly, though other fine. removing css hides parts of html made rating render well. i couldn't replicate issue without mess. sorry. i guess it's winjs bug, then, why or how can prevent in future , there workaround? the code html <div id="app" class="show-home win-type-body"> <!-- split view --> <div class="splitview" data-win-control="winjs.ui.splitview"> <!-- pane area --> <div> <div class="header&quo