Posts

Showing posts from June, 2014

javascript - Can't get gulp watch to trigger build function on file change within supposedly watched folder -

i've tried couple of ways gulp watch folder of files in order rebuild on file change , stop me having manually. i'm sure in grunt worked adding watch task array of build tasks , finish initial build leaving watch open listen changes during development session. i've tried this, taken this example gulp readme - i've removed batch call want build trigger on every event. gulp.task('watch', function () { watch('src/**/*.js', function (events, done) { gulp.start('build', done); }); }); the call gulp watch works , appears watching, error displayed make change file in folder. my build function works - i've been not happily triggering manually far! /users/tonileigh/node_modules/gulp/node_modules/orchestrator/index.js:89 throw new error('pass strings or arrays of strings'); ^ error: pass strings or arrays of strings @ gulp.orchestrator.start (/users/tonileigh/no...

GnuPlot: stacked histogram causes hovering bars -

Image
since 2 days trying solve problem. bars of stacked histogram not printed above each other. floating freely around. secondly, want print 5th xtic-label. using gnuplot v 4.6 patchlevel 6. hovering bars in stacked bargraph here first data rows (generated libreoffice): 05.06,-,-,1 06.06,3,-,0 07.06,12,-,3 08.06,0,5,4 09.06,7,2,0 10.06,86,2,1 11.06,31,4,1 12.06,17,1,0 01.07,1,7,1 here comes command set: gnuplot> set datafile separator ',' gnuplot> set style data histogram gnuplot> set style histogram rowstacked gnuplot> set style fill solid border -1 gnuplot> set xlabel "zeit" gnuplot> set ylabel "anzahl" gnuplot> set yrange [0:250] gnuplot> plot 'test.csv' using 2:xtic(1) title "menge a",'' gnuplot> using 3:xtic(1) title "menge b",'' gnuplot> using 4:xtic(1) title "menge c" gnuplot seems confused - column content. set datafile missing '-' doesn...

C# Foreach statement does not contain public definition for GetEnumerator -

i'm having problem windows form application i'm building in c#. error stating "foreach statement cannot operate on variables of type 'carbootsale.carbootsalelist' because 'carbootsale.carbootsalelist' not contain public definition 'getenumerator'". i can't seem understand causing this. this code throwing error: list<carbootsalelist> sortcarboot = new list<carbootsalelist>(); foreach (carbootsale c in carbootsalelist) { if (c.charity == "n/a") { sortcarboot.add(carbootsalelist); textreportgenerator.generateallreport(sortcarboot, appdata.charity); } } and carbootsalelist class it's saying there isn't getenumerator definition: public class carbootsalelist { private list<carbootsale> carbootsales; public carbootsalelist() { carbootsales = new list<carbootsale>(); }...

scala - Passing Type Constructor to Var Args of `Any` Type -

given: scala> def f(x: any*): string = "foo" f: (x: any*)string my understanding it'll take 1 or more arguments of any , , return "foo" . scala> f(1, 2, list(4), "foo") res5: string = foo scala> f(null) res6: string = foo but, passed in higher-kinded type: scala> f(option) res7: string = foo ... expected compile-time failure since edit - think it's type constructor. why did f(option) work, i.e. output "foo" ? that not type constructor, , there's nothing special var args in case. companion object of option . if make f generic on type parameter a , can see option.type (the type of option s companion object) inferred. scala> def f[a](a: a) = f: [a](a: a)a scala> f(option) res1: option.type = scala.option$@59f95c5d

iphone - Error: SyntaxError: DOM Exception 12 setRequestHeader@[native code] -

i in process of developing mobile application android , ios, phonegap , angularjs, cors_rest. have working headers on android. when testing on iphone gapdebug. here example of authentication code: $http.post('someurlhere', {username: username, password: password}) .then(function (response) { if(!response.isauthenticated) { alertsmanager.addalert('username or password incorrect', 'alert-danger'); } callback(response); console.log(response); }); i getting error: syntaxerror: dom exception 12_img if please appreciate it. thank you: please, check headers params, ios9 not accept parameters in http headers has space @ beginning of value. example: "token":" token12345" => wrong "token":"token12345" => correct i hope helps you.

mysql - PHP Calculation from database not calculating correctly. -

i trying run sum numbers taken database. can't seem work. does have ideas why keep getting 0 instead of percentage? if guide me in right direction. php: //sql original goal $goal = "select * login username = '$login'"; $goalquery = mysql_query($goal); $goalarray = mysql_fetch_array($goalquery); $endgoal = $goalarray['goal']; //latest weight $latestweightarray = mysql_fetch_array($latestweightq); $currentweight = $latestweightarray['weight']; //first weight recorded $firstweightarray = mysql_fetch_array($firstweightq); $firstweight = $firstweightarray['weight']; $percent = "100"; $progress = (($firstweight - $currentweight) / ($firstweight - $endgoal)) * $percent; print result: <?php echo $progress ?> this gives: 0 rookie error, had updated database twice in 1 day conflicted results somehow, changed 1 of dates in database , solved problem

facebook - Python - Addition and merging with an array -

i'm using facebook api collect data on mentions. i'm collecting month , amount of times term (eg: banana) has been mentioned in post. have data coming in looks this: 12, 0 12, 0 11, 1 11, 0 11, 1 10, 0 10, 0 10, 0 each row represents 1 post. want merge months (first column) , number of times term has been mentioned (second column) looks this: 12, 0 11, 2 10, 0 i tried putting data in array so: [12, 0] [12, 0] [11, 1] [11, 0] [11, 1] [10, 0] [10, 0] [10, 0] but unable figure out way of merging , adding columns. there anyway of doing this? assuming data list of tuples or lists, can use defaultdict , iterate on list, e.g.: >>> collections import defaultdict >>> d = defaultdict(int) >>> m, c in data: ... d[m] += c >>> list(d.items()) [(10, 0), (11, 2), (12, 0)]

How can I disable other buttons when I press one button in angularjs -

is possible in angular? when press 1 single button element, other button elements automatically disabled. saw similar question looking in pure angularjs. <html ng-app> <button ng-model="button" > abc </button> <button ng-disabled="button"> def </button> <button ng-disabled="button"> ghi </button> </html> you can bind ng-click event 3 of buttons, passing identifier function (i.e. id of button. function bind variable scope, use determine if ng-disabled should active or not. for example, in controller have similar to: $scope.selectedbutton; $scope.selectbutton = function(id) { $scope.selectedbutton = id; } then, in html; revise take in ng-click , ng-disabled considerations mentioned above. <html ng-app ng-controller="somecontroller"> <button ng-disabled="selectedbutton && selectedbutton != 'abc'" ng-click=...

excel - Getting "" in the file instead of " which is not expected -

there code in button click workbooks saved local text files. workbook contains below info: critical; insert ifparam values(3498,'tat_unalloctradesrec','string','if(string(c5)=string("tce - external hedge"),string("e"),if(string(c5)=string("tce - internal hedge"),string("i"),string(c5)))'); but output comes critical; insert ifparam values(3498,'tat_unalloctradesrec','string','if(string(c5)=string(""tce - external hedge""),string(""e""),if(string(c5)=string(""tce - internal hedge""),string(""i""),string(c5)))'); issue ever there " getting "" in output. can me in getting in workbook i.e; single double quote " instead of "" please suggest if code change needed. code used : private sub commandbutton1_click() dim xlbook workbook, xlsheet worksheet dim stroutputfi...

excel - If Cell.Value is specific size, Copy 3 cells in that row to new sheet -

i have excel document fill out tshirt sizes, names, , numbers. goal here is... once form filled out, can hit button copy smalls , put them onto new sheet, mediums, onto another, , on. can select whole row, want copy few cells. pasting them @ point same row on new sheet in old sheet. want them show on next available line. here examples... in excel sheet(1) "main" b c d ----------------------------------------- **name** | size | # | ----------------------------------------- joe small 1 there other sarah x-small 3 instructions on peter large 6 here on side sam medium 12 of document ben small 14 important rick large 26 in excel sheet(2) "small" should be b c d ----------------...

java - Capture Console Display (both input & output) -

i'm setting test cases console-based application in java. below code: bytearrayinputstream in = new bytearrayinputstream("input 1\ninput 2".getbytes()); system.setin(in); //feeds inputs bytearrayoutputstream out = new bytearrayoutputstream(); system.setout(new printstream(out)); //captures output testprogram.test(); string output = out.tostring(); system.setout(new printstream(new fileoutputstream(filedescriptor.out))); system.out.println(output); the application simple , forth between console , user - console asks question, user gives answer. so, example, console might following @ end of interaction, given inputs above: please enter color: input 1 please enter name: input 2 ...where input 1 , input 2 user's inputs, , prompts issued print commands testprogram.test() . i capture console looks @ end of interaction (i.e., both inputs , outputs together), seems can capture input , output independently. how can modify code above capture resulting consol...

Upload zip file in JSF 2.2 with ajax -

in application can upload zip file. i'd incorporate ajax. how can ajax work zip files? right now, code looks this: <h:form id="form" enctype="multipart/form-data" prependid="false" pt:class="form-inline" pt:role="form" rendered="#{consolecontroller.getadmin() != null}"> <div class="form-group"> <label class="sr-only" for="file">file:</label> <h:inputfile id="file" value="#{uploadcontroller.file}" /> </div> <h:commandbutton id="button" value="upload" action="#{uploadcontroller.upload}" class="btn btn-default"> <f:ajax execute="file" render="@all" /> </h:commandbutton> </h:form> i following error in form of modal window in chrome: malformedxml:...

android - How to detect from which app a user returned to your app? -

a user presses on url in app , url opens in mobile browser. is possible detect in app when user returned mobile browser app? many users read content of url , press return app. test case: user clicks on url mobile browser opens url user touches button app detects user came app mobile browser if did not explain well, please let me know. i suggest launch url startactivityforresult . then, when user returns application onactivityresult called, , if requestcodes align know web browser. for more information, take @ this: http://developer.android.com/reference/android/app/activity.html#startingactivities

symfony - Use Doctrine to merge entity with different subclass -

i have mapped superclass abstractquestion single-table-inheritance. /** * @orm\entity * @orm\mappedsuperclass * @orm\table(name="question") * @orm\inheritancetype("single_table") * @orm\discriminatorcolumn(name="dtype", type="string") * @orm\discriminatormap({ * "simple": "simplequestion", * "dropdown": "dropdownquestion" * }) */ abstract class abstractquestion simplequestion , dropdownquestion inherit superclass. /** * class simplequestion. * @orm\entity() */ class simplequestion extends abstractquestion i want modify existing simplequestion , make dropdownquestion . when saving question, deserialise , merge question, contains id , 'dtype' , other properties. $dquestion = $this->serial->fromjson($request->getcontent(), abstractquestion::class); $question = $this->em->merge($dquestion); $this->em->flush(); so submit like: { id: 12, dtype:...

sql - Teradata Week Number Prior Year with Monday as Start of Week -

i have following statement in teradata case when extract(year current_date) - 1 = extract(year event_date) , weeknumber_of_year(event_date) = weeknumber_of_year(current_date) 'y' else 'n' end "wtd_ly" the issue 'week' supposed start on monday, instead of sunday. how need tweak this? there's optional parameter week number_of_year : weeknumber_of_year(current_date, 'iso') but logic fail, e.g. there's week 53 in 2015/16, not in 2014.

RSPEC test and Ruby Object -

so i'm trying write code make rspec test pass ruby. i'm having trouble getting first test pass. think if can have little this, i'll able rest. can post rest of tests if makes easier offer advice. so it's constructing fahrenheit/celsius converter, using objects , classes instead of defining couple of methods conversions. the first part looks require "temperature" describe temperature describe "can constructed options hash" describe "in degrees fahrenheit" "at 50 degrees" temperature.new(:f => 50).in_fahrenheit.should == 50 end one of hints in instructions says temperature object constructer should accept options hash either :celsius or :fahrenheit entry. any or hints appreciated. i've been stuck on test last few weeks. in advance. i think temperature class needs work. why not have 'scale' attribute can set base value of temperature object? here's modified v...

database - MySQL - 1 column table -

Image
so tried asking yesterday phrasing of question pretty terrible. im stuck designing database, system hold different types of creatures, , there 3 types of creatures. these insects, air creatures , aquatic creatures, , there 3 seperate tables these three. each of these creatures have base table , active table user can copy of base creature. want able reference id these tables table , im not sure how besides creating new table id , each of these 3 base creatures having there id being foreign key of parent table. doing though mean have table has 1 column (id) referenced other tables. basecreatures table: id 1 2 3 4 aircreatures table: id name 1 eagle 2 bird aquaticcreatures table: id name 3 whale 4 shark what think? ok do? so baseaquatic, baseinsect... tables, these store base stats of creature. these havent been assigned user yet. in order new field in activecreature needs created can generate id go in activeaquatic, activ...

ios - Expression is not assignable, coordinate attribute from MKAnnotation class delegate -

Image
i did schema in order explain better troubles. so, can fix it? thank =) the cllocationcoordinate2d struct , i.e. value type. passed around value, way of saying "copying". if assign fields (e.g. longitude) modifying copy ; original coordinate inside annotation remain intact. why property not assignable. to fix this, should add separate properties latitude , longitude, , use them instead: @interface annotation : nsobject<mkannotation> @property (readwrite) cllocationdegrees latitude; @property (readwrite) cllocationdegrees longitude; @property (nonatomic,assign) cllocationcoordinate2d coordinate; ... @end @implementation annotation -(cllocationdegrees) latitude { return _coordinate.latitude; } -(void)setlatitude:(cllocationdegrees)val { _coordinate.latitude = val; } -(cllocationdegrees) longitude{ return _coordinate.longitude; } -(void)setlongitude:(cllocationdegrees)val { ...

css - JavaFX remove padding/margin/border from Pane -

i can't seem remove left , right border of gridpane. see picture below. left , right border my fxml file <?xml version="1.0" encoding="utf-8"?> <?import java.lang.*?> <?import java.util.*?> <?import javafx.scene.*?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <gridpane alignment="center" maxheight="-infinity" maxwidth="-infinity" minheight="-infinity" minwidth="-infinity" prefheight="600.0" prefwidth="800.0" style="-fx-box-border: transparent;" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8"> <padding> <javafx.geometry.insets top="0" right="0" left="0" bottom="0"/> </padding> <columnconstraints> <columnconstraints percentwidth="33.0" /> ...

Cakephp - one variable accessible in view and controller -

i want define array can use in appcontroller , default layout. how in cakephp? $this->set('arr', array('one', 'two')); // accessible in controller $this->viewvars['arr']; // accessible in view/layout echo $arr;

list - Why does not Java HashSet.equals() check for object equality? -

i've come phenomenon morning, equals method in set not check value equality of element while list does. not in accordance java doc. set<myclass> s1 = new hashset<>(); set<myclass> s2 = new hashset<>(); set<myclass> s3 = new hashset<>(); set<myclass> s4 = new hashset<>(); list<myclass> l1 = new arraylist<>(); list<myclass> l2 = new arraylist<>(); myclass o1 = new myclass(); myclass o2 = new myclass(); // **this gives false, , not call myclass.equals().** s1.add(o1); s2.add(o2); boolean setcomparewithdifferentobjects = s1.equals(s2); // gives true, , not call myclass.equals(). s3.add(o1); s4.add(o1); boolean setcomparewithsaveobjects = s3.equals(s4); // give true, , myclass.equals() called. l1.add(o1); l2.add(o2); boolean listcompare = l1.equals(l2) i've done research. according java doc set , hashset equals , hashset containsall , hashset contains , use (o==null ? e==null : o.equals(e)) chec...

Query array element and then field, from MongoDB -

suppose have following document in collection: { "_id":objectid("1123562e7c594c12942f"), "figures":[ { "shape":"square", "color":"blue" }, { "shape":"triangle", "color":"black" } ] } i make query selects field "shape" second element of array "figures" . using db.test.find({}, {"figures": {$slice: [2, 1]}}) can access second element of "figures" , can select only field "shape" there? use below query db.test.find({}, {"figures": {$slice: [2, 1]}, "figures.shape": 1}).pretty();

jquery - how to use $.ajax() in anywhere -

my file in d drive d:/item/1.js i not use xampp or wamp it not work function request($i){ $url = "item/"+$i+".js"; $.ajax({ crossdomain: true, cache: false, type: 'post', url: $url, datatype: 'json', success: function(datax){ //return data; data = datax; }, error: function(){ //return error(); data = error(); } }); } i want work anywhere for example : file:///c:/document/item/1.js , flash memory , , .... i can not use .load() because json thanks

What have I done wrong when coding this array of objects in C++? -

i have 2 classes, personnellists , employee. create instance of personnellists in main, so: int main() { personnellists example; //make personnel list ... } personnellists uses constructor member initialisation of list of employees, number of employees, , size of array: personnellists::personnellists(): list(new employee[size]), numemployees(0), arraysize(size){ } this results in null empty employees being created (i think?): employee::employee(): employeenumber(0), name(null), department(null) { } it @ line invalid null pointer error. i new c++, fresh off boat java programming. i'm still novice pointers, i'm not quite sure i'm doing wrong here. update: requested, here class definition of employee: #include <iostream> class employee { public: employee(); //constructor employee(std::string name, std::string deparment); void print() const; //print employee's details void setemployeeno(int employeenum); ...

javascript - Combine Angular and Blade expressions -

i'm using laravel , angular , wondering if it's possible , how can combine both laravel , angular expressions? for example if have route has parameter need angular variable: data-ng-click="myfunction({{ url::route("myroute", [<% myobj.id %>]); }})" where <% %> changed angular open/close expression tags , {{}} blades open/close expression tags. it won't work. blade code(php) run server-side , angular(js) run on client side. meaning blade code always executed before angular code while code requires blade execute after angular. if change expression blade required run before angular, work. but, end lots of spaghetti code way. blade , angular different technologies. not intermix them unless extremely necessary. , make sure comment reasons .

Rewrite function in java-8 style -

i implement next task in 1 stream, without loop in code: public list<integer> findsumforeachnode() { list<integer> result = new arraylist<>(); (int ind = 0; ind < nodenum; ind++) { result.add(stream .concat(getneighbors(ind).stream(), getinneighbors(ind).stream()) .collect(summingint(integer::intvalue))); } return result; } what going on: each node take neighbours (list) , inneighbours(list), find sum , add result in result list. intstream.range(0, nodenum) .maptoobj(ind -> stream.concat( getneighbors(ind).stream(), getinneighbors(ind).stream()) .collect(summingint(integer::intvalue))) .collect(tolist());

Introspecting a C++ dll with python and calling function -

i'm searching way call function inside c++ dll. work c# , c++ seems can't use reflection on dll , calling function name string. i saw post on ctypes, i'm not sure if fit needs. need python library introspect c++ dll, call function, getfood() string mydll.call('getfood'). thank you. yes, ctypes need. use: dllobj = ctypes.windll("dll file name") to load dll memory. can find functions , call them. this nice job of explaining.

php - Using .htaccess to rewrite urls with ID: "Page not found" -

i trying rewrite urls using .htaccess file in wordpress environment. have wordpress page called "offerta" 2 parameters, 1 of them custom id use generate content. so, example url is: http://www.riccionelastminute.it/rlm/offerta/?id=15&titolo=my-title and be: http://www.riccionelastminute.it/rlm/offerta/my-title-15/ this .htaccess right now: # begin wordpress <ifmodule mod_rewrite.c> rewriteengine on rewritebase /rlm/ rewriterule ^index\.php$ - [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /rlm/index.php [l] </ifmodule> # end wordpress after research, tried add rule right after last rewrite rule, redirects 404 page: rewriterule ^offerta/([a-za-z0-9-]+)-([0-9]+)/$ offerta/?id=$2&titolo=$1 i'm not used play around .htaccess , i'm not expert. missing something? the problem last rewriterule has l flag means no other rules applied after it . need add rule before last one: <ifm...

32 bit division in assembly language -

i'm learning assembly language programming in college course (80386 programming). currently, i'm learning ins , outs of 32 bit division using edx , eax registers store remainder , quotient respectively. want know, why not correct output when don't include mov edx, 00000000h in program. program either doesn't run or gives wrong output. relevant source code: mov edx, 00000000h mov eax, 1234567ah div 11111111h ; edx=remainder, eax=quotient i post full code if needed. when using div 32-bit operand, divide 64-bit value in edx:eax (high dword in edx , low dword in eax ) operand , put quotient in eax , remainder in edx . therefore should clear edx prior division if value want divide 32 bits (fits in eax alone). failure result in incorrect results, or division overflow if quotient doesn't fit in eax .

ios - Border collision detection -

i'm making game sprite kit , have collision detection setup this: ball.physicsbody?.categorybitmask = ballcategory borderbody.physicsbody?.categorybitmask = bordercategory and handler -didbegincontact() : func didbegincontact(contact: skphysicscontact) { var firstbody = skphysicsbody() var secondbody = skphysicsbody() if contact.bodya.categorybitmask < contact.bodyb.categorybitmask { firstbody = contact.bodya secondbody = contact.bodyb }else { firstbody = contact.bodyb secondbody = contact.bodya } if firstbody.categorybitmask == ballcategory && secondbody.categorybitmask == bordercategory { print("you lose!") } } i have line set contact delegate: self.physicsworld.contactdelegate = self but when run game, collision not detected , nothing happens. wrong? see documentation here . need set contacttestbitmask if want receive contact/intersection notifications....

c# - Reflection get all GenericParameterAttributes -

i need genericparameterattributes generic parameter t in mclass public class mclass<t>:ienumerable<t> t : class,icomparable, new() { //some body here } so try in way: assembly asm = assembly.loadfrom("m.dll"); type some_type = asm.gettype("m.mclass`1"); type[] generic_args = { typeof(mytestclass) }; if (some_type.isgenerictype) { console.writeline("generic type: {0}", some_type.tostring()); console.writeline("where t : {0}", some_type.getgenericarguments()[0].genericparameterattributes); some_type = some_type.makegenerictype(generic_args); } but in reason propherty genericparameterattributes show t must class default constructor doest't show t must have icomparable tried in way : this worked dont forget rebuilt project after changed) static void main() { assembly asm = ...

How to sort ordinal values in elasticsearch? -

say i've got field 'spicey' possible values 'hot', 'hotter', 'smoking'. there's intrinsic ordening in these values: they're ordinals. i'd able sort or filter on them using intrinsic order. example: give me documents spicey > hot. sure can translate values integers 0,1,2 requires housekeeping on both index , query side i'd rather avoid. is possible in way? contemplated using multi field mapping not sure if me. you can sort based on string values scripting sort operation, set each spicey string specific field value. curl -xget 'http://localhost:9200/yourindex/yourtype/_search' -d { "sort": { "_script": { "script": "factor.get(doc[\"spicey\"].value)", "type": "number", "params": { "factor": { "hot": 0, "hotter": 1, "smoking"...

jquery - Recursive function that returns $.Deferred() with setTimeout -

i have recursive function returns $.deferred(); the function follows: var mytest = function (i, deferred) { if (!deferred) { deferred = $.deferred(); } if (i < 3) { i++; console.log("recursion (" + + ")!"); return mytest(i, deferred); } else if (i === 3) { console.log("resolving!"); return deferred.resolve("woohoo, reached " + + "!"); } } /* call */ mytest(0).done(function (result) { console.log(result); }); this gives expected output of: recursion (1)! recursion (2)! recursion (3)! resolving! woohoo, reached 3! but if change line 8 be settimeout(function() { return mytest(i, deferred); }, 500); it fails. how can add timeout function achieve same result? jsfiddle original code jsfiddle timeout if understand trying... var mytest = function (i) { var deferred = $.deferred(); var interval = setinterval(function()...

bash - Why doesn't my if statement with backticks work properly? -

i trying make bash script user able copy file, , see if done or not. every time copy done, or not, second output "copy not done" shown. idea how solve this? if [ `cp -i $files $destination` ];then echo "copy successful." else echo "copy not done" fi what want is if cp -i "$file" "$destination"; #... don't forget quotes. you version: if [ `cp -i $files $destination` ];then #.. will execute else branch. the if statement in shell takes command. if command succeeds (returns 0 , gets assigned $? ), condition succeeds. if if [ ... ]; then , it's same if test ... ; then because [ ] syntactic sugar test command/builtin. in case, you're passing result of stdout* of cp operation argument test the stdout of cp operation empty ( cp outputs errors , go stderr ). test invocation empty argument list error. error results in nonzero exit status , else branch. *the $() proces...

Java Recursion in an If/Else statement -

i'm trying figure out why top block of code executes bottom block of code not. did other execute switch conditions position in if/else statement public static void onthewall(int bottles){ if (bottles == 0){ system.out.println("no bottles of beer on wall," + " no bottles of beer, ya’ can’t take 1 down, ya’ can’t pass around," + "cause there no more bottles of beer on wall!"); } else if (bottles <= 99){ system.out.println(bottles + " bottles of beer on wall, " + bottles + " bottles of beer, ya’ take one" + " down, ya’ pass around, " + (bottles - 1) + " bottles of beer on wall"); onthewall(bottles-1); } } public static void onthewall(int bottles){ if (bottles <= 99){ system.out.println(bottles + " bottles of beer on...

laravel - How to deny access to certain routes / views for users -

i trying deny access users other 1 id=1 (in case it's admin) 'cpanel' (admin panel) view. trying achieve acl, somehow think not correct way. this want in pseudocode version if (isadmin()) renderpage() else print "you not allowed view page" reading documentation found line declared in custom controller $this->authorize('update', $post); where 'update' ability defined elsewhere, , $post seems model (use app\post) don't know how implement. don't think laravel's documentation covers how implement models authorization. how can authorize view? it's laravel 5.2

c# - Error in generate code and Update list -

i try make generate 16 bit code , when add record number same how can fix ? in loop befor code[i] = newcode; code corect when code added in list changed last code new code same last generate !!!! public actionresult gen5rm(generatecodemodel model){ code newcode = new code(); int x = convert.toint32(model.quntity); code[] code = new code[x]; (int = 0; < x; i++) { string strdate = ""; string strmonth = ""; string strday = ""; string myday = ""; strmonth = datetime.now.tostring("mm"); myday = datetime.now.dayofweek.tostring(); if (myday == "sunday") { strday = "su"; } if (myday == "monday") { strday = "mo"; ...

PHP Cross Site XML -

this question has answer here: php httprequest 3 answers i have in file called abc.php, , return valid xml document, instead of showing -string- labels @ end , beggining header('content-type: application/xml'); $xml = file_get_contents("http://www.xxx.asmx/test?id=1"); //external web service $xmlstr = simplexml_load_string($xml); echo $xmlstr; i want use valid xml data of abc.php, extract data, store in db, , check output of other server periodically, i've tried this: ob_start(); include 'abc.php'; $result = ob_get_clean() as this: $xml = file_get_contents("abc.php"); $xmlstr = simplexml_load_string($xml); without success, advice? make sure output mime type well, or else server feed text/html , wrong. put function header("content-type: application/xml"); in abc.php client recognize xml. ...

angularjs - Angular $scope function not running -

i have ionic app works every function this. no errors, function never being executed ... $scope.contact = function(contactid){ console.log("test"); for(i=0;i<contacts.length;i++){ if(contacts[i].id == contactid){ return contacts[i]; } } } }; ... here entire controller: .controller('contactsctrl', function($scope, $rootscope, auth, data, $localstorage, $stateparams) { $scope.token = $localstorage.token; $scope.tokenclaims = auth.gettokenclaims(); $scope.contacts = data.getapicontacts( function(list) { $scope.contacts = list; $localstorage.contacts = list; return list; }, function() { $rootscope.error = 'failed fetch contacts.'; } ); $scope.contact = function(contactid) { console.log("test"); (i = 0; < contacts.length; i++) { if (contacts[i]....

mercurial - hg clone through a login server using ssh -

i'm trying collaborate individuals not in institution , not allowed connect internal network through vpn, however, ssh through login server allowed. i.e. collaborates can login using 2 successive ssh commands: $ ssh loginserver $ ssh repositoryserver after logging in can begin developing on repository server. however, make clone, , make modifications remotely, , push changes back. i know 1 can run mercerial commands through ssh, , works fine me (because on network). i.e.: $ hg clone ssh://uid@repositoryserver//path/to/repo however, there way run commands through login server? something like: $ hg clone ssh://uid@loginserver ssh://uid@repositoryserver//path/to/repo thanks help. this in principle possible, underlying ssh chaining necessity bit fragile; if institution's policies allow hosting on external server, i'd consider option first. that said, yes, can done. first of all, users need login repository server login server @ least once (...

sql - trigger after insertion method -

i trying built trigger in when user delete row after deleted user able view row deleted. i have tried coading follows please help. create trigger insertion before insert on client each row select * client try this: create trigger deltrig on client delete select deleted

Extract information from a GAMLSS object in R -

i using lms function in gamlss package centile regression. after running lms() function got object, not know how display centile curves. how extract parameters can plot centile curves own. tested fitted.plot() function, there error saying such function not exist. have download 4.2.0 version. wondering if help. have @ documentation: here as far can see lms command version of gamlss fit , plotted using centiles command.

javascript - Objects in external json file should be placed in html divs of same name -

being new jquery , javascript, looking way insert data external json file html code. data objects in json named same corresponding html divs. same should happen @ onload event of html page. var mainobject = {"main":[{ "i_have": [ { "mymainsavings": { "mymainsavingstop": { "accountname": "mymainsavings", "accountnumber": "x726", "balance": "usd 5,600.00", "rate":"" }, "mymainsavingsbottom": [ {"available": "available","value": "$4329"}, {"clear": "clear","value": "$3456"}, {"hold": "hold","value": "$5000"} ] } }, { "myeverydayexpenses": { "myeverydayexpensestop": { "accountnam...

php - Mysql dyanmic value as alias -

so following works $query = "select a.entity_id, b.value variable_character, c.value text, d.value integer customer_address_entity left join customer_address_entity_varchar b on b.entity_id = a.entity_id left join customer_address_entity_text c on c.entity_id = a.entity_id left join customer_address_entity_int d on a.entity_id = d.entity_id order a.entity_id desc limit 100"; however there many values need joined entity in table , right creating own nested array based on new value. 0 => array (size=4) 'entity_id' => string '597424' (length=6) 'variable_character' => string 'dave' (length=4) 'text' => string '45 haven rd' (length=11) 'intiger' => string '43' (length=2) 1 => array (size=4) 'entity_id' => string '597424' (length=6) 'variable_character' => null ...

ios - App inactive state notification didn't arrive? -

when app active state shown notification using alertview ,when app inactive state show notification . this response : aps = { alert = { calltype = order; id = 194; info = "dear customer thank contacting sr number request sacha4 contact shortly our service professional details."; }; sound = default; }; i splitting values this: nsdictionary *aps=[userinfo objectforkey:@"aps"]; nsdictionary *alertdic=[aps objectforkey:@"alert"]; inactive state coding: if (application.applicationstate == uiapplicationstateinactive) { query=[nsstring stringwithformat:@"insert job ('id','message','calltype')values('%ld','%@','%@')",[[alertdic objectforkey:@"id"] integervalue],[alertdic objectforkey:@"info"],[alertdic objectforkey:@"calltype"]]; uilocalnotification *notificatio...

node.js - react-native init error with nodejs -

i got error when use command react-native init hello in nodejs events.js:141 throw er; // unhandled 'error' event ^ error: spawn npm enoent @ exports._errnoexception (util.js:855:11) @ process.childprocess._handle.onexit (internal/child_process.js:178:32) @ onerrornt (internal/child_process.js:344:16) @ nexttickcallbackwith2args (node.js:455:9) @ process._tickcallback (node.js:369:17)

visual c++ - connecting to access database using MFC CDatabase in VS2012 and windows 8 x64 -

to connect access database programming mfc, using visual studio 2012 update 1 installed on windows 8 x64, following code throws exception, did not happened before in vs2010 , windows 7 x64. there thing changed odbc manager , how should change connection string. cdatabase db; db.openex(text("odbc;driver={microsoft access driver (*.mdb, *.accdb)};dsn='';dbq='d:\\databases\\a.mdb'"); and exception message: 'data source name not found , no default driver specified' it not work accdb file too. cha in comments correct since default x64 odbc driver present in windows 8 mfc applications compiling in win32 platform necessary install odbc driver in x86. downloaded here: http://www.microsoft.com/en-us/download/details.aspx?id=13255

php - Laravel - Task Scheduling(The system cannot find the path specified.) -

when run : php /path/to/artisan schedule:run 1>> nul 2>&1 it gives me error the system cannot find path specified. the tutorial says /path/to/artisan project folder located. project folder located in c:/xampp/htdocs/project/ but when run : php c:/xampp/htdocs/project/ schedule:run 1>> nul 2>&1 or php c:/xampp/htdocs/project/artisan schedule:run 1>> nul 2>&1 it gives me same error try this: php c:/xampp/htdocs/project/artisan schedule:run 1>> /dev/null 2>&1

angularjs - how to load the specific div class or id in to another html using anguarjs -

in jquery, possible load specific selector element in html using classes , id on load function for example: $('#id').load("http://www.thisiswhyimbroke.com li:first .someclass") is there way same in angular include i.e ng-include? try this.. <div class="include-example" ng-class="template.class" ng-include="template.url">

c# - Type and identifier are both required in a foreach statement ERROR in csharp -

i converting vb.net c# code: dim files() string files = directory.getfiles("e:\\text", "*.txt") dim filename string dim file string each file in files filename = path.getfilename(file) i tried in c# got error type , identifier both required in foreach statement error in csharp string[] files; files = directory.getfiles("e:\\text", "*.txt"); string[] filenamemove; string filename; string file; foreach (file in files) filename = path.getfilename(file); try foreach(var file in files) you need specify type you're looping through or use var you declared variable called file though. you'd have use different name foreach(var f in files) { filename = path.getfilename(f); } (although logic you're overwriting filename on each iteration, unless want last filename, i'm not sure purpose of is).

Function only working half of the time C -

i have written random path generator project , when works works intended. works sometimes. may lot of code go through bare me. in main function have simple switch statement call 3 tasks project. while(continue) { switch(example_number) { default: printf("no such program exists.\n"); break; case 1: path(); break; case 2: caesar_cipher(); break; case 3: anagram(); break; } printf("would test another?(y/n)\n"); scanf("\n%c",&ch); if(ch == 'y' || ch == 'y') { null; } else { continue = false; } } when input 1 calls function witch creates array , calls other 2 functions. void path(void) { //creates array walk. char walk[10][10] = {{'.','.','.','.','.','.','.','.','.','.'}, {'.',...