Posts

Showing posts from May, 2013

java - Library System: Borrowing -

i not know how borrowholding() in library menu have create. purpose of borrowholding() members able borrow books or videos. this sample data of array: member[0] = new standardmember("id", "name"); member[1] = new premiummember("id", "name"); holding[0] = new book("id", "title"); holding[1] = new video("id", "title", loanfee); this borrowholding() method in testlibrary class: (the array in testlibrary class too) public static void borrowholding(){ string option; option = input.next(); do{ scanner scan = new scanner(system.in); int tempid = 0; system.out.println("enter id: "); string searchid = scan.next(); for(int = 0; < member.length; i++){ if(member[i].getid().equals(searchid)){ tempid = i; } } so method, tried write code search through array find memberid wants borrow. not completed yet because believe

Combining Sass mixin selectors -

this question has answer here: styling specific set of input types in reusable way sass 2 answers i'm trying figure out if it's @ possible combine mixin selector strings. don't believe possible in context of code, missing something! let's have following scss: // apply set of rules input form fields. @mixin input-form-fields { input:not([type="hidden"]), textarea { @content; } } // apply set of rules button form fields. @mixin button-form-fields { button, button { @content; } } // apply set of rules select form fields. @mixin select-form-fields { select { @content; } } // apply set of rules form fields. @mixin all-form-fields { @include input-form-fields { @content; } @include button-form-fields { @content; } @include select-form-fields { @c

javascript - Saving Value from check to mysql database (Angular Js,J2EE,Mysql) -

i getting data database array- in view code is- <tr role="row" ng-repeat="result in searchresults"> <td class="sorting_1"><input type="checkbox" ng-model="result.status" ng-change="savecheckboxvalue(result.status)"/></td> </tr> on clicking checkbox want update value, js :- $scope.savecheckboxvalue = function(data){ $scope.result.status= (data == true ? 1 : 0); alert($scope.result.status); var successcallback = function(){ $.growl.notice({ message: "updated successfully!" }); $location.path("/attendance"); //$scope.get(); $scope.displayerror = false; }; var errorcallback = function() { $scope.displayerror=true; }; $scope.result.$update(successcallback, errorcallback); } i getting error : put localhost...... 405 method not allowed help solution or idea , how can it?

php - How to make a string from one kind of array items? -

i have array this: $results = $stmt->fetchall(pdo::fetch_assoc); /* array ( [0] => array ( [id] => 191 [type] => 3 [table_code] => 15 ) [1] => array ( [id] => 192 [type] => 3 [table_code] => 15 ) [2] => array ( [id] => 194 [type] => 3 [table_code] => 15 ) ) */ and i'm trying make string of ids comma separator. this: echo $expectedoutput; // 193, 192, 194 how can that? here i've tried far: foreach($results $item) { $expectedoutput = $item['id']; } but there , in end of string. you can using implode , array_column . array column makes array id of array, , after implode makes string array delimiter. want use , . echo implode(", ", array_column($results, "id")); //193, 192, 194

mysql - Sum column values in flipped table with generated column names -

i have following mysql-code : select question, sum(case when value = '1' 1 else 0 end) '1', sum(case when value = '2' 1 else 0 end) '2', sum(case when value = '3' 1 else 0 end) '3', sum(case when value = '4' 1 else 0 end) '4', sum(case when value = '5' 1 else 0 end) '5', sum(case when value = '6' 1 else 0 end) '6', sum(case when value = '7' 1 else 0 end) '7', sum(case when value = '8' 1 else 0 end) '8', sum(case when value = '9' 1 else 0 end) '9', sum(case when value = '10' 1 else 0 end) '10', count(value) total -- line should edited ( select answer1 value, 'answer1' question questionaire union select answer2 value, 'answer2' question questionaire union select answer3 value,

java - Overriding time from settings page -

i want override time settings page app screen. attaching 2 pictures 1 app screen time need override , second 1 settings page this 1st picture i.e; app screen time need override here. . if want change 5:00 pm how can it? this second image settings page when input time here time need change in first image so here think trying achieve, 1.have 1 page in app (i.e. first image) show current time. 2.you want page change according time set on phone. use following code system time calendar c = calendar.getinstance(); simpledateformat df = new simpledateformat("hh:mm a"); string formattedtime = df.format(c.gettime()); // formatteddate have current date/time textview.settext(formattedtime); //set time view using above code can have view set time system time. ps make sure set time in onresume() method of activity well

ruby on rails - saving an object value passed by function -

i have folliwing code: class logfactory < activerecord::base after_initialize :inizializza messagenotdefined = "msg" def inizializza self.happened = time.current self.messaggio = messagenotdefined end def setmessage(messaggio) logger = logfactory.new(:messaggio => messaggio, :happened => self.happened) logger.save end end the problem in messaggio variable. mean, if use param messaggio in .new(:messaggio => messaggio,.. rails still use messagenotdefined constant defined during initialization. why? cause assign messagenotdefined messaggio after object initialization. when .new(:messaggio => 'my_messaggio', ...) , there 2 steps: initialization. on step messaggio assign 'my_messagio' . after_initialize callback executing. on step messaggio assign messagenotdefined anyway, according code. it looks want use this: def inizializza happened ||= time.current me

c++ - How to suppress termination in Google test when assert() unexpectedly triggers? -

here it's discussed how catch failing assert, e.g. setup fixture assert() fails , see nice output. need opposite. want test assert() succeeds. in case fails want have nice output. @ point terminates when snags on assert(). #define limit 5 struct obj { int getindex(int index) { assert(index < limit); // stuff; } } obj obj; test(fails_whenoutofrange) { assert_death(obj->getindex(6), ""); } test(succeeds_wheninrange) { obj->getindex(4); } above contrived example. want second test not terminate in case fails, example if set limit 3. after all, assert_death suppresses somehow termination when assert() fails. the following opinion, seems me either testing wrong thing, or using wrong tool. assert (c assert() ) not verifying input, catching impossible situations. disappear release code, example, can't rely on it. what should test function specification rather implementation . , should decide, specification in

javascript - Is there js plugin convert the matrix parameter to css3 transform property? -

suppose have css3 transform style: img { -webkit-transform:rotate(10deg) translate(100px,20px); -moz-transform:rotate(10deg) translate(100px,20px); } then use jquery style: console.log($('#clone').css('-moz-transform')); it return me series number: matrix(0.984808, 0.173648, -0.173648, 0.984808, 95.0078px, 37.061px) is there js plugin turn matrix number transform?or turn other side? numbers you're getting result of multiplying rotation , translation matrices. although case doing math on paper , getting formulas need hand, increasing number of terms teadious task (you need know structure of original trasforms in order reverse them well). here's link you: http://www.useragentman.com/blog/2011/01/07/css3-matrix-transform-for-the-mathematically-challenged/ why not set value need javascript code , therefore eliminate need geting them matrix @ all?

javascript - Creat gantt chart from d3.js -

this kind of data have: [ {'totaltime': 10, 'hour': 0, 'name': 'sam'}, {'totaltime': 15, 'hour': 1, 'name': 'bob'}, {'totaltime': 300, 'hour': 2, 'name': 'tom'}, ... , on till, {'totaltime': 124, 'hour': 23, 'name': 'jon'} ] data every hour of day. , wish create gantt chart size of bars based on totaltime. names on y axis , hour on x. is possible make gantt chart without start time , end time on d3.js? it's possible, you'd need draw if you're using d3.js. if you've made bar charts before, along lines, setup axes, add them svg , use them convert data rectangles you'll put on chart, label rects names data. d3.js not include layout this. if haven't done already, go through tutorials : let’s make bar chart, parts i , ii & iii , move on looking @ custom time axis example , , related a p i s. there ma

android - Image.resizeMode doesn't work as expected in react-native -

Image
i followed instruction( https://facebook.github.io/react-native/docs/image.html ) on using image.resizemode resize image fit content of view. below code. import react, {component} 'react'; import {view, image,stylesheet, dimensions} 'react-native' import tabnavigator 'react-native-tab-navigator'; class maincomponent extends component { render() { return ( <tabnavigator tabbarstyle={style.tab}> <tabnavigator.item title="护士说" rendericon={()=> <image source={require('../../icons/main/tab-button_01_pre.png') } resizemode={image.resizemode.cover}/>} > </tabnavigator.item> </tabnavigator> ) } } const screenheight = dimensions.get('window').height; const style=stylesheet.create({ tab: { align

css - React native android fitSystemWindows does not take effect -

is there alternative fitsystemwindows() in react-native android? my use case following : use translucent status bar flag draw under status bar, in case keyboard resize doesn't work (standard android limitaion) solution of apply window insets - whenever system windows insets using fitsystemwindows=true received respective views set same amount of padding around . here reference: windowsoftinputmode="adjustresize" not working translucent action/navbar but since react-native controls layout system, see fitsystemwindows not applied.

arrays - How to forward functions with variadic parameters? -

in swift, how convert array tuple? the issue came because trying call function takes variable number of arguments inside function takes variable number of arguments. // function 1 func sumof(numbers: int...) -> int { var sum = 0 number in numbers { sum += number } return sum } // example usage sumof(2, 5, 1) // function 2 func averageof(numbers: int...) -> int { return sumof(numbers) / numbers.count } this averageof implementation seemed reasonable me, not compile. gives following error when try call sumof(numbers) : could not find overload '__converstion' accepts supplied arguments inside averageof , numbers has type int[] . believe sumof expecting tuple rather array. thus, in swift, how convert array tuple? this has nothing tuples. anyway, isn't possible convert array tuple in general case, arrays can have length, , arity of tuple must known @ compile time. however, can solve problem providing overloads

angular2 template - Angular 2: If value exists show html -

at moment have service pulls values number of apis have written. in template wish output following html if value exists or not empty in results when fed template: <li class="title rh-blue-lite-fg">{{ project.meta_header_one }}</li> so trying figure out how wrap in ngif or there other way 'li' item gets output if value present , not empty i think can use ngif directive check if project isn't null: <li class="title rh-blue-lite-fg" *ngif="project.meta_header_one">{{ project.meta_header_one }}</li> reference: https://angular.io/docs/ts/latest/api/common/index/ngif-directive.html

asp.net mvc 3 - MVC3 pass exception from controller to view -

want print exception on cshtml page, unbale use this @html.validationsummary() <form method="post" action="adduser"> </form> you should add error message in action this. modelstate.addmodelerror(string.empty, "error message."); and use @html.validationsummary() in view.

javascript - If element has two specific classes, disable button -

i have group of divs user can scroll though clicking on next , previous button. @ 1 time there should ten divs loaded. when user clicks next button, first div hidden , next div shown. goes previous button. when user viewing first div, previous button disabled , when user viewing last div, next button disabled. far, have working except disabling of buttons. here loose structure of html <div> <button id="logo-previous"></button> <div class="logo-image"></div> <div class="logo-image"></div> <div class="logo-image"></div> <button id="logo-next"></button> </div> here jquery script far: $(document).ready(function() { $('.logo-image:lt(10)').show(); $('.logo-image').first().attr('id', 'first'); $('.logo-image').last().attr('id', 'last'); $('.logo-image:lt(10)').a

objective c - Receiver type error Obj-C -

i'm trying make hangman game. realize methods aren't efficient. basically, each time letter entered i'm checking see if there empty spaces left can display "you won!" image. keep getting 2 errors: receiver type 'char' not 'id' or interface pointer , consider casting 'id' thread 1: exc_bad_access (code=1, address=0x63) any appreciated. bool dash = yes; for(int j = 0; j < self.correctword.length; j++){ char temp = [self.correctword characteratindex:j]; if([temp isequal:@"-"]) dash = yes; } if(dash == yes) self.hangmanimage.image = [uiimage imagenamed:@"wonimg"]; the thing objective-c it's 2-headed beast. there objects, send messages. there's plain c. no messages here, operators , function calls. let's examine error: receiver type 'char' not 'id' or interface poin

python - printing items inline in IPython -

i need print inline dynamically in loop in ipython notebook. using python 2.7 . used code: for in xrange(10): print "." , #some computation , no print statement and used: for in xrange(10): print "\b." #some computation , no print statement but both of above solutions doesn't seem work in ipython notebooks. what need is: .......... , above snippets printing is: . . . . . . . . . . any , every appreciated. this work on both python 2 , python 3: from __future__ import print_function in range(10): print('.', end='') you can pass flush=true keyword argument force flush buffer instantly. you can overwrite previous line using '\r' , her's simple example: import time in range(10): time.sleep(0.2) print('\r{} / 10'.format(i + 1, 10), end='')

c# - OpenTK bind multiple textures on shader -

i'm trying make multitextured terrain. when trying bind 3 textures, there 1 texture displayed. c# code here : gl.useprogram(program); //active textures, glid - texture id, generated gl.gentexture() gl.bindtextures(0,3,new int[3]{grass.glid,grass_normal.glid,stone.glid}); //set shaders uniform, diffuse shader class diffuse.setuniform("maintexture",grass.glid); diffuse.setuniform("gnormalmap",grass_normal.glid); diffuse.setuniform("stonetexture",stone.glid); //just render code, example gl.bindvertexarray(mesh.vao); gl.drawelements(primitivetype.triangles, mesh.triangles.count,drawelementstype.unsignedint, intptr.zero); //unbind gl.useprogram(0); gl.bindvertexarray(0); gl.bindbuffer(buffertarget.arraybuffer, 0); gl.bindbuffer(buffertarget.elementarraybuffer,0); gl.bindtextures(0,3,new int[3]{0,0,0}); there shader fragment program: #version 140 uniform sampler2d maintexture;//grass uniform sampler2d gnormalmap;//grass normal uniform

android - "cannot resolve constructor FirebaseRecyclerAdapter" when trying to use FirebaseUI -

i using firebaseui 's firebaserecycleradapter described in github . but getting error (cannot resolve constructor firebaserecycleradapter ). tried possible still getting same error. here activity firebase ref = new firebase("https://myapp.firebaseio.com/shoplist"); recyclerview recyclerview; string enteredshopname; private firebaserecycleradapter<chat, chatholder> mrecyclerviewadapter; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); recyclerview = (recyclerview) findviewbyid(r.id.recyclerview); recyclerview.sethasfixedsize(true); recyclerview.setlayoutmanager(new linearlayoutmanager(this)); floatingactionbutton fab = (floatingactionbutton) findviewbyid(r.id.fab); fab.setonclicklistener(new view.onclicklistener() { @override p

database - How to store someone else's password? -

this question has answer here: storing passwords external apis - best practice 5 answers there's general consensus on how store passwords if have validate them (i.e. hash + salt (+ pepper)). however, building application logs users in service x actions a, b, c repeatedly them. how 1 store passwords in case? if encrypted, there has 1-to-1 conversion if 1 wants log them service x. there no safe way store passwords can decrypted plain text form. the oauth2 protocol offers solution use case. it asks user authenticate , issues application access token (and potentially refresh token) allows application access or act upon behalf of user.

Git - git pull dont give the expected result -

i working on repo , did local commits , want git pull origin develop whithout change .. should please ? you can git log for check commit history. there find commits. take commit number before local changes. do git checkout -f {commit number} then initial state (before make local changes). do git pull origin develop the develop branch update then. , think expected result.

cocoapods - During Pod Installation `AFNetworking (~> 3.0)` is not used in any concrete target -

recently i've installed cocoapods v 1.0.0 in mac successfully, trying install 'afnetworking', '~> 3.0' dependency in pod file of project directory. i've created successfully, putting following code in pod file source 'https://github.com/cocoapods/specs.git' platform :ios, '8.0' pod 'afnetworking', '~> 3.0' but when write pod install in terminal giving me following error [!] dependency `afnetworking (~> 3.0)` not used in concrete target. could suggest me why getting error & how resolve issue? after submitting question, further explored solution & come know @ " https://guides.cocoapods.org/using/the-podfile.html " should write code in podefile target 'myapp' pod 'afnetworking', '~> 3.0' end instead of above found @ github afnetworking official dependency installation guide. https://github.com/afnetworking/afnetworking but curious why official afnet

javascript - SequelizeDatabaseError: You need JSON-C for ST_GeomFromGeoJSON when I have JSON-C installed on centos -

i getting following error @ centos server: npm-2 unhandled rejection sequelizedatabaseerror: need json-c st_geomfromgeojson npm-2 @ query.formaterror (/home/centos/jobcue.com/node_modules/sequelize/lib/dialects/postgres/query.js:357:14) npm-2 @ null.<anonymous> (/home/centos/jobcue.com/node_modules/sequelize/lib/dialects/postgres/query.js:88:19) npm-2 @ emitone (events.js:77:13) npm-2 @ emit (events.js:169:7) npm-2 @ query.handleerror (/home/centos/jobcue.com/node_modules/pg/lib/query.js:108:8) npm-2 @ null.<anonymous> (/home/centos/jobcue.com/node_modules/pg/lib/client.js:171:26) npm-2 @ emitone (events.js:77:13) npm-2 @ emit (events.js:169:7) npm-2 @ socket.<anonymous> (/home/centos/jobcue.com/node_modules/pg/lib/connection.js:109:12) npm-2 @ emitone (events.js:77:13) npm-2 @ socket.emit (events.js:169:7) npm-2 @ readableaddchunk (_stream_readable.js:153:18) npm-2 @ socket.readable.push (_stream_readable.js:1

java - (JDBC) Mysql query with if statement and multiple conditions -

what proper syntax mysql-java statement such 1 ? preparedstatement st =connection.preparestatement("select name, value, quantity sales if (type=='purchase' , state=='confirmed') or (type=='sale' , state=='not confirmed')) ; the sql like: select name, value, quantity sales (type = 'purchase' , state = 'confirmed') or (type = 'sale' , state = 'not confirmed');

opengl - Million mesh programatically? -

i have flat surface drawn single fullscreen gl_quad . i want deform surface @ each point specified gl_texture2d , preferably through kind of shader. in mind, black correspond flat , white correspond hill. i want have 4 million points on terrain , update them @ each step in program. how use geometry shader this? shader able generate new veritices? the simplest way generate large triangle strip grid, upload vbo , draw it, using vertex shader alter coordinate. vertex shader can generate normals heightmap (or supply normal map), passed fragment shader lighting. to avoid storing huge amount of data vertices, use glvertexid generate vertex positions scratch in vertex shader. don't bind buffers, call gldrawarrays(gl_triangle_strip, 0, lots). as guyrt mentioned, tessellation shader , allow vary tessellation detail based on camera's distance mesh. more work though.

remove field from tab seperated file using awk -

i trying clean-up tab-delineated files , thought awk below remove field 18 otherinfo file. tried cut , can not seem desired output. thank :). file chr start end ref alt func.refgene gene.refgene genedetail.refgene exonicfunc.refgene aachange.refgene popfreqmax clinsig clndbn clnacc clndsdb clndsdbid common otherinfo chr1 949654 949654 g exonic isg15 . synonymous snv isg15:nm_005101:exon2:c.294a>g:p.v98v 0.96 . . . . . . 1 3825.28 624 chr1 949654 . g 3825.28 pass af=1;ao=621;dp=624;fao=399;fdp=399;fr=.;fro=0;fsaf=225;fsar=174;fsrf=0;fsrr=0;fwdb=0.00425236;fxx=0.00249994;hrun=1;len=1;mlld=97.922;oalt=g;oid=.;omapalt=g;opos=949654;oref=a;pb=0.5;pbp=1;qd=38.3487;rbi=0.0367904;refb=0.0353003;revb=-0.0365438;ro=2;saf=335;sar=286;srf=0;srr=2;ssen=0;ssep=0;sssb=0.00332809;stb=0.5;stbp=1;type=snp;varb=-3.42335e-05;ann=isg15 gt:gq:dp:fdp:ro:fro:ao:fao:af:sar:saf:srf:srr:fsar:fsaf:fsrf:fsrr 1/1:171:624:399:2:0:621:

python - How to read some contents of xml files and write them into a text file? -

i have following xml file, want read contents in <seg> , save them plain text file python. , used dom module. <?xml version="1.0"?> <mteval> <tstset setid="default" srclang="any" trglang="trglang" sysid="sysid"> <doc docid="ntpmt-dev-2000/even1k.cn.seg.txt"> <seg id="1">therefore , can obtained having excellent properties ( stability , solubility of balance of crystal pharmaceutical compound not possible predict .</seg> <seg id="3">compound ( ) preferably crystalline , in particular , has stability , solubility equilibrium , suitable industrial prepared type crystal preferred .</seg> <seg id="4">method b included in catalyst such dmf , , in presence of compound of formula ( ii ) thionyl chloride or oxalyl chloride give acyl chloride , in presence of base of acid chloride alcohol ( iv ) ( o ) reacti

ios - resizing UIPopoverController to fit UITableController -

i have uipopovercontroller has uitablecontroller in it. init elements , want present popover, @ time uitable not know size, cant set size of uipopover also i'm not sure else can set size of uipopover after uitable knows size (i can try hack inside cellforrowatindexpath ugly can any ideas ? i tried define didview* methods, none of them called maybe because view inside popover thanks before show popover, call [table reloaddata] . force table calculate size. use [table contentsize] . also note can calculate size of table yourself. if know data , height of rows/headers/footers, it's simple matter of multiplication & addition.

cassandra - SSTableSimpleUnsortedWriter and column family comparator -

am trying use sstableloader, cf created cql this: create table test ( text, b text, c text, d int, e set<text>, f text, primary key ((a, b) c, d)) how should define column family comparator in sstablesimpleunsortedwriter ? or more specific how work when column defined set ? sstablesimpleunsortedwriter(file directory, ipartitioner partitioner, string keyspace, string columnfamily, abstracttype<?> comparator, abstracttype<?> subcomparator, int buffersizeinmb, compressionparameters compressparameters) you have @ how row stored internally storage engine -- inserting sample data, listing cli, should help, reading http://www.datastax.com/dev/blog/thrift-to-cql3 . the "right"

C++ member function overloading picks wrong function -

msvc throws error c2660 when trying overload global function member function (with different number of arguments) calls global function in it's body. this code: void f(int* x, int y) { *x += y; } struct { int* x; inline void f(int y) { f(x, y); // tries call a::f instead of f } void u(void) { f(5); } }; gives error: error c2660: 'a::f' : function not take 2 arguments use ::f(x, y); use 1 in global namespace.

Apache Nifi processor that acts like a barrier to synchronize multiple flow files -

i'm evaluating nifi our etl process. want build following flow: fetch lot of data sql database -> split chunks 1000 records each -> count error records in each chunk -> count total number of error records -> if exceeds threshold fail process -> else save each chunk database. the problem can't resolve how wait until chunks validated. if example have 5 validation tasks working concurrently, need kind of barrier wait until chunks processed , after run error count processor because don't want save invalid data , delete if threshold reached. the other question have if there possibility run validation processor on multiple nodes in parallel , still have possibility wait until completed. one solution use executescript processor "relief valve" hold simple count in memory triggered off of first receipt of flowfile specific attribute value (store in local/cluster state map of key attribute-value value count ). once value reaches threshol

CTP Installation Error. Install Microsoft System CLR Types for SQL Server 2016 CTP3.2 -

i error: to continue, install microsoft system clr types sql server 2016 ctp3.2 during installation of sql 2016 ctp 3.2. can download clr types sql server 2016 ctp3.2? i had problem too. solution me access link: https://www.microsoft.com/en-us/download/details.aspx?id=52676&wt.mc_id=rss_alldownloads_all click download , in list, search enu\x64\sqlsysclrtypes.msi , reportviewer best regards!

python - can't sum my list because of commas -

i have list of numbers input user. list of random length depending on how many elements user inputs. python sees list (e.g) this: numbers entered are: ['6', '7', '8', '4', '5', '98', '34', '56'] they on list called numlist . i want sum list - tried print(sum (numlist) it won't sum, reckon, because of commas. believe makes them string items not list. so, think have remove commas, turning them list, can sum. i've looked over, can't find solution makes sense me. (sorry i'm quite new this. ) i've experimented strip. map. , int. can't find 1 job. i'm setting code incorrectly someplace. please help. you trying add string elements of list. if want sum of list elements. e.g. if have list a = ['1','2'] 1) convert list elements of a int , assign list b b= [int(i) in ] 2) sum list elements using sum print sum(b)

regex - How to do I write custome apache rules for urls from a view folder and remove the .PHP -

i have literally looked everywhere try , understand apache rules , writing better. trying achieve simple. want leave index.php in root, , each additional page/view want keep them in view directory , views display without .php extension. the second thing trying achieve however, want keep other pages in view folder, , maybe have folders within keep views organized, display url without /view like: something.com/about not somthing.com/views/about lastly, if place folders within view, want decide display like: something.com/about && somthing.com/blog/winners this close have gotten: <ifmodule mod_rewrite.c> rewriteengine on # url renaming rewriterule ^contact$ contact.php [l] </ifmodule> thank in advance! replace existing rule rule: <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{document_root}/view/$1\.php -f rewriterule ^(.+?)/?$ view/$1.php [l] </ifmodule>

javascript - Swift equivalent of '#' + Math.random().toString(16).slice(2, 8) -

the javascript: function randomcolor() { return '#' + math.random().tostring(16).slice(2, 8); } what swift equivalent? i'm assuming uikit here. swift ui typically uses uikit uicolor type represent color. you can use drand48 random color between 0 , 1, convert float , return ui color parameters: func randomcolor() -> uicolor { return uicolor(red: cgfloat(drand48()), green: cgfloat(drand48()), blue: cgfloat(drand48()), alpha: 1.0 ) } update - found online, similar earlier solution - might make sense link here: https://gist.github.com/skreutzberger/32be80e2ebef71dfb793

javascript - Node / JS promises blocked -

new node/js , i'm creating password recovery page exiting portal, searches ad(ldap) , db user has registered. based on results both presents user options auth change pwd when make request ($get()) client find user backend stalls intermittently. see console logging below this console logging attempting find : <account name> found ad user: <account name> in acc prep in sql request in getuserregistration //within auth controller . .here prints results of sql query // @ point expect promise fulfilled. . this time spent doing knows what. completes takes minutes. prints... in sql results the stall seems after calling return auth.getuserregistration(globaluser.sql) within then(). logging auth controller logs results sql query right before should resolved, thereby returning results following then(). don't believe there issue auth controller (which independently works flawlessly) rather within resolve(). perhaps because within promise?. what find interest

iphone - getting a large version of message and mail icon ios -

is there place can ios message , mail app icons? checked in apple developer resources , human interface guidelines couldn't find anything? (i know can use them uiactivityviewcontroller , need them in separate uiimageview well) here link icon package ios 5 used in 1 of apps: http://iconsparadise.com/iphone-free-icons/iphone-4-ios-5-app-icons/ pretty straight forward download. luck.

ios - Swift 2: Update UIImage Dictionary with UIImage() var from UIImagePicker -

i have 2 viewcontrollers. viewcontroller#1 contains uiimagepicker , viewcontroller #2 contains uiimage dictionary variable key. update dictionary array uiimage variable (var newimage = uiimage() )that passed viewcontroller#1.the array expecting string tried converting uiimage array string. confirmed image no luck.any ideas? viewcontroller#1: class viewcontroller: uiviewcontroller,uinavigationcontrollerdelegate,uiimagepickercontrollerdelegate { let imagepicker = uiimagepickercontroller() var images = [uiimage]() var testimage = uiimage() @iboutlet weak var beaconone: uitextfield! @iboutlet weak var beacontwo: uitextfield! @iboutlet weak var backimage: uiimageview! @iboutlet weak var majorid2: uitextfield! @ibaction func pickphoto(sender: uibarbuttonitem) { imagepicker.allowsediting = true imagepicker.modalpresentationstyle = .popover imagepicker.sourcetype = .photolibrary imagepicker.delegate = self s

php - Thymeleaf, table in Javascript -

i use thymeleaf print items(each has 3 values) database, html file is: <!doctype html system "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd"> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="utf-8"/> <title>edycja miejsca</title> </head> <body> <div th:each="items : ${itemslist}"> <div th:object="${items}"> <p th:text="*{id}"/> <p th:text="*{name}"/> <p th:text="*{age}"/> </div> <br/> </div> </body> </html> i try use autocomplete, local static table in javascript, mean: var gifs = [ { value: 'android-explosion', data: 'ae' }, { value: 'ben-and-mike', data: 'bm' }, { value: 'book-dominos', data: 'bd' }, { value: 'compiler-bot', data: 'cb

java - Pass a foreach JSP variable as parameter to javascript function -

i have following code sample written in jsp. not working. have tried code snippet following links. didn't me solve problem. pass jsp variable parameter javascript function passing jsp variable javascript function parameter < c:foreach items="${items}" var="item"> <div onclick="myonclick('<%=item%>')">${item.title}</div> < /c> function myonclick(item){ console.log(json.stringify(item)); } actually getting error in eclipse "item cannot resolved variable" jsp code. i tried below 1 code <div onclick="myonclick(${item})">${item.title}</div> it throwing "syntax error:illegal character" error. need fix issue. thank you. i found answer own following link. how access java object in javascript jsp? that doing in code. getting java objects , mapping them html. once mapped wan unable access them javascript. in above link have provided

import a reg key using CreateProcess & regedit.exe? -

i need simple way import .reg key registery hive how can this? current code looks this: #include<windows.h> int main() { startupinfo startinfo = { sizeof(startupinfo) }; startinfo.cb = sizeof(startinfo); startinfo.dwflags = startf_useshowwindow; startinfo.wshowwindow = sw_hide; process_information processinfo; createprocess("regedit.exe /s c:\\folder\\dd.reg", null , null, null, false, create_no_window , null, null, &startinfo, &processinfo); from commmand line c:\\windows\regedit.exe /s c:\\folder\\dd.reg works fine, doing wrong? ps: dont want use system read documentation createprocess . first parameter name/path of executable; second 1 command line. createprocess(l"regedit.exe", l"/s whatever.reg", ...)

php - Getting user data -

there 2 parts application i've been building. there's website powered cms , there's cms (wrestling manager) goes it. 2 controllers created called frontend , backend use accordingly. frontend controller responsible code needs ran across controllers on website. backend controller responsible code needs ran across controllers on cms. i'm looking ideal way work user data after user logs in again gets directed dashboard extended backend controller. i've heard different solutions example hook. that's 1 i've heard. inheritance friend here you create master controller(front-controller) extends ci_controller you might consider doing spa application, if there many great frameworks achieve this, quite popular 1 angular.js some more useful reading on subject... class my_controller extends ci_controller { protected $currentuser; protected $template; public function __construct() { //you talked hooks //this con

php - Multiple dynamic url redirect in Laravel -

i have looked @ many similar questions bu don't approach real problem. redirect user url after login depending on condition user. i know can archieved middleware have tried in app\http\middleware\redirectifauthenticated.php class redirectifauthenticated { /** * handle incoming request. * * @param \illuminate\http\request $request * @param \closure $next * @param string|null $guard * @return mixed */ public function handle($request, closure $next, $guard = null) { if (auth::user()->check()) { $redirect = '/client'; if (auth::user()->hasrole('admin')){ $redirect = '/admin'; } return redirect($redirect); } return $next($request); } } i realise not work after login. i'd redirect user depending whether he/she admin or client. know use: protected $redirectpath = '/url/to/redirect'; have multipl

javascript - Parsing an xml template using jQuery -

so have template-like script i'm trying parse jquery. issue have tags want replace data, fine, want loop on object properties, makes more difficult. i want rely on external libraries little possible, i'm using jquery here. know angular here don't know yet. the template code looks this: <?xml version="1.0" ?> <div id="test"> <each obj="list"> <div class="listdiv"> <span><value>thing</value></span> <span><value>thing2</value></span> <span><value>thing3</value></span> <div> <each obj="morestuff"> <span>blah: <value>blah</value></span> <span>foo: <value>foo</value></span> </each> </div> </div> &

java - Find number of unique routes to specific node using Depth First Search -

i have directed graph vertexes 123456. using depth first search, if wanted able find number of unique routes 1-4 (for example), how go doing it? here current dfs. private final map<character, node> mnodes; private final list<edge> medges; private list<node> mvisited = new arraylist<>(); int weight; int numberofpaths; public depthfirstsearch(graph graph){ mnodes = graph.getnodes(); medges = new arraylist<>(graph.getedges()); for(node node : mnodes.values()){ node.setvisited(false); } } public void depthfirstsearch(node source){ source.setvisited(true); list<edge> neighbours = source.getneighbouringedges(medges); for(edge edge : neighbours){ system.out.println(edge.getfrom().getname()+"-"+edge.getto().getname()); if(!edge.getto().isvisited()){ mvisited.add(edge.getto()); weight += edge.getweight(); depthfirstsearch(edge.getto()); } }

terminal - Error upgrading Ruby to 1.9.3 on OS X 10.7.5 using zsh - Command not found: rvm -

i've been trying follow tutorial upgrade ruby i'm getting "command not found: rvm" in terminal. ➜ ~ rvm zsh: correct 'rvm' 'rvim' [nyae]? n zsh: command not found: rvm i'm getting stuck after step 2: load rvm shell. i've added [[ -s "$home/.rvm/scripts/rvm" ]] && source "$home/.rvm/scripts/rvm" into .zshrc file additional lines i've found in other answers similar question. file contents now: # path oh-my-zsh configuration. zsh=$home/.oh-my-zsh # set name of theme load. # in ~/.oh-my-zsh/themes/ # optionally, if set "random", it'll load random theme each # time oh-my-zsh loaded. zsh_theme="robbyrussell" # example aliases # alias zshconfig="mate ~/.zshrc" # alias ohmyzsh="mate ~/.oh-my-zsh" # ruby 1.9 __rvm_project_rvmrc alias rvm-promt=$home/.rvm/bin/rvm-prompt # added 2013/09/13 source $zsh/oh-my-zsh.sh [[ -s "$home/.rvm/scripts/rvm" ]] &a

javascript - How to check all collections in Mongo database to find field name exists in which collection -

i have list of field names in file "field_name_list.txt". want know field exists in collection in mongo database using java script or mapreduce job or mongo code. let me give example field_name_list.txt firstname lastname address zip collection in database: personal_data adress i want output below: fieldname collection_name firstname personal_data lastname personal_data address address zipcode address

Heroku Error during websocket handshake 503 -

i'm trying connect websockets in heroku it's saying error during websocket handshake: unexpected response code: 503. error in dev tools 'service unavailable'. server code var wss = new websocketserver({server: app, port:5001}); client code(i replacing port 5001 well) var host = location.origin .replace(/^http/, 'ws') .replace('5000','5001'); var ws = new websocket(host); i've did same in development , managed connect. troubleshoot? thanks. apparently, stupid mistake side. did follow example on here , ok.. basically, omitted part code: // app.listen(config.port, function(){ // console.log("app started on port " + config.port); }); and included instead var server = http.createserver(app); server.listen(config.port);

html - vertically center text in navigation bar -

i trying make navigation bar in buttons' text aligned in center vertically. currently, working fine navigation bar besides vertical align. i have tried many methods such line height, padding top , bottom (messes heights text divs overflow), flex, , table display. html, body { height: 100%; margin: 0px; } #nav { height: 10%; background-color: rgb(52, 152, 219); position: fixed; top: 0; left: 0; width: 100%; color: white; font-family: calibri; font-size: 200%; text-align: center; display: flex; } #nav div { display: inline-block; height: 100%; align-items: stretch; flex: 1; } #nav div:hover { background-color: rgb(41, 128, 185); cursor: pointer; } <div id="main"> <div id="nav"> <div><a>home</a></div> <div><a>page2</a></div> <div><a>page3</a></div> <div><a>page4</a&