Posts

Showing posts from February, 2015

ios - How can I animate the height of a CALayer with the origin coming from the bottom instead of the top? -

i want animate simple calayer move , down in response incoming data (bars on graphic equaliser) the calayer should remain fixed along bottom , move , down height animated. can advise on best way achieve without having animate origin y coord height? if want layer grow , shrink bottom, should set own anchorpoint on layer bottom. anchor point specified in layers unit coordinate space both x , y range 0 1 inside of bounds, no matter size. yourlayer.anchorpoint = cgpointmake(0.5, 1.0); then animation, animate bounds (or better, can animate "bounds.size.height" , since height changing): // set new bounds of yourlayer here... cabasicanimation *grow = [cabasicanimation animationwithkeypath:@"bounds.size.height"]; grow.fromvalue = @0; // no height grow.tovalue = @200; // height of 200 grow.duration = 0.5; // add additional animation configuration here... [yourlayer addanimation:grow forkey:@"grow height of layer"]; you can read m

Copy constructor in polymorphism in C# -

please first take @ simple code; this base class: public class baseclass { public baseclass() { } public baseclass(baseclass b) { } public virtual string getmsg() { return "base"; } } and derived one: public class drivenclass : baseclass { public string msg { get; set; } public drivenclass(string msg) { msg = msg; } public drivenclass(drivenclass d) { msg = d.msg; } public override string getmsg() { return msg; } } and test: public partial class form1 : form { public form1() { initializecomponent(); } public baseclass b { get; set; } public drivenclass d { get; set; } private void button1_click(object sender, eventargs e) { d = new drivenclass("driven"); b = new baseclass(d); messagebox.show("b:" + b.getmsg() + "\nd:" + d.getmsg()); } } now question sh

html - Bootstrap form formatting not applying -

i trying add form subscription emails instance variable @premail in embedded ruby for reason form not have bootstrap styling when load on localhost. i've tried several things can't form bootstrap input form. here code form: <div class="container-form"> <%= form_for @premail, html: {class: "form-horizontal home-form", role: "form"} |f| %> <% if @premail.errors.any? %> <h2><%= pluralize(@premail.errors.count, "error") %> prohibited link being saved:</h2> <ul> <% @premail.errors.full_messages.each |msg| %> <li><%= msg %></li> <% end %> </ul> <% end %> <div class="form-group"> <p> stay updated our launch! </p> &

c# - asp.net edit text and save it to database -

so got text in div box on page. want make editable , save changes button click. i know how make text in div box editable how save changes database? , put it? $("#bearbeiten").click(function() { $("#beschreibung").attr("contenteditable", "true");)} to data use ajax , tried data , post database either did wrong or not right way post data. var versionid = $(this).data("versionid"); $.ajax({ datatype: "json", url: "api/beschreibung/gettext?xversionid=" + versionid, type: "get" hope can me. summarized: how data , how change it? you should: create form ; post data webserver (you can use jquery that, suggest simple form submit button; handle post data on server. seems using mvc. there tutorials all on internet ; get posted data , send database. can use entity framework that, or ado.net.

java - What is difference between Collection.stream().forEach() and Collection.forEach()? -

i understand .stream() , can use chain operations .filter() or use parallel stream. difference between them if need execute small operations (for example, printing elements of list)? collection.stream().foreach(system.out::println); collection.foreach(system.out::println); for simple cases such 1 illustrated, same. however, there number of subtle differences might significant. one issue ordering. stream.foreach , order undefined . it's unlikely occur sequential streams, still, it's within specification stream.foreach execute in arbitrary order. occur in parallel streams. contrast, iterable.foreach executed in iteration order of iterable , if 1 specified. another issue side effects. action specified in stream.foreach required non-interfering . (see java.util.stream package doc .) iterable.foreach potentially has fewer restrictions. collections in java.util , iterable.foreach use collection's iterator , of designed fail-fast , throw concurrentmodific

php - how to add posts with image programmatically in wordpress -

this code add post programmatically in wordpress require(dirname(__file__) . '/wp-load.php'); global $user_id; $new_post = array( 'post_title' => 'table tennis', 'post_content' => 'table tennis or ping-pong sport in 2 or 4 players hit lightweight ball , forth using table tennis racket. game takes place on hard table divided net. except initial serve, players must allow ball played toward them 1 bounce on side of table , must return bounces on opposite side. points scored when player fails return ball within rules.', 'post_status' => 'publish', 'post_date' => date('y-m-d h:i:s'), 'post_author' => $user_id, 'post_type' => 'post', 'post_category' => array(2), ); $post_id = wp_insert_post($new_post); how add image post? i new wordpress,thanks in advance.. this upload file using wordpress , insert on post featured imag

java - @Transactional in the controller -

first of want mention agree make service layer transactional, world not perfect, , right i´m in middle of situation. have been assigned wonderful project legacy code of 4+ years. thing developers did not follow pattern introduce bussines logic can image multiples services call controller , after call private method controller. no budget refactor, , have many issues acid solution found make controllers transactional , @ least have full rollback if in middle of request/response go wrong. problem cannot make works. describe configuration see if can me out guys. have dispatcherservlet invoke webmvc-config.xml have declaration of controllers <context:component-scan base-package="com.greenvalley.etendering.web.controller**" use-default-filters="false"> <context:include-filter expression="org.springframework.stereotype.controller" type="annotation"/> </context:component-scan> then contextconfiguration invoke

json - Selecting specific class type from a hierarchy during jackson serialization -

if have class hierarchy -> b, base class, how can specify during jackson serialization include fields base class , exclude subclass? serializing b (the subclass) though. appreciate help!! you can use jackson json views mentioned in this similar question . also can write an annotation introspector or jackson json filter exclude subclass. i've written example demonstrating how exclude properties type in hierarchy has special annotation. public class jacksonexcludefromsubclass { @retention(retentionpolicy.runtime) public static @interface ignoretypeproperties {}; public static class superthing { public final string superfield; public superthing(string superfield) { this.superfield = superfield; } } @jsonfilter("filter") @ignoretypeproperties public static class thing extends superthing { public final string thingfield; public thing(string superfield, string thingfi

c++ - Advanced loading of obj-files -

i can't seem find tutorial on how advanced obj-loading (aka. wavefront) want load model assigned textures , not, , tutorials i've found don't explain @ (just show window working) or basic, vertices, normals , indices. so, first of all, suggestions tutorials? here code, there need make work different textures? data struct: struct objectdata { vector <glm::vec3> vertices, normals, colors; vector <glm::vec2> texcoords; vector <gluint> vindices, uindices, nindices; }; object loader h: class objectloader { private: struct material { string name; glm::vec3 color; }; vector <material*> materials; material *currentmaterial; objectdata *object; bool hasuv, hasnormals, isquads, indexchecked; string parsestring(string src, string code); glm::vec2 parsevec2(string src, string code); glm::vec3 parsevec3(string src, string code); void addindices(string str); void checkindices

java - calculate the modulus of a fraction with big numbers -

i have 2 big numbers (<10^9) n , m . have calculate [(n-1+m)!]/[(n-1)!*m!] if answer big have modulus (10^9+7) . (ex : n%mod if n large mod). int mod = 1000000000+7; i calculated below. (i calculated upper half , bottom half separately) long up=1; (long = a+b-1; i>=math.max(a, b); i--) { up*=i%mod; } up=up%mod; long down=1; (long = math.min(a, b); i>0; i--) { down*=i%mod; } then print answer system.out.println((up%mod/down%mod)%mod); is approach correct. gives correct out put. i know (a*b*c)%d == [(a%d)*(b%d)*(c%d)]%d (correct me if i'm wrong) so there way calculate [a/b]%d ? (a/b) % c != ((a%c) / (b%c) % c) instead use recursive formula of binomial coefficient calculate modulus (n, k) = (n - 1, k - 1) + (n - 1, k) in case be (n - 1 + m, m) % mod = ((n - 2 + m, m - 1) % mod + (n - 2 + m, m) % mod) % mod use above recursion result.

python - "if", and "elif" chain versus a plain "if" chain -

i wondering, why using elif necessary when this? if true: ... if false: ... ... you'd use elif when want ensure one branch picked: foo = 'bar' spam = 'eggs' if foo == 'bar': # elif spam == 'eggs': # won't this. compare with: foo = 'bar' spam = 'eggs' if foo == 'bar': # if spam == 'eggs': # *and* this. with if statements, options not exclusive. this applies when if branch changes program state such elif test might true too: foo = 'bar' if foo == 'bar': # foo = 'spam' elif foo == 'spam': # skipped, if foo == 'spam' true foo = 'ham' here foo set 'spam' . foo = 'bar' if foo == 'bar': # foo = 'spam' if foo == 'spam': # executed when foo == 'bar' well, # previous if statement changed 'spam'. foo = 'ham' now

How do you use the Confirm Email functionality in ASP.NET Identity 2.0 -

identity 2.0 boasts new functionality in area, there's no documentation. install microsoft.aspnet.identity.samples package on empty project , can find code implements functionality. sample application written in mvc

Using pointers to get value from multidimensional array - C -

i trying value "second row" in multidimensional array. have problems that. thought numbers stored sequentialy in memory tab[2][2] stored same tab[4] . seems wrong. this tried: int b[2][2] = {{111,222},{333,444}}; int = 0; for(;i < 100; i++) printf("%d \n", **(b+i)); the problem 111 , 333 result. there no 222 or 444 in other 98 results. why? the problem **(b+i) doesn't think does. evaluates to: b[i][0] as matt mcnabb noted , **(b+i) is equivalent to: *(*(b+i)+0) and since *(b+i) equivalent b[i] , expression whole can seen as: *(b[i]+0) and hence: b[i][0] since array has 2 rows, values of i 0 , 1 in bounds of array (that's 111 , 333). rest wildly out of bounds. what is: #include <stdio.h> int main(void) { int b[2][2] = { { 111, 222 }, { 333, 444 } }; int *base = &b[0][0]; (int = 0; < 4; i++) printf("%d: %d\n", i, base[i]); return 0; } output: 0: 11

bash - Adding XML element in XML file using sed command in shell script -

i using sed command insert xml element existing xml file. i have xml file <students> <student> <name>john</> <id>123</id> </student> <student> <name>mike</name> <id>234</id> </student> </students> i want add new elememt <student> <name>newname</name> <id>newid</id> </student> so new xml file be <students> <student> <name>john</> <id>123</id> </student> <student> <name>mike</name> <id>234</id> </student> <student> <name>newname</name> <id>newid</id> </student> </students> for have written shell script #! /bin/bash content="<student> <name>newname</name>

jquery - onBeforeUnload custom button messages -

i have following beforeunload function have stolen sonewhere else.... $().ready(function() { $("#posmanagerloginform").trigger("submit"); $(window).bind("beforeunload", function(){ window.settimeout(function () { window.location = "home.htm"; }, 0); window.onbeforeunload = null; // necessary prevent infinite loop kills browser return "press 'stay on page' go reporting manager home"; }); }); regardless of option select navigated home.htm. there way can make dialog box ok button instead of default "leave page" or "stay on page" options? or perhaps else make suggestion on hot better handle? thanks you cannot override styling of onbeforeunload dialog. believe me, tried before in earlier projects. reference: http://msdn.microsoft.com/en-us/library/ms536907%28vs.85%29.aspx it built browser object, , have no control on it. yo

Android: Start the circular progress bar from top (270°) -

Image
i have defined circular progress bar using following drawable " ciruclar_progress_bar.xml " <?xml version="1.0" encoding="utf-8"?> <item android:id="@android:id/progress"> <shape android:innerradiusratio="2.5" android:shape="ring" android:thicknessratio="25.0" > <gradient android:centercolor="@color/gray" android:endcolor="@color/gray" android:startcolor="@color/gray" android:type="sweep" /> </shape> </item> <item android:id="@android:id/secondaryprogress"> <shape android:innerradiusratio="2.5" android:shape="ring" android:thicknessratio="25.0" > <gradient android:centercolor="@color/green" android:endcolor="@color/gre

stellar.js - stellar js initialise with jquery only -

stellar js requires following data attribute element like: <div data-stellar-ratio="2"></div> however cannot use inline html on particular site i'd need use jquery. i tried add data attribute jquery not seem work. have idea why? $(window).stellar(); $('.gallery.home .image:nth-child(2)').data('stellar-ratio', '2'); you need order stellar() method : $('.gallery.home .image:nth-child(2)').data('stellar-ratio', '2'); $(window).stellar(); //after data-attribute set...

php - codeigniter and piwik with benedmunds authentication -

i have codeigniter application built using benedmunds authentication model. i'm setting piwik hoping create link in admin panel opens piwik. i'm not worried piwik getting login details codeigniter db. i'm happy add identical users piwik, when user logs codeigniter, needs automatically logged piwik. don't want user have login twice. any suggestions? thanks you can @ piwik source , see how authenticates. can replicate logic create needed session data. that can put ion auth hook called after successful login.

python - clang: error: unknown argument: '-mno-fused-madd' -

when installing reportlab 3.1.8, ran problem kept getting error , not find compiler option being set. the point in setup was: building 'reportlab.lib._rl_accel' extension clang: error: unknown argument: '-mno-fused-madd' [-wunused-command-line-argument-hard-error-in-future] clang: note: hard error (cannot downgraded warning) in future error: command 'cc' failed exit status 1 here solution. cause: keep mac date , result seems have newer (different) version of c compiler (clang) 1 allowed "-mno-fused-madd" command line switch. solution: did not find above switch in file in reportlab source. had on computer itself. culprit seemed in distutils, because setup.py uses module distutils. the problem in file /system/library/frameworks/python.framework/versions/2.7/lib/python2.7/_sysconfigdata.py . file contains definitions dictionary named build_time_vars. in right place have build time problem. first make copy safeguard. sudo <

xpages name picker in XPiNC -

<xe:namepicker id="namepicker1" for="djtextarea5"> <xe:this.dataprovider> <xe:dominonabnamepicker groups="false" namelist="peoplebylastname" addressbookdb="names.nsf"> </xe:dominonabnamepicker> </xe:this.dataprovider> </xe:namepicker> it works on browser without addressbookdb="names.nsf" , in client notes doesn't, when click name picker: list empty. i appreciate time! i saw can have extlib name picker running in xpinc lookup directory on server? explanation : adressbookdb="server!!names.nsf" doesn't works in client notes. you need addressbookdb="server!!names.nsf" addressbooksel="db-name". the hover on addressbookdb clarifies works if addressbooksel db-name

php - Best way to sort a big array by a key -

Image
i have big array lots of datas, here can have example : is example have 1 item [0] . i need sort array key date in last_message . (more in first) in date have format : "2014-04-23t14:59:53+0200" do have idea me ? don't want foreach think there better. thanks ! this code : uasort($arrayc, function ($a, $b) { if ($a == $b) { return 0; } return (strtotime($a['last_message']->date) < strtotime($b['last_message']->date)) ? -1 : 1; }); but there no effect on array.. you can use http://www.php.net/manual/en/function.uasort.php , provide custom function compares date. this this: function cmp($a, $b) { if ($a == $b) { return 0; } return (strtotime($a['last_message']['date']) < strtotime($b['last_message']['date'])) ? -1 : 1; } uasort($array, 'cmp');

sql - Query to Access Sharded Tables -

i querying vendors database has data sharded between multiple tables. tables named events_1 , events_2 , events_3 , events_4 etc. it appears new table automatically created when table hits 10,000 records. looking write query able union results tables (without having manually add tables created) query @ 2 newest tables. any suggestions on best way go this? the database microsoft sql server 2008 you can dynamic sql such query sysobjects table name events_* , build select union results. better, though perhaps more complicated, ddl trigger dynamically update union view append new table whenever table events_* created.

How to calculate byte size of file if I declared it indirectly(BufferedReader with pathname?) (Java 6) -

hypothetically have line bufferedreader instream = new bufferedreader(new filereader("src.txt")); at opening , closure of file how calculate size (for example length() ) instream.legth() ? @ system.out.println() ? use length method of file class: file f = new file(filename); system.out.println(f.length()) please note can use f in bufferreader object : bufferedreader br = new bufferedreader(new filereader(f));

database design - The number of categories must be greater than one but fewer than five -

i want create database application creating academic examination. database contains, sake of simplicity, 3 tables follows. problems: problemid (int, identity, primary key) problem (nvarchar) solution (nvarchar) categories: categoryid (int, identity, primary key) category (nvarchar) problemcategory: categoryid (int, composite primary key) problemid (int, composite primary key each problem linked @ least 1 category , @ 5 categories. question how make sure constraint hold in database level? bonus question: is following design recommended replacement design above? problems: problemid (int, identity, primary key) problem (nvarchar) solution (nvarchar) categoryid1 (int, not null) categoryid2 (int, null) categoryid3 (int, null) categoryid4 (int, null) categoryid5 (int, null) categories: categoryid (int, identity, primary key) category (nvarchar) question 1: each problem linked @ least 1 category. answer: declare foreign key constr

PHP Connection Error with localhost -

why this. warning: mysqli_connect(): (hy000/1045): access denied user 'root'@'localhost' (using password: yes) in /usr/local/zend/share/userserver/s/index.php on line 2 when $con = mysqli_connect("127.0.0.1","root","xxx","s"); ? i've tried localhost , didn't work either. i'm positive credentials correct. ideas?

python - How can I avoid value errors when using numpy.random.multinomial? -

when use random generator: numpy.random.multinomial , keep getting: valueerror: sum(pvals[:-1]) > 1.0 i passing output of softmax function: def softmax(w, t = 1.0): e = numpy.exp(numpy.array(w) / t) dist = e / np.sum(e) return dist except getting error, added parameter ( pvals ): while numpy.sum(pvals) > 1: pvals /= (1+1e-5) but didn't solve it. right way make sure avoid error? edit: here function includes code def get_mdn_prediction(vec): coeffs = vec[::3] means = vec[1::3] stds = np.log(1+np.exp(vec[2::3])) stds = np.maximum(stds, min_std) coe = softmax(coeffs) while np.sum(coe) > 1-1e-9: coe /= (1+1e-5) coeff = unhot(np.random.multinomial(1, coe)) return np.random.normal(means[coeff], stds[coeff]) something few people noticed: robust version of softmax can obtained removing logsumexp values: from scipy.misc import logsumexp def log_softmax(vec): return vec - logsumexp(vec) def

jquery css with dynamically created element not working -

i'm creating element using jquery appending one. i'm trying style header doesn't seem working reason. there doesn't seem syntax errors. it's appending div , text appearing, it's not being styled. jquery('<h3/>', { text: 'todays news', css: ('background-color', 'red'), id: 'tdn' }).appendto('#div1'); any appreciated try wrap css style inside { } instead of ( ) jquery('<h3/>', { text: 'todays news', id: 'tdn', css: {'background-color': 'red'}, }).appendto('#div1'); fiddle demo or can use .css() well: jquery('<h3/>', { text: 'todays news', id: 'tdn' }).css('background-color', 'red').appendto('#div1'); fiddle demo

ruby on rails - Trying to mock an API class with RSpec -

i'm trying learn how use rspec test create_price_type_cache method on setting class being called api class instance. i've tried number of approaches i've googled, figure out how this, or if should write api class differently. the test below gives me error: undefined method `api_endpoint' #<rails::application::configuration:0x00000107376420> # setting_spec.rb "should call get_price_type_list api" price_types = [build(:price_type)] api = mock_model(api.instance) api.stub!(:get_price_type_list).and_return(price_types) expect(api.instance.should_recieve(:get_price_type_list).and_return(api)).to eq [price_types] end # setting.rb class setting def self.create_price_type_cache array = api.instance.get_price_type_list activerecord::base.transaction cachepricetype.delete_all array.each |e| e.save! end end end end # api.rb class api def self.instance @instance ||= new end def get_price_type_

android - How to get the time for which screen is ON -

i working on android application warn user if screen been on long time. basic idea behind app warn user long exposure of eyes screen light. want time screen light turned on. if reaches limit then, user notified turn screen off time. how time screen turned on? reading documentation... public static final string action_screen_off added in api level 1 broadcast action: sent after screen turns off. protected intent can sent system. constant value: "android.intent.action.screen_off" public static final string action_screen_on added in api level 1 broadcast action: sent after screen turns on. protected intent can sent system. constant value: "android.intent.action.screen_on" when screen turned on keep track of current time , set alarm period of time , warn user.

python - Sentry AJAX requests get 302 with Nginx and uWSGI -

i have sentry setup described here . sentry available on www.sentry.mysite.com:9000 , , working fine, except ajax queries, example click on "resolve error" button. ajax queries uses url without port, , 302 status , have no effect. kindly help.

java - Struts 2 property tag can't access abstract parent class member -

i'm having problems accessing property via struts. wondering if who's more experienced struts able give me few pointers. the java classes set this: public abstract class parent{ protected integer id; public integer getid(){ return this.id; } } public class child extends parent{ // stuff } the child list in action class getter set up: private list<child> childlist; this code in front end, attempting grab id property: <s:iterator value="childlist" status="cstatus"> <s:property value='id' /> </s:iterator> however, nothing shows up. i've grabbed other members child class, i'm assuming there's issue parent member i'm grabbing being in abstract class? update i've attempted grab property in abstract class in jsp , works fine. other property grabbed creationdate . i've added breakpoints id getter , it's being accessed fine , returning non-null values. h

ios - Testing correct drag of UIView in Rubymotion -

i want write spec uiview use. uiview should dragged location test wether calls wright delegate methods. i'm using "drag" method. drag command not seem to dragging. perhaps i'm using in wrong way? used macbacon spec inspiration. here code: describe "draggableview" tests specdragviewcontroller before @drag = mydragableview.alloc.initwithframe [[10,200],[100,100]] @drag.backgroundcolor = uicolor.redcolor controller.view.addsubview @drag end "should not accept wrong drop" @drag.frame.should != nil @drag.accessibilitylabel = "drag view" delegate = object.new delegate.mock!(:draggableviewhasbeendroppedatwronglocation) {|view| view.should == @drag } p @drag.center drag "drag view", :from => cgpointmake(15,250), :to => cgpointmake(300,300) wait 10{} # long wait, play view in simulator p @drag.frame end end class specdragviewcontroller < uiv

java - JSONArray within JSONArray -

i'm confused why cannot pull jsonarray jsonarray in android application. example , snippet of source code given below. //the json { "currentpage":1, "data":[ { "id":"dimtrs", "name":"bud light", "breweries":[ { "id":"bznaha", "name":"anheuser-busch inbev", } ] } ], "status":"success" } now i'm trying retreive "breweries" array. //code snippet ... jsonobject jsonobject = new jsonobject(inputline); jsonarray jarray = jsonobject.getjsonarray("data"); jsonarray jsarray = jarray.getjsonarray("breweries"); ... i can pull objects out of data array fine, cannot "breweries" array "data" array using current code. the error jsarray is: the method .ge

javascript - method=flickr.photos.search not working -

i using flickr api photos relevant weather info, code works. background load suitable photos nothing load, when change method flickr.photos.getrecent loads images not suitable weather ones search method brings up, has happened anyone? this seems bug on side. search on flickr website doesn't return results when happens. https://www.flickr.com/help/forum/en-us/72157637322588906/ , https://www.flickr.com/help/forum/en-us/72157637221802585/ guess i'll have implement fallback other service image search.

php - Failed login in yii framewok because user id primary key has a foreign key to other table -

i have database table in postgresql , yii table table user , table request. attributes user.id_user primary key refer request table foreign key user.id_user pk refer request.id_user (fk) i submit request through form , save id_user in request. log out , can't login again username , password.. it said incorrect username or password. i have try other username , password , it's again.. there authenticate code ` please tell me problem , solution problem . thank you.. here login configuration examples http://www.yiiframework.com/forum/index.php/topic/45600-yii-autentication-with-mysql/ http://www.larryullman.com/2010/01/04/simple-authentication-with-the-yii-framework/

Excel VBA ComboBoxes to Omit Previously Selected Options -

i have several activex comboboxes predefined list of names: "variables!$b$1:$b$23" the comboboxes in cells a2 - a24. comboboxes omit selected options. example, if select "john doe" in a2 combobox, when open a3 combobox "john doe" not listed option. looking @ combobox_change option combobox code eludes me. i'm sure can see feeble attempt below: private sub combobox1_change() dim combovalue string combovalue = worksheets("roster").oleobjects("combobox1").object.value = 2 worksheets("variables").range("c1") listvariable = worksheets("variables").range("b" & i) if (listvariable = combovalue) 'change other comboboxes end if next end sub

php - The Chosen Plugin is not displaying properly -

i wrote simple codeigniter php app implement chosen. here's page: <!doctype html> <html> <head> <script src="<?php echo base_url();?>js/jquery-1.11.0.min.js"></script> <script src="<?php echo base_url();?>js/chosen.jquery.js"></script> <script> jquery(document).ready( function() { jquery(".chosen").chosen(); } ); </script> </head> <body> <h2>chosen plugin test</h2> <select class="chosen" style="width: 200px; display: none;"> <option>choose...</option> <option>jquery</option> <option selected="selected">mootools</option> <option>prototype</option> <option>dojo toolkit</option> </select> <select class="chosen" multip

javascript - html form two buttons with two actions -

hi there have got simple form work , both functionality update , delete working cannot seem figure out way make them work simultaneously in 1 form... here doing <form id ='udassignment' method ='get' name='udassignment'> <input id ='action' type ='hidden' name ='action' value ='updatemessagefromsimpleform' /> <label for='fid'> id </label> <input id ="fid" type='number' name ='fid' readonly/> <label for='ftitle'> title </label> <input id ="ftitle" type='text' name ='ftitle'/> <label for='fmodule'> module </label> <input id ="fmodule" type ='text' name ='fmodule'/> <label for='fdescription'> description </label> <textarea rows ='4' id ='fdescription' type ='text' name ='fdescription'> </textarea>

Joomla website is getting 303 redirect loop -

my website getting 303 redirect loop on main page. gives me error when trying view site "the webpage has redirect loop", of time loads fine. but, 303 redirect doesn't seo. i'm running joomla 3.2.3 zo2 framework. used firefox live http headers tool , shows: http/1.1 303 see other date: sat, 19 apr 2014 06:42:44 gmt server: apache mod_fcgid/2.3.10-dev x-powered-by: php/5.4.26 set-cookie: 81f5073a1f9d10dc244e07c98216335e=hb7mb5k3v0vftstcgtdbonikq6; path=/; httponly location: / cache-control: max-age=600 expires: sat, 19 apr 2014 06:52:44 gmt content-length: 0 keep-alive: timeout=5 connection: keep-alive i went through , disable every plugin in joomla 1 @ time , when disable zo2 framework plugin 303 redirect went away. i've asked on forums , haven't been able me. so, searched through of files in zo2 plugin directory word redirect , found. these 2 in site.megamenu.js !function ($) { $(document).ready(function ($) { // when clicking o

javascript - SetTimeout not functioning properly -

this code running 21 console logs @ once. should, however, run them 1 @ time @ set interval suggestions? var index = 1; var switchbg = function(num){ if( num < 22 ){ console.log('index' + index); console.log('num' + num); index++; function_timer(index); } }; var timer; var function_timer = function(index){ cleartimeout(timer); timer = settimeout(switchbg(index), 10000); }; you need pass function argument settimeout . try this: timer = settimeout(function() { switchbg(index); }, 10000); doing settimeout(switchbg(index), 10000); evaluates switchbg(index) , passes return value (which undefined ) settimeout .

math - payment amount tracking sql -

i had question asked of me on job interview, , can't seem find right way this. i'm looking answer if comes again time i'll have more of idea of should done. table has 3 columns. id, customername, , amount values (1, "someone", 20000) table b has 3 columns. custid, date, payment. values (1, 1/1/2014, 100) (1, 2/1/2014, 200) (1, 3/1/2014, 500) (1, 4/1/2014, 175) what want know after each payment has been made, remaining balance on account. output be: customer name, payment amount, remaining balance for each payment. how go accomplishing since i've stumped of database friends , can't seem find info on google.... in databases support ansi standard cumulative sum syntax, do: select a.customername, b.payment, (a.amount - sum(b.payment) on (partition a.id order date)) remainingbalance tablea left outer join tableb b on a.id = b.id; in other databases, use correlated subquery.

php - Creating a table from query -

here 2 sql query on first query want use table , on 2nd query want join 1st query assume table e.g. first query: select sale.salesmanid, sale.companyname, sale.sellingprice sale inner join carmodel on (sale.companyname = carmodel.companyname) , (carmodel.size>10) ; second query: select salesman.salesmanid, salesman.name, sum(firstquery.sellingprice) salesman inner join firstquery on salesman.salesmanid = firstquery.salesmanid group salesmanid, name; how can ? in advance. if understand question correctly (although i'm not sure why you'd want way...): if object_id('tempdb..#firstquery) not null drop table #firstquery; select sale.salesmanid, sale.companyname, sale.sellingprice #firstquery sale inner join carmodel on (sale.companyname = carmodel.companyname) , (carmodel.size>10) ; select salesman.salesmanid, salesman.name, sum(firstquery.sellingprice) salesman inner join #firstquery on salesman.salesmanid = first

c++ - Cannot place Collision Detection debug rectangle over game sprites -

i following along let's make rpg (c++/sdl2) - tutorials on youtube , stuck on let's make rpg (c++/sdl2) - part 35 continuation on collision ( https://www.youtube.com/watch?v=dlu6g2s3ta0&list=plhm_a02ntaavey-4ezh7p6bbosv-dka-0 ). i trying place transparent rectangle on sprites debug collision detection. not getting errors there no 1 piece of code can show you. can please shed light on went wrong. i'm new c++ i'm not giving up. thank time. i'm genuinely grateful. this code both header , cpp file of collision rectangle #include "collisionrectangle.h" collisionrectangle::collisionrectangle() { offsetx = 0; offsety = 0; setrectangle(0,0,0,0); } collisionrectangle::collisionrectangle(int x, int y, int w, int h) { offsetx = x; offsety = y; setrectangle(0,0,w,h); } collisionrectangle::~collisionrectangle() { //dtor } void collisionrectangle::setrectangle(int x, int y, int w, int h) { collisionrect.x = x + offset

Double-splat operator destructively modifies hash – is this a Ruby bug? -

i noticed find surprising behavior ** (double-splat) operator in ruby 2.1.1. when key-value pairs used before **hash , hash remains unmodified; however, when key-value pairs used after **hash , hash permanently modified. h = { b: 2 } { a: 1, **h } # => { a: 1, b: 2 } h # => { b: 2 } { a: 1, **h, c: 3 } # => { a: 1, b: 2, c: 3 } h # => { b: 2 } { **h, c: 3 } # => { b: 2, c: 3 } h # => { b: 2, c: 3 } for comparison, consider behavior of single- * operator on arrays: a = [2] [1, *a] # => [1, 2] # => [2] [1, *a, 3] # => [1, 2, 3] # => [2] [*a, 3] # => [2, 3] # => [2] the array remains unchanged throughout. do suppose sometimes-destructive behavior of ** intentional, or more bug? in either case, documentation describing how ** operator meant work? i asked question in ruby forum . update the bug fixed in ruby

get the logged in RDP user in Python -

i don't know rdp, question may not make sense but: what correct way detect, in python, user logged server through rdp? would answer question: is there portable way current username in python? work on remoted log in?

python - <textarea> says it supports carriage return new line but it doesn't seem to - google app engine -

Image
first off, here's screenshots illustrate issue. i'm writing crowd-sourced lyric database web app on google app engine. have 2 text input boxes , text area lyrics. however, when grab data form add database entry, seems strip new lines. either that, or displaying them not working properly. here's code : class addsong(webapp2.requesthandler): def post(self): song = song() song.title = self.request.get('title') song.artist = self.request.get('artist') song.data = self.request.get('data') song.put() self.redirect('/') thanks taking time read this.

php - Only Alphanumeric and one special charcter regex in preg_match -

$str = 'test-test-test-test\\50-test-37447'; if(preg_match('/[a-za-z0-9-]/',$str,$matches)){ echo "<pre>true";print_r($matches);echo "</pre>"; }else{ echo "<pre>false";print_r($matches);echo "</pre>"; } it return true? wrong? it returns true because regex calls 1 character set (so t start first match). if want entire string made of characters, use: ^[a-za-z0-9-]*$ the ^ , $ markers indicate start , end of string respectively, , * means 0 or more of preceding "object". hence means entire string must made of 0 or more of character set you've specified. this causes \ character fail match in test string.

scope - AngularJS - Pass $index or the item itself via ng-click? -

say have <div ng-repeat="item in scope.allitems"> <div ng-click="dosomething(...)"></div> </div> if want item upon click, 1 better option? option 1 use ng-click="dosomething($index) , have: $scope.dosomething = function($index) { var myitem = $scope.allitems[$index]; } option 2 use ng-click="dosomething(item) , have: $scope.dosomething = function(myitem) { // whatever } if doing item, pass in. way function doesn't need know array item belongs to: $scope.addcolor = function(car) { car.color = 'red'; }; if, on other hand, need modify array prefer pass in $index , save having loop through array looking match: $scope.deletecar = function(index, cars) { cars.splice(index, 1); };

c# - How to modify the keys and values of an encrypted app.config file? -

Image
i new on c#/visual studio , i'm having difficulty on running test methods. requires connect database server resulting of getting failed result since can't connect database. we tried modify connection string include our working credentials can connect database server app.config file encrypted. please see below screenshot of example encrypted line. how can modify that? as see think connectionstring encrypted outside project , pasted here. saying because imo encrypting connection string value , keeping key in plain text not possible within project. possible encrypt entire section within config file. check method using connectionstring. believe method might using form of decryption. use decrypt string, change values required, encrypt again , paste in above location. you can edit question include method using connectionstring can analyse , give better solution. hope helps.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException For Loops -

i have problem loop because of nullpointerexception error. for (int num = 0; num < checkingacct.getsize(); num++) and error comes as: exception in thread "awt-eventqueue-0" java.lang.nullpointerexception @ application2.panel.listtransactions(panel.java:152) @ application2.application2$application2a.actionperformed(application2.java:84) @ javax.swing.abstractbutton.fireactionperformed(abstractbutton.java:2018) @ javax.swing.abstractbutton$handler.actionperformed(abstractbutton.java:2341) @ javax.swing.defaultbuttonmodel.fireactionperformed(defaultbuttonmodel.java:402) @ javax.swing.jtogglebutton$togglebuttonmodel.setpressed(jtogglebutton.java:308) @ javax.swing.plaf.basic.basicbuttonlistener.mousereleased(basicbuttonlistener.java:252) @ java.awt.component.processmouseevent(component.java:6505) @ javax.swing.jcomponent.processmouseevent(jcomponent.java:3320) @ java.awt.component.processevent(component.java:6270) @ java.awt.container.processevent(container.java:2229