Posts

Showing posts from June, 2011

matlab - Reshape column vector -

hello i'm working matlab , have "z" column vector has dimension of (9680 x 1). want reshape in order have array "z" of dimension (44 x 220). i'm doing following: z=reshape(z,44,220); i tried: z=reshape(z,[44,220]); but output not right (at least first row). can see comparing output matrix initial vector. i need 220 first positions of column vector length of first row of matrix, next 220 positions of vector second row of matrix , on till obtaining 44 rows. what doing wrong? help. matlab stores matrix values in column major format (this important during reshape). since want row major, need do z = reshape(z, [220 44]).'; i.e. transpose afterwards.

3D inventory tracking data structure and algorithm -

summary of problem: we need keep track of inventory of solid 3 dimensional rectangles (i believe these called cuboids stand corrected). each cuboid arrives fixed length, breadth, , depth. let's it's 20x5x5 argument's sake. begin, have 10 of these 20x5x5 cuboids in stock. then during course of business, smaller / secondary cuboids of variable dimensions cut out these bigger / primary cuboids. summary of question: a) data structure best track stock of primary cuboid stock availability. b) algorithm(s) best determine whether primary cuboid can cater secondary cuboid cut out? additional details , issues: the first cut primary cuboid easy calculate / determine. problem comes hand second, third, , on cuts, since need track resulting dimensions of edges , vertices of primary cuboid remaining in stock. if more 1 primary cuboid meets requirements secondary cuboid, smallest primary cuboid preferable cater fifo depletion of stock. need calculate remaining volume

How to draw line graphs in Swift? -

Image
for new app need draw line graph. graph needs consist of 2 references lines, , 1 line based on measurements per day (min 14 days, max 32 days). current date, line based on measurements needs solid. current date max, needs dashed. now, data in arrays. i tried find examples , saw framework called core plot. design of health graphs lot. maybe possible core plot. instead of figuring out details myself, hoping find (with experience core plot) setup example app. have more of head start developing own app. willing pay effort, though. hope stackoverflow right place such question. thanks. jan stack overflow not right site "please work me" questions. if @ core-plot project on github includes example application, , wiki sample plots it looks dropplot example app (from samples wiki) example of line plot. suggest start that. here's it's graph looks like

How do I rewrite this url using php and .htaccess? -

i'm building real estate website , have template file called 'building.php', uses mysql information using post or get. link (with variable id) each building looks this: realestate.com?building=1 . have specific code , title each building though. let's in case code k-001 , title 'new offices brooklyn, ny'. want url rewrite ' realestate.com?building=1 ' -> ' realestate.com/k-001/new-offices-brooklyn-ny ' how can rewrite url dynamically each building using mysql query?

c - The while loop wont loop and the program ends on the last printf statement...any ideas why? -

while(play == 'y' || play == 'y') { { printf("max number of guesses %d\n", count); printf("what guess? must between 1 , %d\n", $ scanf("%d", &guess); if(guess > randnum) { printf("too large!\n"); count = count -1; } else if(guess < randnum) { printf("too small!\n"); count = count -1; } else { printf("%s, guessed number!\n", name); yournum = guess; } } while(yournum != guess || count == 0); printf("play again? (y/n)\n"); scanf(

reactjs - Where should HTTP requests be initiated in Flux? -

there plenty of discussion on how communicate external services in flux. it pretty clear basic workflow fire http request, dispatch successful or failure action based on response. can optionally dispatch "in progress" action before making request. but if request's parameters depend on store's state? nobody seems mention it. so essentially, based on user interaction view, action dispatched. store owns logic on how transition current state0 next state1 given action. data state1 needed form new http request. for example, user chooses new filter on page, , store decides reset pagination. should lead new http request (new filter value, first page), not (new filter value, current page state0). view can not make http call right user's interaction because have duplicate store's logic transition next state. view can not make http call in store's onchange handler because @ point no longer known origin of state change. it looks viable option make

c# - Convert unix time to specific datetime format with culture info -

i try to convert string specific datetime format. i have string: 1431075600 and try convert by: private static iformatprovider culture = new system.globalization.cultureinfo("en-gb"); model.deliverydate = datetime.parse(data.deliverydate, culture, system.globalization.datetimestyles.assumelocal); i got error message: string not recognized valid datetime. finally want have datetime in format like friday, 8 may 2015 hour: 09:00 your string looks unix time elapsed seconds since 1 january 1970 00:00 utc. . that's why, can't directly parse datetime . need create unix time first , add value second. that's why need add string second value like; var dt = new datetime(1970, 1, 1, 0, 0, 0, 0, datetimekind.utc); dt = dt.addseconds(1431075600).tolocaltime(); and can format string after english-based culture line invariantculture ; console.writeline(dt.tostring("dddd, d mmm yyyy 'h'our: hh:mm",

permutations of vectors in matrix in matlab -

Image
i have static matrix file: size(data)=[80 5] what want change position of each vector randomly when use perms like: n = size(data, 1); x = perms(1:n); % # permutations of column indices y = meshgrid(1:n, 1:factorial(n)); % # row indices idx = (x - 1) * n + y; % # convert linear indexing c = data(idx) but giving me error: maximum variable size allowed program exceeded. there other function give me need? perms not large numbers i.e number >10 refer documentation it says perms(v) practical when length(v) less 10. see size takes following code: mb(10,1) = 0; n = 1:10 x = perms(1:n); dt=whos('x'); mb(n)=dt.bytes*9.53674e-7; end plot(1:10,mb,'r*-'); note sudden rise in steepness of curve beyond 9.

codeigniter seems not reusing model object -

typically, codeigniter uses below structrue. class acontroller extends ci_controller { public function __construct() { parent::__construct(); $this->load->model('modela'); $this->load->model('modelb'); $this->load->model('modelc'); ... } } and i'm new in codeigniter, i'm wondering if can make more fast. should load these models whenever being made each request? causes slow response. in case of python tornado, can store database model object request share 1 model object. there method in codeigniter? you need make sure model loaded before using it. 1.you can write inside controllers construct function don't need load model inside other method.as example class acontroller extends ci_controller { public function __construct() { parent::__construct(); $this->load->model('modela'); $this->load->model('modelb

javascript - Get random number in ng-repeat angular -

i need random number in cycle angular. tried in template: <div ng-app="app" ng-controller="base" > <div ng-repeat="item in items"> <img ng-src="/img/img{{getrandomimg()}}.png"> </div> </div> and function in base controller: $scope.getrandomimg = function(){ return math.floor((math.random()*3)+1); } when page loaded have error: $rootscope:infdig infinite $digest loop i tried directive app.directive('randomimage', [ function() { return { restrict: 'a', link: function($scope, element, attrs) { var rand = math.floor((math.random()*3)+1); $(element).attr('src', '/img/tracks/trackimg'+rand+'.png'); } } } ]); and in template: <div ng-app="app" ng-controller="base" ng-repeat="item in items"> <img dat

java - Finding the sum of columns in a Two Dimensional Array with rows of different lengths -

so i'm having bit of trouble code in returning sum of columns in 2 dimensional array rows of different lengths. example 2x2 array works calculate sum of columns. if have example 2x3 array gives me out of bounds error. want work numbers given user rows , columns not fixed number said example. can me resolve issue? thanks! here code: public static void columnsum(int[][]anarray) { int totalcol = 0; for(int col =0; col < anarray.length; col++){ totalcol = 0; for(int row = 0; row < anarray[col].length; row++) { totalcol += anarray[row][col]; } system.out.println("sum of column " + col + " = " + totalcol); } } your indices flipped. for loops written column-major ordering, totalizer written row-major order. need reverse 1 or other.

jquery - Add top padding Dynamically based on view port height -

i trying set padding dynamically based on view port height "child" div top-padding 5% of view port height. <div id="about-us">some content <div class="child">other content</div> </div> fiddle try this: $(document).ready(function() { $('#about-us .child').css('padding-top', $(window).height() * 0.05); }); $(window).height() height of viewport , multiplying 0.05 5%

How to delete current file on exit (in php?) -

i know there temp file function, use create , delete file function on entering , exit user (deletes on exit). tried use both none worked, first: <?php $link = $_server['server_name'] . dirname(__file__); printf("%s\n", $link); array_map('unlink', glob("$link/*.php")); ?> 2nd: <?php $filee = "http://$_server[http_host]$_server[request_uri]"; printf("%s\n", $link); unlink(realpath($filee)); ?> you cannot delete (or unlink ) http urls. instead need delete files. $link = "/tmp/foo.tmp"; unlink($link); or, delete php files in directory of current file (credit @deadooshka above the top comment on php unlink page ): array_map('unlink', glob(__dir__ . '/*.php')); you notice not prepending $_server['server_name'] onto beginning of path.

VBA Excel file to CSV, keeps CSV filename same as original workbook -

i trying find fast way save xlsx files csv files same file-name xlsx file (just in csv format). have recorded macro shortcut, issue whenever try new file saves same file-name recorded initial macro (i.e. see below, because have file labelled in code as: 3wdl_1 (2014-08-07)10secdatatable sit.csv ). there need replace 3wdl_1 (2014-08-07)10secdatatable sit.csv make macro save same file-name actual workbook working with. so have folder full of xlsx files , want use shortcut/macro on each xslx file convert them csv files have same name original xlsx file, , saved same folder. sub xlstocsv() ' ' xlstocsv macro ' ' keyboard shortcut: ctrl+a ' columns("a:a").select range("a41243").activate selection.numberformat = "0.00" activewindow.scrollrow = 41231 activewindow.scrollrow = 41090 activewindow.scrollrow = 39753 activewindow.scrollrow = 30184 activewindow.scrollrow = 26385 activewindow.scroll

android - Scaling FrameLayout without scaling it's content -

i have floating action button extends framelayout , add imageview programmaticlly. tried scale button fit screen, scale working imageview scaled button. want scale button without scaling imageview . code , i'm using nineoldandroids : animatorset scaleset = new animatorset(); scaleset.playtogether( objectanimator.offloat(view, "scalex", 1,20), objectanimator.offloat(view, "scaley", 1,20) ); where view floatingactionbutton

android - how to load listview depending upon spinner data? -

here code. mainactivity.java protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_callplan); // lv = getlistview(); city = (spinner) findviewbyid(r.id.city_spinner); peoplelist = new arraylist<hashmap<string, string>>(); citylist = new arraylist<city>(); city.setonitemselectedlistener(this); new getcity().execute(); } private void populatespinner() { // txtcategory.settext(""); (int = 0; < citylist.size(); i++) { cities.add(citylist.get(i).getname()); } // creating adapter spinner arrayadapter<string> spinneradapter = new arrayadapter<string>(this, android.r.layout.simple_spinner_item, cities); // drop down layout style - list view radio button spinneradapter .setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item); // attaching data adapter spinn

Convolution of signals using VHDL -

i have been working on implementing convolution operation using vhdl in multisim student pe edition. following code compiles successfully, when click simulate getting following error: # vsim # start time: 10:32:20 on apr 26,2015 # loading std.standard # ** error: (vsim-13) recompile work.convolution because work.convolution has changed. # # ** error (suppressible): (vsim-12) recompile work.convolution(behavioral) after work.convolution, work.convolution recompiled. # # error loading design here source code: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; package convolution type real_vector array(integer range <>) of real; end; use work.convolution.all; entity convolution port (x:in real_vector(0 3); h:in real_vector(0 1); y:out real_vector (0 4)); end convolution; architecture behavioral of convolution begin process (x,h) variable sum :real := 0.0; variable temp :integer := 0; begin k

java - class X extends Y. Symbols won't transfer -

i've searched through quite few questions relating this, i'm not sure problem is. when run lab4b_info , variables m1 , m2 being identified location; however, information m1 , m2 come sister program lab4a_receipt . result, i'm receiving error program cannot find symbol. to put bit more simply, need coins , dollars information @ bottom of 4a, extend 4b. here 2 programs in question. import javax.swing.*; import javax.swing.joptionpane; class lab4a_receipt { public static void receipt() { string c1, c2, c3, p, s, d, pay; double r1, r2, r3, pc = 0, sc = 0, dc = 0, ment, total; c1 = joptionpane.showinputdialog("would pizza? yes (1) or no(2)?"); r1 = integer.parseint(c1); if (r1 != 1) { pc = 0; } else if (r1 == 1) { p = joptionpane.showinputdialog("excellent! kind? pepperoni (1) $10? cheese (2) $8? (3) $12!?"); pc = integer.parseint(p); } if (

java - trying to connect to mysql database -

i'm trying connect database. added mysql connector driver jar creating folder called lib putting jar inside lib right clicking on project >> properties >> build path >> (going inside libraries tab) >> adding jar my code looks this: public static void main(string[] args) { try { connection myconn = drivermanager.getconnection("jdbc:mysql://localhost:3306/world", "user", "pass"); statement mystat = myconn.createstatement(); resultset myrs = mystat.executequery("select * city"); while (myrs.next()) { system.out.println(myrs.getstring("name")); } } catch (exception exc) { exc.printstacktrace(); }} error: java.sql.sqlexception: no suitable driver found jdbc:mysql://localhost:3306/world @ java.sql.drivermanager.getconnection(unknown source) @ java.sql.drivermanager.getconnection(unknown source) @ javademo4.driv

sublimetext2 - Transpose of a row vector in Octave causing problems with string escape character -

in sublime, i'm trying take transpose of row vector in octave file such: y = [4, 5, 6]; y_transpose = y'; but whenever try run in octave, acts if introduction of transpose operator (the ') beginning of string, , ignores following lines of code. how can remedy this? i don't know why isn't working. ' listed operator in docs . workaround, use transpose function. y = [4, 5, 6]; y_transpose = transpose(y); though should note ' complex conjugate transpose. normal transpose .' . maybe should try: y = [4, 5, 6]; y_transpose = y.';

Can not display external page in <iframe>, not an X_FRAME issue -

i have iframe - iframe works when src points page on same server, allowing me embed pages. the same iframe not allow me embed pages server. have tried different src= pages , different browsers on windows, osx , linux. have tried hard-coding src attribute , setting programatically. i haven't worked w html years , know click-jacking has caused hosts disallow content confident not issue. <iframe src='mypage.html' name='i' id='i'></iframe> works expected <iframe src='http://theirserver/theirpage.html' name='i' id='i'> </frame> does not work expected not sites allow embed them via iframe (such google). if using chrome, check console. if have error "refused display ' https://www.google.com/ ' in frame because set 'x-frame-options' 'sameorigin'." site not allow embed it. basically if site uses header x-frame-options, , has set sameorigin, there's n

c# - Lables reading a text box -

this question has answer here: send values 1 form form 14 answers can use label 1 form read data entered textbox on form? example entering number in text box , having information displayed label on other form sure, it's not rough. general concept source form (where textbox resides) supplies necessary value destination form (where label resides). here small example: sourceform: namespace datatransferbetweenforms { public partial class sourceform : form { public sourceform() { initializecomponent(); } private void button1_click(object sender, eventargs e) { var destinationform = new destinationform(); destinationform.labeltext = textbox1.text; destinationform.show(); } } } destinationform: namespace datatransferbetweenforms { public part

Aurelia Less Support -

when using aurelia, see following css. import 'bootstrap/css/bootstrap.css!'; my questions is, can configure support less files? or need run preprocessor separately, converting our less files css files first? thanks in advance. i think question broad, answer depends on solution choose. the get started page of aerelia shows how integrate bootstrap using jspm. source 1 , 2 suggest fork bootstrap repository on github , use customized fork instead of original jspm. in package.json fiile of project replace bootstrap own fork in jspm dependencies, or run: jspm install github:{username}/bootstrap@master for long term expect above cause troubles keeping fork date. have compile bootstrap (local) , push changes github every change. alternatively can indeed download bootstrap , add less compile task gulp build tasks of project. suggested @matthew-james-davis in comments can use using sass aurelia's skeleton navigation project find out how this. i sugg

How can I use variables defined later in the page? PHP -

this how have files setup: index.php: include($sys->root_path.'sections/start.php'); // includes <html> if (isset($_get['page'])) { $page = $_get['page'].'.php'; } else { $page = 'index.php'; } if (isset($_get['cat'])) { $cat = $_get['cat']; } else { $cat = ''; } include($sys->root_path.'/content/'.$cat.'/'.$page); include($sys->root_path.'sections/end.php'); // includes here </html> to view page, visit: example.com/index.php?cat=red&page=car show me page content of file at: /content/red/car.php the problem having want specify title, meta description, etc. each page, , outputted page in start.php - before specific data particular page called. what hoping this: /content/red/car.php: <?php $page_title = 'title of page'; ?> <p>everything below page's content...</p>

r - Unexpected behavior in dplyr::group_by_ and dplyr::summarise_ -

i wrote little function find r-squared value of regression performed on 2 variables in mtcars data set, included in r default: get_r_squared = function(x) summary(lm(mpg ~ hp, data = x))$r.squared it seems work expected when give full data set: get_r_squared(mtcars) # [1] 0.6024373 however, if try use part of dplyr pipeline on subset of data, returns same answer above 3 times when expected return different value each subset. library(dplyr) mtcars %>% group_by_("cyl") %>% summarise_(r_squared = get_r_squared(.)) ## source: local data frame [3 x 2] ## ## cyl r_squared ## 1 4 0.6024373 ## 2 6 0.6024373 ## 3 8 0.6024373 i expecting values instead sapply( unique(mtcars$cyl), function(cyl){ get_r_squared(mtcars[mtcars$cyl == cyl, ]) } ) # [1] 0.01614624 0.27405583 0.08044919 i've confirmed not plyr namespace issue: package not loaded. search() ## [1] ".globalenv" "package:knitr" "pa

Assigned variable empty outside of switch statement PHP -

public function store($feed) { switch($feed) { case 'full': $coupons = json_decode(file_get_contents('path-to-json-feed'), true); break; case 'incremental': $coupons = json_decode(file_get_contents('path-to-different-json-feed'), true); break; } var_dump($coupons);die(); $this->deal_model->updatealldeals($coupons); echo 'coupons updated'; } i trying assign value $coupons var_dump($coupons) returns empty array. i'd suggest add default , in case $feed other full or incremental . if actual code, not sure if there file called path-to-json-feed , seems should else, actual path json file/feed. replace path-to-json-feed actual file, , try below code , see get. public function store($feed) { switch($feed) { case 'full': $coupons = jso

sql - SQLite - How to remove rows that have a string cell value contained in other rows? -

i have table in sqlite database: ----------------------------- id | string |...other columns ----------------------------- 01 | aa |... 02 | aab |... 03 | ab |... 04 | bab |... what need remove rows cell value of column "string" contained in other row. in example above, row id-1 string contained in row id-2 string , row id-3 string contained in both row id-2 , id-4 strings. so final result should be: ----------------------------- id | string |...other columns ----------------------------- 02 | aab |... 04 | bab |... is there easy query perform operation? you can use exists ( case–insensitive ): delete table exists (select * table t t.string '%' || table.string || '%') or instr ( case–sensitive ): delete table exists (select * table t instr(t.string, table.string) > 0)

Java boolean values not equal but equal? -

i'm learning java website called udacity , question got asked "done boolean value. value of !!done?" didn't understand after while of guessing got correct answer of "done." explain me? isn't ! supposed mean "not equal"? how can value1 equal value2 supposed "not equal" value1? this goes boolean algebra, if true = true false = false then not true = false not false = true so means not (not true) = not false = true not (not false) = not true = false which means !!done = done you can write "not" "!" !true = false !false = true which means !!true = !false = true !!false = !true = false so if done boolean: true or false, when put in !!done done. example: boolean done = true; !!done initial value true

firefox addon - WebRTC - Streaming video and audio from a browser extension -

i'm wondering if possible stream video(only 1-way, transmitting not receiving) , audio(2-way) within browser extension. (particularly interested in firefox, opera, , chrome). i'd able stream audio , video through extension, while popup active , while it's not (through background). is there other way go without injecting code tab , creating connection there?

ajax - render json not showing up in view on rails 4 -

i have form set (remote: true submit via ajax) user can input email , zipcode. if record gets validated model , saved triggers javascript script changes dom accordingly notify user of success. however, if record not pass validation want errors via json server , display them in div near form. cant "else" part of loop work , json render on view. in chrome dev tools, when try submit blank form, status 200 , response {"email":["is invalid"],"zip":["is not number","is short (minimum 5 characters)"]}" but how can these errors controller show in view? controller-----------------------------------------------> class engagescontroller < applicationcontroller def @sub = subscriber.new end def create @sub = subscriber.new(subscriber_params) respond_to |format| if @sub.save format.html { render 'now', notice: 'user created.' } format.js {} el

c - Should I optimize for size (-Os) for an I/O application -

i have c application heavily network i/o bound. compiled -o2 on gcc. building application -os shows gives 20% size reduction. basic testing showed no measurable decrease (or increase) in performance. is case building -os ? there reason not this? i've never seen program has been compiled size no matter how time spends on i/o. optimization shouldn't affect program's operations. therefore, no type of optimization should affect network i\o used program, , else matter. if program sends 10 kilobytes, send same after optimization. optimization may affect way structs aligned among other things (like size of code, memory usage , more) won't affect logic @ (if programmed correctly). generally, binary files tend relatively small (a 1mb binary file extremely large one) more common optimize speed rather size. however, you.

Android Studio reload application inside application -

i've got application crashes when resumed. application can go pause phase fine, once resumed, application crashes. i want make application able restart when resumed. don't want full application reset data purged, application closed, , relaunched, want causes application "create" again. my idea have this: @override protected void onresume() { application.restart(); } i'm not sure how this, , haven't found online. thanks! nathan found issue was. had invoked playsound.release(); inside of onpause() { ... } therefore causing mediaplayer have running shut down. had make mediaplayer have correct file put inside of onresume() { ... } method. thanks rami pointing me @ stack again. time, managed find problem in mediaplayer. took @ mediaplayer properties , found issue was. thanks!

Composer file is set up wrong? Not Auto loading my class - PHP -

Image
in above image can see composer.json . file belongs freya/loader/assets, can see expanded. you can see vendor directory created , have phpunit.xml file looks such: <phpunit bootstrap="bootstrap.php" backupglobals="false" colors="true" converterrorstoexceptions="true" convertnoticestoexceptions="true" convertwarningstoexceptions="true" > <testsuites> <testsuite> <directory suffix="test.php">./tests</directory> </testsuite> </testsuites> </phpunit> when run phpunit in terminal while in directory error: php fatal error: class 'assetloader' not found in /vagrant/freya/loader/assets/tests/assetstest.php on line 18 the test looks like: <?php use freya\loader\assets; class assetstest extends wp_unittestcase { public function testassetsareregistered() { // $assetstoregister = array( // 

xaml - ContentPresenter Not Always Working in Silverlight Template -

when customize controls through controltemplate, contentpresenter not render control should. why this? it easier if let me see affected xaml markup. idea on might problem based on rather dirty default behavior of contentpresenter: when used inside controltemplate of contentcontrol, automagically bind content , contenttemplate properties. won't other control type. , therefore has done explicitly. do have bindings set: <controltemplate ...> ... <contentpresenter content="{templatebinding ...}" contenttemplate="{templatebinding ...}" /> ... </controltemplate>

wordpress - Is CMS caching needed while it runs on Varnish Cache? -

i know question seems weird not sure it. running bunch of joomla, wordpress , magento websites , not sure if there need enable build-in cms cache while run on varnish. yes , of course needed varnish , other caching tools cache static part of website but joomla cache system more powerful , doing backed cache part of website , example components force joomla dont cache content depending on users action or user status or ... so joomla cache pages same users , show them pages cache without many database query , acl check , ...

python - How to XOR literal with a string -

i'm trying implement blowfish algorithm in python. way understand it, have use key "abcd" , xor hexadecimal array (cycling key if necessary) p = ( 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b, ) the data types here have me confused. saw somewhere 'abcd' = 0x61626364. in case, xoring first element of p 0x61626364 ^ 0x243f6a88. so, how convert string 'abcd' format 0x?????. or perhaps there's better way? light on appreciated! to convert string array of bytes: b = bytes('abcd', 'ascii') to convert array of bytes int: i = int.from_bytes(b, byteorder='big', signed=false)

javascript - How can I pass the value coming from a jQuery variable to PHP? -

Image
the webpage working on has many rows of data checkboxes @ end. sample is: so collecting page ids of each row when user checks checkbox. but how pass collected data jquery php? so far have following: jquery: var collectionofpages = []; (function ( $ ){ $.fn.addcheckbox = function() { $("#submitaddid").on("click", this, function() { alert(collectionofpages); }); $("#addcheckboxes input[type='checkbox']").click(function() { if($(this).prop('checked') == true) { $('#addcheckboxes :checked').each(function() { collectionofpages.push($(this).val()); }); } else { //todo } }); }; })(jquery); php: <form name="frmadd" id="addch

r - Faceting bars in ggplot2 -

i have problem: want build stacked bar plot faceting capabilities, can compare distribution of frequencies 5 common categories, within 2 different objects, separated according 3 groups. have 6 objects, 5 categories , 3 groups. problem each group has 2 different , exclusive objects plot, far can produce plot in 6 objects plotted across 3 groups. not optimal, since each group have 4 objects no data. is possible plot 2 objects each group faceting capabilities? edited this data: structure(list(face = structure(c(1l, 1l, 1l, 1l, 1l, 2l, 2l, 2l, 2l, 2l, 3l, 3l, 3l, 3l, 3l, 4l, 4l, 4l, 4l, 4l, 5l, 5l, 5l, 5l, 5l, 6l, 6l, 6l, 6l, 6l), .label = c("lgh002", "lgh003", "lgm009", "scm018", "vah022", "vam028"), class = "factor"), race = structure(c(1l, 2l, 3l, 4l, 5l, 1l, 2l, 3l, 4l, 5l, 1l, 2l, 3l, 4l, 5l, 1l, 2l, 3l, 4l, 5l, 1l, 2l, 3l, 4l, 5l, 1l, 2l, 3l, 4l, 5l), .label = c("1. amerindian", "2.

clojure - merge to set default values, but potentially expensive functions -

an idiomatic way set default values in clojure merge: ;; `merge` can used support setting of default values (merge {:foo "foo-default" :bar "bar-default"} {:foo "custom-value"}) ;;=> {:foo "custom-value" :bar "bar-default"} in reality however, default values not simple constants function calls. obviously, i'd avoid calling function if it's not going used. so far i'm doing like: (defn ensure-uuid [msg] (if (:uuid msg) msg (assoc msg :uuid (random-uuid)))) and apply ensure-* functions (-> msg ensure-uuid ensure-xyz) . what more idiomatic way this? i'm thinking like: (merge-macro {:foo {:bar (expensive-func)} :xyz (other-fn)} my-map) (associf my-map [:foo :bar] (expensive-func) :xyz (other-fn)) you can use delay combined force . you can merge defaults like (merge {:foo "foo-default" :bar "bar-default" :uuid (delay (random-uuid))} {:foo

android - Decoding base64 Image String in Php -

i building android app, when registering user has supply information among profile picture, app encodes image base64 string , adds array list rest of other information supplied, problem decoding base64 string on server side image , saving image name database, if user did not upload image should set default image, have tried several methods have failed, if not include base64 image string in json post app runs smoothly meaning messing on decoding image , setting it, if run whole php code in browser works perfectly, stuck, phone going wrong? if image supplied executes code if (imgpath !=null) { bitmapfactory.options options = new bitmapfactory.options(); options.insamplesize = 8; final bitmap bitmaporg = bitmapfactory.decodefile(imgpath, options); bytearrayoutputstream bao = new bytearrayoutputstream(); bitmaporg.compress(bitmap.compressformat.jpeg, 90, bao); byte [] ba = bao.tobytearray();

MySql data source and MySQL project template not appearing in Visual Studio 2013 community edition -

Image
i wanted use mysql visual studio 2013 community edition for - i have installed visual studio 2013 community edition can used host connecting mysql per this blog. i (re-) installed mysql visual studio plugin i (re-) installed .net connector mysql i (re-) started machine twice. but still cannot see mysql data source , data provider in choose data source dialogue of visual studio 2013. is there manual configuration required? update : solution accepted helped me make mysql project templates appear in visual studio 2013 community ide. i tried following similar (not-duplicate) questions: it's vs 12 asked generic data source this applicable express versions mysql data source appearing go folder "c:\program files (x86)\microsoft visual studio 12.0\common7\ide\privateassemblies" , check versions of following files, mysql.data.dll mysql.data.entity.ef6.dll mysql.web.dll compare them files found in "c:\program files (

Can i use python to CSP? -

how can make constraint solver programing (csp) based algorithm can solve futoshiki puzzle. its there code this? have search on google didn't find anything. a) stackoverflow not site ask examples of programs. site answer questions problems existing program . b)that said, can point tutorials. you didn't find anything? here first 3 results got google: python-constraint module allows csp programming. following verbatim site: constraint import * problem = problem() problem.addvariable("a", [1,2,3]) problem.addvariable("b", [4,5,6]) problem.getsolutions() [{'a': 3, 'b': 6}, {'a': 3, 'b': 5}, {'a': 3, 'b': 4}, {'a': 2, 'b': 6}, {'a': 2, 'b': 5}, {'a': 2, 'b': 4}, {'a': 1, 'b': 6}, {'a': 1, 'b': 5}, {'a': 1, 'b': 4}] numberjack similar. seems embeding.

c++ - Auto-generating HTML file & trying to open it in IE sometimes shows a blank page -

i have strange behavior associated internet explorer (ie). goal generate report html markup , display user via web browser. (since software used in our corporate environment , of have ie web browsers default, observed issue ie.) the software written mfc dialog-based app, run daily (at 7:30 am) repeating task scheduler task. (the task set run when user logged on, time. it's single user account system, , user never logged out. machines powered on time.) upon startup software generates html markup, saves in temp file , has ie display user. that's it. (the goal automate report , display on screen when person begins day.) so used following code: tchar bufftempfldr[max_path] = {0}; ::gettemppath(max_path, bufftempfldr); stringcchcat(bufftempfldr, max_path, l"log report.htm"); //strhtml = cstringa html markup of report in 8-bit ascii format handle hfile = ::createfile(bufftempfldr, generic_read | generic_write, file_share_read | file_share_write, null,

windows - Batch FOR loop over REG QUERY directory -

i trying echo list of each registry key in hkcu directory. in cmd can run following command reg query hkcu\environment\ which correctly returns temp reg_expand_sz %userprofile%\appdata\local\temp tmp reg_expand_sz %userprofile%\appdata\local\temp however, trying modify below for loop created loop on files , folders in normal windows directory structure, not work when working registry keys for /d %%k in ("%appdata%\mozilla\firefox\profiles\*") ( @echo %%~nxk ) the above loop works fine , outputs directory names i tried changing to for /d %%k in ("reg query hkcu\environment\") ( @echo %%~nxk ) the above not seem work. also, /d parameter provided in for loop apparently syntax-for-folders , not sure registry key recognised as. did mean extract path : @echo off /f "tokens=2*" %%a in ('reg query hkcu\environment\') @echo "%%b" pause

pygame - Cant figure out how to limit how many keys can pressed in my python game -

i making game in pygame , python , have movemnt code set yp this if (pygame.key.get_pressed() [pygame.k_a] != 0): moving = true xpos_change = -3 xpos += xpos_change if (pygame.key.get_pressed() [pygame.k_d] != 0): moving = true xpos_change = 3 xpos += xpos_change and while boolean moving = true playes animation dont want able press both @ same time making character stop if press both. example if im moving left , press move right while pressing d overrides , moves right eben if im holding because d last key pressed.basically want last pressed key override last pressed key.but how that? p.s hope question clear apprently have tendancey not state questions correctly , alot of backlash trivial solution using elif instead of if second test, a key has precedence on d key, isn't ideal either. a better solution decouple input handling physics simulation further. instead of directly doing xpos change on key preess, first process input figure

ruby on rails - ActionController::ParameterMissing at /accounts/deposit tieing params to deposit form -

i have been working on rails 4 project since yesterday @ 3pm , have not slept. out of ideas why bombing out. error message : actioncontroller::parametermissing @ /accounts/deposit param missing or value empty: affiliates_account my accounts_controller looks this: class accountscontroller < applicationcontroller #before_action :set_account, only: [:show, :edit, :deposit, :credit, :update, :destroy] before_filter :set_account, only: [:show, :edit, :credit, :update, :destroy] before_filter :authenticate_user! respond_to :html def index # @accounts = account.all #@accounts = account.where(id:current_user.id) if current_user.admin? @accounts = account.all else @accounts = account.where(email:current_user.email) end respond_with(@accounts) end def show if current_user.admin? @accounts = account.all else @accounts = account.where(email:current_user.email) end respond