Posts

Showing posts from January, 2012

asp.net - Return user roles from bearer token of Web API -

i developing web api 2 project. authentication using bearer token. on successful authentication api returns json object. {"access_token":"vn2kwvz...", "token_type":"bearer", "expires_in":1209599, "username":"username", ".issued":"sat, 07 jun 2014 10:43:05 gmt", ".expires":"sat, 21 jun 2014 10:43:05 gmt"} now want return user roles in json object. changes need make in order user roles json response? after searching lot found can create custom properties , can set them authentication ticket. in way can customize response can have custom values may required @ caller end. here code send user roles along token. requirement. 1 can modify code send required data. public override async task grantresourceownercredentials(oauthgrantresourceownercredentialscontext context) { using (usermanager<applicationuser> usermanager = _usermanage

c# - No connection could be made because the target machine actively refused it 127.0.0.1:57240 at System.Net.Sockets.Socket -

i have been developing web service , windows service, web service have deployed in server, , windows service have deployed works in own server, use windows service call web service. fine, in few days have received below message: system.net.webexception: unable connect remote server ---> system.net.sockets.socketexception: no connection made because target machine actively refused 127.0.0.1:57240 @ system.net.sockets.socket.doconnect(endpoint endpointsnapshot, socketaddress socketaddress) @ system.net.sockets.socket.internalconnect(endpoint remoteep) @ system.net.servicepoint.connectsocketinternal(boolean connectfailure, socket s4,socket s6, socket& socket, ipaddress& address, connectsocketstate state, iasyncresult asyncresult, int32 timeout, exception& exception) --- end of inner exception stack trace - -- @ system.net.httpwebrequest.getrequeststream(transportcontext& context) @ system.net.httpwebrequest.getrequeststream() @ system.web.services.protocols.s

ios - dismissViewControllerAnimated not passing back data to vc1 -

i have vc1 , vc2. need vc2 set vc1's variable when vc2 dismissed. this relevant code in vc1.h - (ibaction)btnclick:(id)sender; @property (strong, nonatomic) nsstring *mystr; this relevant code in vc1.m - (ibaction)btnclick:(id)sender { uistoryboard * storyboard = self.storyboard; nsstring * storyboardname = [storyboard valueforkey:@"name"]; //in storyboard named vc2 "ctrl2" identifier viewcontroller2 *temp = [[uistoryboard storyboardwithname:storyboardname bundle:nil] instantiateviewcontrollerwithidentifier:@"ctrl2"]; [self presentviewcontroller:temp animated:yes completion:null]; } - (void)viewwillappear:(bool)animated{ nslog(@"in viewwillappear mystr %@", self.mystr); } - (void)viewdidload{ [super viewdidload]; nslog(@"my str %@", self.mystr); } this relevant code in vc2.h @class viewcontroller; - (ibaction)btnclkd:(id)sender; @property(nonatomic, weak)viewcontroller *v

swift - How to call ambiguous method? -

given code extension array { func filter(includeelement: (t) -> bool) -> t[] { var ret = t[]() e in self { if includeelement(e) { ret += e } } return ret } } var = [1,2] var b = a.filter() {i in print(i); return true} it can't compile error message error: ambiguous use of 'filter' var b = a.filter() {i in print(i); return true} ^ swift.array<t>:84:8: note: found candidate func filter(includeelement: (t) -> bool) -> array<t> ^ <repl>:30:10: note: found candidate func filter(includeelement: (t) -> bool) -> t[] { ^ so looks allowed create extension method duplicated method , signature, somehow need special way call btw, default array.filter broken, calls closure twice each element , crashes repl or give rubbish result in playground if result inconsistent xiliangchen-imac:~ xiliangchen$ xcrun swift welcome swift!

java - Workaround for passing a method into a method? -

i looking way pass method parameter method. i trying simulate newton's-method ( http://en.wikipedia.org/wiki/newton%27s_method ) in java following code: public class newton { // iterationmethod public void newtoncalc(double x0) { double x; // counter int = 0; //newton-iteration x0 x = x0 - (y2(x0) / y2deriv(x0)); while (math.sqrt(y2(x)*y2(x)) >= math.pow(10, -10)){ //newton-iteration x(n+1) x = x - (y2(x))/ y2deriv(x); i++; system.out.printf("%d. %.11f\n",i,y2(x)); } system.out.printf("%d steps necessary resolution of 10^-10", i); } // function (2) public static double y2(double x) { return math.sin(x) / (1 - math.tan(x)); } // derivative (2) public static double y2deriv(double x) { return (math.cos(x) + math.sin(x) * math.tan(x) * math.tan(x)) / ((math.tan(x) - 1) * (math.tan(x) - 1)); } // function (4) public static double y4(double x) { return math.exp(

Apache Worker and APC user cache -

anybody tried apcu zendopcache in mpm worker ? went problems mpm worker-apc found article https://engineyard.zendesk.com/entries/26902267 my target achieve apache mpm worker mod_fcgi [ mod_spdy work ] , zendopcache apcu ( user cache ) , varnish on top. run centos 6.4 on kvm. any oppinion appreciated. disclaimer: jetty developer, since asked opinion, here go. a alternative option run jetty fastcgi module (this link wordpress run jetty , chrome it's served via spdy - via alpn ). jetty java server known spdy support (the server transparent spdy push ), , fastcgi support too; has small memory footprint , it's highly scalable because asynchronous. with haproxy in front (mostly ssl offloading) satisfied of setup.

lisp - How do I ensure the correct precedence in Emacs highlighting keywords? -

Image
i'm trying write simple major mode lisp dialect. here's mode: (defconst example-font-lock-keywords (list `(";.*" . font-lock-comment-face) `(,(regexp-opt '("function" "macro") 'symbols) . font-lock-builtin-face) `("\"[^\"]+?\"" . font-lock-string-face)) "highlighting example mode.") (defvar example-mode-syntax-table (make-syntax-table)) (define-derived-mode example-mode lisp-mode "example" "major mode editing example lisp code." :syntax-table example-mode-syntax-table (set (make-local-variable 'font-lock-defaults) '(example-font-lock-keywords))) here's sample program: ; highlighting tests. ; comment despite "quotes" (function foo () "bar") here's result i'm seeing: what doing wrong? why string regexp 'win' against comment regexp? emacs highlights buffer in 2 phases. first syntactic phase, b

KineticJS move shape -

i'm new kineticjs , i'm trying make circle shape move on player input. alerts on event listener firing, circle not moving. ? here's code: (function () { var stage = new kinetic.stage({ container: "the-container", width: 800, height: 600, }); var layer = new kinetic.layer(); var playercircle = new kinetic.circle({ x: 50, y: 50, radius: 10, fill: "black", }); var leftarrowcode = 37; var rightarrowcode = 39; var uparrowcode = 38; var downarrowcode = 40; document.addeventlistener('keydown', function (event) { if (event.keycode == leftarrowcode) { playercircle.move({ x: -10, y: 0 }); alert("left pressed"); } if (event.keycode == rightarrowcode) { playercircle.move({ x: 10, y: 0 });

How to retrieve rows using datetime (python & mysql) -

this code: now = datetime.datetime.now().replace(microsecond=0) curs.execute("select name, msgdate, test msgdate=%s",(now)) i got these msgs: file "c:\python\lib\site-packages\mysql\connector\cursor.py", line 220, in _process_params res = list(map(to_mysql,res)) typeerror: 'datetime.datetime' object not iterable during handling of above exception, exception occurred: traceback (most recent call last): file "c:\projectse\email\src\a.py", line 65, in <module> curs.execute("select name, msgdate messages msgdate=%s",(now)) file "c:\python\lib\site-packages\mysql\connector\cursor.py", line 300, in execute stmt = operation % self._process_params(params) file "c:\python\lib\site-packages\mysql\connector\cursor.py", line 225, in _process_params "failed processing format-parameters; %s" % e) mysql.connector.errors.programmingerror: -1: failed processing format-parameters; 

javascript - Is there any way of making this function more efficient in a standard browser? -

while profiling web app in chrome found following function function taking large percentage of total runtime app (which reasonable considering how used - maybe 1000 times each page load). therefore wonder if has suggestions of how improved increase performance? function getdate(datestring) { re = datestring.split(/\-|\s/); return new date(re.slice(0, 3).join('/') + ' ' + re[3]); } this function given string in form: "yyyy-mm-dd hh:mm:ss", example: "2014-06-06 23:45:00", , returns javascript date. i using jquery option. not using many array operations, , not using global re variable, should help: function getdate(datestring) { return new date(datestring.replace(/-/g, "/")); } however, notice yyyy-mm-dd hh:mm:ss valid date format parsed date constructor directly (ok, maybe not in older ies), in standard browser work well: function getdate(datestring) { return new date(datestring); }

actionscript 3 - Flash Pro cc why is the stage width and height on my phone, set as the one inside Flash pro? -

i having problem setting stage height , width app developing. i need set height , width screen of device on. stage.fullscreenheight , stage.fullscreenwidth. but realized fullscreenheight , width setting size stage inside flash pro cc under properties(the stage size). and not able make stage width , height according phone's. if capabilities.screenresolutionx; or stage.stageheight. of them set either size of image, or stage inside flash pro, none according device. edit: e.g. var button = button = new button(); button.width = stage.stagewidth; button.height = button.width/stage.stagewidth * button.height; try stage.scalemode = stagescalemode.no_scale or unchecking "full screen" checkbox in air settings

Unable to Resolve Library Activity for Android Test -

i created basic android-maven-project using android-release archetype . 1 thing changed setting android project android library. means have no androidmanifest defining activities. maven build still works helloandroidactivity , helloandroidactivitytest , copying both classes make new test fail: unable resolve activity for: intent { act=android.intent.action.main flg=0x10000000 cmp=org.acme.project.android/.helloandroidactivity2} i've searched entire workspace , not find reference helloandroidactivity explain why works activity not one. guess have 2 questions: why integration test work activity not referenced in manifest file? , why doesn't work identical copy of activity? i don't think matters much, these androidmanifests : library project: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.acme.project.android" android:versioncode="1" android:versionname="1

android - Update one Fragment due to changes in another fragment -

the scenario: i have 2 fragments(each in separate tab) doing work that's related each other. example: public class extends fragment{ // take user input , calculate geo-location(this works fine) // user can mannually enter location address , geocoder // figures out lat/lng of location. // uses asych task. } public class b extends fragment{ // google map. based on latitude & longitude // place marker @ location(which provided class a.) // other stuff aswell } the problem: i want pass location information class b. having trouble updating map marker once finished calculating location in class a. have seen minute app starts class b oncreateview() method runs. put marker functions information. asych task class takes time calculate geolocation , therefore don't have location provide markers method in class b yet. there anyway add marker map once asych task has completed without calling oncreateview() (for class b) in class again? in other words can somehow pass

android - horizontal scrolled view for tabwiget not slide tabs -

i using horizontal scrolled view tabs not slide content change. please me. when flip pages tabs not flip. <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <tabwidget android:id="@android:id/tabs" android:layout_width="wrap_content" android:layout_height="wrap_content" > </tabwidget> <framelayout android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="match_parent" > <framelayout android:id="@+id/tab1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" />

Perl Flip Flop operator and line numbers -

i noticed while looking @ another question ... if have script this: while (<>) { print if 5 .. undef; } it skips lines 1..4 prints rest of file. if try this: my $start_line = 5; while (<>) { print if $start_line .. undef; } it prints line 1. can explain why? actually i'm not sure why first 1 works. hmmm looking further found works: my $start = 5; while (<>) { print if $. == $start .. undef; } so first version magically uses $. line number. don't know why fails variable. the use of bare number in flip-flop treated test against line count variable, $. . perldoc perlop : if either operand of scalar ".." constant expression , operand considered true if equal ( == ) current input line number (the $. variable). so print if 5 .. undef; is "shorthand" for: print if $. == 5 .. undef; the same not true scalar variable not constant expression. why not tested against $. .

html - No able to select particular check box using Selenium (Java) -

i want click on store pickup available checkbox on following page http://www.target.com/c/pants-shorts-baby-toddler-boys-clothing/-/n-59yk1#navigation=true&viewtype=medium&sortby=newest&isleaf=true&navigationpath=59yk1&parentcategoryid=9976007&facetedvalue=/-/n-59yk1&ratingfacet=0&categoryid=139007 and particular html part has <input type="checkbox" name="facetid" id="in store, onlinecheckbox3" value="10058540" omniture="store pickup eligible"> i tried many thing by.id() , by.cssselector() , xpath also. can try , tell me working code ... in-between continue trying. the problem checkbox want click hidden initially. can click this: driver.findelement(by.xpath("//a[contains(text(),'in store, online')]")).click(); driver.findelement(by.xpath("//span[contains(text(),'store pickup eligible')]/../../input")).click(); this expand element "

LibGDX smart collision detection actors -

so i'm creating towerdefence-game lot(5-25) towers exist. now i'm trying think of smart way handle collision detection, meaning spawning creature in range. the obvious way (for me @ least) create list of creatures , list of towers, every tower checks, if creature in reach. but i'm pretty 20 towers game crash (especially on smartphone), since tower collision-checks every frame. isn't there kind of way, tower waits collision, , if happens, reacts on it? (like listener, collisions)

python - Best way to access data from mysql db on other non-local machines -

i have read few posts on how enable remote login mysql. question is: safe way access data remotely? i have sql db located @ home (on ubuntu 14.04) use research purposes. run python scripts macbook @ work. able remote login old windows os using workbench connection (dns ip). os change has got me thinking best/most secure way accomplish task? use ssh login home computer, setup authorized keys , disable password login. setup iptables on linux machine if don't have firewall on router, , disable traffic on ports except 80 , 22 (ssh , internet). should started.

c++ - How is the deletion of a pointer detected using dynamic cast -

as shown here , 1 can use dynamic_cast detect deleted pointer: #include <iostream> using namespace std; class { public: a() {} virtual ~a() {} }; class b : public { public: b() {} }; int main() { b* pb = new b; cout << "dynamic_cast<b*>( pb) "; cout << ( dynamic_cast<b*>(pb) ? "worked" : "failed") << endl; cout << "dynamic_cast<b*>( (a*)pb) "; cout << ( dynamic_cast<b*>( (a*)pb) ? "worked" : "failed") << endl; delete pb; cout << "dynamic_cast<b*>( pb) "; cout << ( dynamic_cast<b*>(pb) ? "worked" : "failed") << endl; cout << "dynamic_cast<b*>( (a*)pb) "; cout << ( dynamic_cast<b*>( (a*)pb) ? "worked" : "failed") << endl; } the output: dynamic_cast<b*>( pb) worked dynamic

gem - RHC not working on OpenShift instance -

i getting started node, created instance on openshift , trying install rhc can setup aliases domain name. i ran following , installation successful rhc (1.25.2). gem install rhc the next step run: rhc setup however, i'm getting error bash: rhc: command not found help appreciated. ultimately, problem trying fix stopping website redirecting http://www.example.com -> https://www.example.com/app -- update: i found rhc located in /var/lib/openshift/[myuserdir]/.gem/bin , tried run setup , ended message: ./rhc setup openshift client tools (rhc) setup wizard wizard upload ssh keys, set application namespace, , check other programs git installed. unexpected error occured: undefined method `[]' nil:nilclass update 2: rhc setup runs, fails when attempting generate token: generate token now? (yes|no) yes generating authorization token client ... /usr/lib/ruby/1.8/fileutils.rb:243:in `mkdir': permission denied - /var/lib/openshift/[hidden]/.op

javascript - issue in adding events to dynamically coming elements -

this question has answer here: events triggered dynamically generated element not captured event handler 5 answers doing accordion, structure follows, few divs coming dynamically, not working. parent div <div id="resultarea" class="accordion"> </div> inside parent tag following tags coming dynamically. <div class="accordion-item"> item 1 <div class="type"></div> </div> <div class="data"> data related item 1 </div> <div class="accordion-item"> item 2 <div class="type"></div> </div> <div class="data"> data related item 2 </div> below javascript $(function($) { var allaccordions = $('.accordion div.data'); var allaccordionitems = $('.accordion .accordio

SlowCheetah not working on c# console application -

i'm trying use slow cheetah xml transforms console application using c# when right click on app.config file there no "add transform" item in menu. and "slowcheetah" installed application , can found in packages.config file <packages> <package id="slowcheetah" version="2.5.10.6"/> </packages> any appreciated thanks the solution is: 1- uninstall slowcheetah. 2- install again using this link ! 3- referesh visual studio

graph - calculate AUC (GAM) in R -

i used following script calculate auc in r: library(mgcv) library(rocr) library(auc) data1=read.table("d:\\2005.txt", header=t) gam<-gam(tuna ~ s(chla)+s(sst)+s(ssha)+s(eke), family=binomial, data=data1) gampred<- predict(gam, type="response") rp <- prediction(gampred, data1$tuna) auc <- performance( rp, "auc")@y.values[[1]] auc roc <- performance( rp, "tpr", "fpr") plot( roc ) but when running script, result is: rp <- prediction(gampred, data1$tuna) error in prediction(gampred, data1$tuna) : format of predictions invalid. auc <- performance( rp, "auc")@y.values[[1]] error in performance(rp, "auc") : object 'rp' not found auc function (x, min = 0, max = 1) { if (any(class(x) == "roc")) { if (min != 0 || max != 1) { x$fpr <- x$fpr[x$cutoffs >= min & x$cutoffs <= max] x$tpr <- x$tpr[x$cutoffs >= min &

java - NullPointerExceptions when parsing Json using Gson on Android -

i'm bit new posting on stackoverflow. i've done whole bunch of searching, , can't seem find answer helps me solve specific problem. i trying parse particular json: https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=fuzzy%20monkey%27 i'm new json, , using google gson in order parse it. compiles fine. doesn't seem if java classes being populated proper info json (i keep getting nullpointerexceptions), due lack of knowledge json. in code, nullpointerexception comes final int n = response.results.size() line main activity. my main activity: public class mainactivity extends actionbaractivity { public static inputstream json; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); if (savedinstancestate == null) { getsupportfragmentmanager().begintransaction() .add(r.id.container, new place

Get top 2 rows from each distinct field in a column in Microsoft SQL Server 2008 -

i have table named tblhumanresources in want collection of rows consists of 2 rows each distinct field in effectivedate column (order by: ascending): tblhumanresources table | empid | effectivedate | company | description | 0-123 | 2014-01-23 | dfd comp | analyst | 0-234 | 2014-01-23 | abc comp | manager | 0-222 | 2012-02-19 | cdc comp | janitor | 0-213 | 2012-03-13 | cbb comp | teller | 0-223 | 2012-01-23 | cbb comp | teller and on. any appreciated. try use row_number() function n rows per group: select * ( select t.*, row_number() on (partition effectivedate order empid) rownum tblhumanresources t ) t1 t1.rownum<=2 order effectivedate sqlfiddle demo version without row_number() function assuming empid unique during day: select * tblhumanresources t t.empid in (select top 2 empid tblhumanresources t2

javascript - jQuery UI trigger datepicker -

i have span/date element below <span class="editabledatetxt">06/10/2014</span> now on click of this, want show inline editable date popup (or jquery ui datepicker) so when view rendered, have; var self = this, $el = $(self.el); $el.find(".datepicker" ).datepicker(); and click of editabledatetxt, have; $(document).on("click",".editabledatetxt", function () { var input = $('<input />', {'type': 'text', 'class':'datepicker hasdatepicker', 'value': $(this).html()}); $(this).parent().append(input); $(this).remove(); input.focus(); }); but datepicker not getting triggered (i cannot see date picker on ui) am doing wrong ? because when view rendered there no element class datepicker , added when click on editabledatetxt element. $el.find(".datepicker" ).datepicker() statement not have meaning. so $(document).o

command prompt - How to create batch file? -

i need run below command command prompt. how make batch file not have type whole command again? c:\program files (x86)\microsoft ajax minifier\ajaxmin.exe c:\css\reset.css c:\css\main-styles.css c:\css\lightbox.css c:\css\shortcodes.css c:\css\custom-fonts.css c:\css\custom-colors.css c:\css\admin_menu.min.css -out c:\css\mc.css -clobber add >"file.bat" echo start of command create simple batch file. quotes around paths , filenames spaces , & characters needed too. >"file.bat" echo "c:\program files (x86)\microsoft ajax minifier\ajaxmin.exe" c:\css\reset.css c:\css\main-styles.css c:\css\lightbox.css c:\css\shortcodes.css c:\css\custom-fonts.css c:\css\custom-colors.css c:\css\admin_menu.min.css -out c:\css\mc.css -clobber in cases characters need escaping example work.

python - SQLalchemy/wtforms update issue - 400 bad request -

what i'm trying is, once user submits results want update fixture_prediction model according filters. although 400 bad request. log doesnt tell me enough know whats going wrong. ideas? i think tuple data submitted through form... the form displays fine when submit form goes straight bad request. my error bad request browser (or proxy) sent request server not understand. what have currently: views @app.route('/predictor/',methods=['get','post']) @login_required def predictions(): user_id = g.user.id # retrieve predictions prediction= db.session.query(fixture_prediction,\ fixture_prediction.fixture_id,fixture.stage,\ fixture.home_team,fixture_prediction.home_score,\ fixture_prediction.away_score,fixture.away_team)\ .outerjoin(fixture,fixture.id==fixture_prediction.fixture_id)\ .outerjoin(user,fixture_prediction.user_id == user.id)\ .fi

java - NullPointerException in rest webservice upload -

i trying upload file using rest webservice. code @path(value= "/up") public class upload { @post @path(value="upload") @consumes(mediatype.multipart_form_data) public response uploadfile(@formdataparam("file") inputstream fileinputstream ) { string filepath = "c://users/marya/desktop/file" ; system.out.println("*****serverpath********"); savefile(fileinputstream, filepath); //this line 29 system.out.println("*****save********"); string output = "file saved server location : " + filepath; system.out.println("done"); return response.status(200).entity(output).build(); } private void savefile(inputstream uploadedinputstream,string serverlocation) { try {outputstream outpustream = new fileoutputstream(new file(serverlocation)); int read = 0; byte[] bytes = new byte[1024]; outpust

java - form creation in spring mvc issue -

i've 2 classes public class user { private int id; priavte list<hobby> hobbies; //setter getter } public class hobby { private int id; private string hobbyname; //setter getter } now want create form user.java my form.jsp is <form:form method="post" action="saveemployee.html" commandname="user" name="register-form" id="register-form" cssclass="smart-green"> <form:select path="hobbies" multiple="true" size="3"> <form:option value="1">cricket</form:option> <form:option value="2">computer games</form:option> <form:option value="3">tennis</form:option> <form:option value="4">music</form:option> </form:select> </form:form> mycontroller.java @requestmapping(value = "/saveemployee.html", method = requestmeth

c# - Doing some actions (setting language) before controller initializes in Web API -

i trying set language controller in web api (doing internationalization globalization). i writing attribute called setlanguage , decorate web-api controller it something like, [setlanguage] public servicerequestcontroller : apicontroller but problem this: public class setacceptlanguageheader : attribute, icontrollerconfiguration { public void initialize(httpcontrollersettings controllersettings, httpcontrollerdescriptor controllerdescriptor) { if (controllersettings.request.headers.acceptlanguage != null && controllercontext.request.headers.acceptlanguage.count > 0) { var culture = new cultureinfo(controllercontext.request.headers.acceptlanguage.first().value); thread.currentthread.currentculture = culture; thread.currentthread.currentuiculture = culture; } } } but, not able because cannot access request controllersettings . (though know

javascript - Unexpected string in JS with CSS -

i write small page , in code have error. want use way because isotope doesn't read width , height styles in html tags. var winw = $(window).width(); var plmt_w = winw / 10; var plmt_h = plmt_w; var css = '.plmt { width:' plmt_w '; height:' plmt_h ';}', ..... as ajm , amit joki said, need + operators concatenate strings. but, since $(window).width() returns unitless value, need add 'px' valid css string: var css = '.plmt { width:' + plmt_w + 'px; height:' + plmt_h + 'px;}',

Android Studio 0.6 "Select modules to import" error -

i'm trying import volley android application. i've done in past. morning, updated android studio 0.6 , updated buildtoolsversion 19.1.0 , , updated gradle. when try import volley module, , navigate location of volley folder in file system, following message "select modules import" . i opened build.gradle folder in volley , , updated gradle , build version, still got same error. running issue? i've met problem yours , solved commenting line #android.library=true int file project.properties .it works me , hope works or else.

c++ - What container really mimics std::vector in Haskell? -

the problem i'm looking container used save partial results of n - 1 problems in order calculate n th one. means size of container, @ end, n . each element, i , of container depends on @ least 2 , 4 previous results. the container have provide: constant time insertions @ either beginning or end (one of two, not both) constant time indexing in middle or alternatively (given o(n) initialization): constant time single element edits constant time indexing in middle what std::vector , why relevant for of don't know c++, std::vector dynamically sized array. perfect fit problem because able to: reserve space @ construction offer constant time indexing in middle offer constant time insertion @ end (with reserved space) therefore problem solvable in o(n) complexity, in c++. why data.vector not std::vector data.vector , data.array , provide similar functionality std::vector , not quite same. both, of course, offer constant time indexing in midd

How to I specify a NuGet package comes from an external source in packages.config? -

i working on project has dependency on nuget project on external source. using package restore , not committing packages git. developers not have source configured in nuget settings, there way specify in packages.config file package should pulled different source? e.g., <?xml version="1.0" encoding="utf-8"?> <packages> <package id="antlr" version="3.4.1.9004" targetframework="net45" /> <package id="bootstrap" version="3.0.0" targetframework="net45" /> ... <!-- how specify custom package comes different source? --> <package id="mycustompackage" version="1.0.0" targetframework="net45" /> ... <package id="respond" version="1.2.0" targetframework="net45" /> <package id="webgrease" version="1.5.2" targetframework="net45" /> </packages>

php - Undefined variable not allowing me to insert file into database table column -

Image
i'm uploading audio files directory , storing file name info in database. have done successfully. next wanted create default image each audio file, use php add audio files title image , tack on unique id file name. have done successfully. learned following tutorial. example image: the problem i'm having getting audio files image insert database column on upload. here database image. need file name of newly created audio image go rt_file column. can echo out later. i hoping on i'm going wrong. the current error is: undefined variable: rt_file . don't understand why...? not define have defined above insert statement this: $rt_file = preg_replace('/\s+/', '-', "../ringtones/rtimage/".($ringtone_image[0]['ring_name'])."-".substr(md5(microtime()),rand(0,26),5).".jpg"); i hate post code know it's frowned upon, apologize in advance, i'm not sure problem lies. if has time through great, if no