Posts

Showing posts from August, 2014

php - Decrypt and Encrypt using CallBack Methods in cakephp -

Image
i want use callbacks methods encrypt value before gets stored in database , decrypt before showing in application. i used 1 of examples provided in documentation . in core.php put following : configure::write('security.ciphercriptkey','su0hksspmdbwgk6ldqlqzp0ymyati7zo'); in model, used 2 methods: beforesave() public function beforesave($options = array()) { $value=$this->data['internship']['encryptedindb']; $encrypted = security::encrypt($value, configure::read('security.ciphercriptkey')); $this->data['internship']['encryptedindb'] = $encrypted; return true; } afterfind() public function afterfind($results, $primary = false) { foreach ($results $key => $val) { if(isset($val['internship']['encryptedindb'])){ $results['internship']['encryptedindb'] = security::decrypt($val['internship']['encryptedindb']...

lazy loading - AngularJs Set controller on Dom at Runtime -

i'm trying set controller on dom object @ runtime: example code here: http://jsfiddle.net/2fl3z/3/ <div id="ctrl1"> <p>{{message}}</p> <a href="#/view1" class="btn">{{btn1}}</a> <a href="#/view2" class="btn">{{btn2}}</a> </div> <div id="ctrl2"> <p>{{message}}</p> <a href="#/view1" class="btn">{{btn1}}</a> <a href="#/view2" class="btn">{{btn2}}</a> </div> /* controller 1 (first.js) */ define([], function () { function firstcontroller($scope) { $scope.message = "i'm 1st controller!"; $scope.btn1 = "ctrl1 btn 1"; $scope.btn2 = "ctrl1 btn 2"; } // reference div#ctrl1 , apply controller it. return firstcontroller; }); /* controller 2 (second.js) */ define([], function () { funct...

php - How to debug (and fix) Symfony2|3 routes? -

i have routes defined @ app/config/routing.yml in symfony 2.8 app: platform_chat: resource: "@platformchatbundle/controller/" type: annotation prefix: /chat platform_admin: resource: "@platformadminbundle/controller/" type: annotation prefix: /admin #----> part of routing.yml forgot add easy_admin_bundle: resource: "@platformadminbundle/controller/admincontroller.php" type: annotation prefix: /admin #fosuser fos_user: resource: "@fosuserbundle/resources/config/routing/all.xml" as may notice platformadminbundle backend , platformchatbundle frontend. having in mind tryin setuo , use 1 firewall both , on security.interactive_login event redirect right route|path. how firewall looks like: security: ... role_hierarchy: role_chatter: role_user role_admin: role_user role_super_admin: role_admin ... firewalls: ... ...

angularjs - Can we put any tag inside tbody of table element in HTML -

i have peculiar use case requires me use 2 ng-repeats. 1 array of dates , contains date in form of associated array argument dates. <tbody> <tr ng-repeat="date in dates"> <!-- <tr ng-repeat="datum in data[date]"> --> <td> {{date}} </td> <td> {{datum.carname}} {{datum.regnumber}}</td> <td> {{datum.drivername}} </td> <td> {{datum.starttime}} </td> <td> {{datum.endtime}} </td> <td> {{datum.trip.sourcename}}</td> <td> {{datum.trip.destinationname}} </td> <!-- </tr> --> </tr> </tbody> now html doesn't allow me use tags inside tbody apart tr , td . know cannot have 2 ng-repeats inside tag workaround ? can insert other tag ? you can repeat <tbody> , repeat <tr> within each <tbody> <tbody ng-repeat="date in dates"> <tr ng-repea...

python - Django database tables not being created -

so have existing project worked on django 1.8 , python 2.7. i've since tried run project under django 1.9 , python 3.5.1... but i'm running problem, tables aren't being created in new database when run python3.5 manage.py migrate here log i'm seeing: [gpsp@localhost gpsp]$ python3.5 manage.py migrate /usr/local/lib/python3.5/site-packages/django/template/utils.py:37: removedindjango110warning: haven't defined templates setting. must before upgrading django 1.10. otherwise django unable load templates. "unable load templates.", removedindjango110warning) /home/gpsp/gpsp/gpsp/urls.py:36: removedindjango110warning: django.conf.urls.patterns() deprecated , removed in django 1.10. update urlpatterns list of django.conf.urls.url() instances instead. url(r'^admin/', include(admin.site.urls)), /usr/local/lib/python3.5/site-packages/django/conf/urls/__init__.py:89: removedindjango110warning: support string view arguments url() deprecated...

html - Setting stroke-width to 0 compatible with Android browser -

i trying set width of stroke 0 using following style: .link { stroke: #6e6e6e; stroke-width: 0px; } this works fine in chrome, safari, , mobile version of chrome on android. however, not work in android mobile browser (the default browser). stroke width comes out 1px instead of 0px. have tried -webkit-stroke-width: 0px; not solve issue. i have encountered bug in older version of chrome, see https://code.google.com/p/chromium/issues/detail?id=15461 two solutions try: stroke: none or stroke-width: 0.000001

javascript - hovering the text for full form -

when mouse hover text below cube..... need display small window text in it.... got text js not sure how integrate hover function.... can tell me how implement it.... providing code below..... when hover on crm should show customer relationship management..... providing code below... hover functionality working fine when hover on text box.... don't know how text below cube...... have included onmouseover , onmouseout functions..... dont know how achieve text below cube $('document').ready(function() { window.settimeout(function() { $('.cubecell').each(function () { var htmltext = $(this).attr('data-text'); $(this).append('<div class="cubetextstyle">' + htmltext + '</div>'); }); }, 600); }); <script type="text/javascript"> function showstock(ii) { var sh = $(ii).parent().find($('.divstock')); ...

foreign keys - Entity Framework - multiple relationships to lookup table -

i'm having difficult time trying map out relationships ef code first. we're creating "lookup" table key value pairs. table has type define type of lookup. these used in number of dropdown lists in app. table have id, name, type. of larger entities may have multiple lookup values. below example. there many many relationship needs exist. public partial class systemdetail : entitydata { public string brandid { get; set; } [foreignkey("brandid")] public lookup brand { get; set; } public string operatingsystemid { get; set; } [foreignkey("operatingsystemid")] public lookup operatingsystem { get; set; } public string batterytypeid { get; set; } [foreignkey("batterytypeid")] public lookup batterytype { get; set; } public icollection<lookup> removablestoragedevices { get; set; } } public class lookup : entitydata { [maxlength(125)] public string name { get; set; } public lookupty...

Google App Engine Monetization with Youtube API -

i run website hosted through google app engine custom youtube search engine. hosted through google app engine . youtube videos embedded website , started run ad page when user first goes website. want comply youtube's terms, curious if in same situation. did have issues youtube? don't want issues , can remove ads if need be. i have been reading tos here : , have read google restrictions adsense (which not running). motionpicker.com site.

ios - Detect tap on image view -

Image
i building app, have image , want action happen when tap on image. have set of design, changing image view button image lot of work. is there way constrain button same size image, , @ same place? set image view's userinteractionenabled true , add uitapgesturerecognizer image view. you can in storyboard checking “user interaction enabled” checkbox, dragging tap gesture recognizer onto image view, , connecting tap gesture recognizer action in view controller.

Which PHP date formatting is this Mon Jun 27 13:59:36 +1000 2016 -

as topic says, i'm looking date() markup of mon jun 27 13:59:36 +1000 2016 i've got far not getting + in front of forelast parameter. date("d m d h:i:s z y"); which generates this: fri jan 15 22:13:23 3600 2016 but guess need + in order able compare future date like: mon jun 27 13:59:36 +1000 2016 any hints highly appreciated! use o rather z outlined here: http://php.net/manual/en/function.date.php echo date("d m d h:i:s o y");

javascript - How to refresh the page between window widths 480px to 768px? -

i using code: // resize when less 768 $(document).ready(function(){ $(window).on('resize',function(){ if ($(window).width() < 768) { location.reload(); // refresh page } else { // width greater 768px pc } }); }); but reloads page when browser resized less 768px. possible have code reloads page on resize when browser say, between 480px , 768px? thanks! yes, of course: // resize when less 768 $(document).ready(function(){ $(window).on('resize',function(){ if (($(window).width() > 480) && ($(window).width() < 768)) { location.reload(); // refresh page } else { // width greater 768px pc // or width smaller 480 mobile } }); });

mapreduce - Hadoop Reduce side what is really occurred? -

Image
i'm reading "hadoop: definitive guide" , have questions. in chapter 7 "how mapreduce works" on page 201, author said in reduce side when [a] in-memory buffer reaches threshold size (controlled mapreduce.reduce.shuffle.merge.percent ) or [b] reaches threshold number of map outputs ( mapreduce.reduce.merge.inmem.threshold ), merged , spilled disk. my questions (4 questions) conditions a , b . in condition a default values config hadoop 2 that will 0.462(0.66 * 0.70) of 1gb memory reducer full (462mb), merge , spill begin? in condition b default values config that when 1000 pairs of key-value map output 1 mapper have been collected in buffer, merge , spill begin? in above question 1 mapper correct or more 1 mapper different machine? in following paragraph, author said that as copies accumulate on disk, background thread merges them larger, sorted files it correct intended purpose when spill file wants write disk before spi...

c# - Why won't my datatable populate -

i have searched long time , can't find i'm doing wrong. i have web app uploads spreadsheet (verified works) , supposed parse spreadsheet , populate gridview. seems simple enough, won't display data. the spreadsheet i'm testing (as upload; upload works expected) simple single tab spreadsheet boring vanilla... 3 columns column names 1 row of data (two populated rows total, destined expanded once thing works). tab name crprlist used in oledbdataadapter below. i'm getting no errors on page, gridview not populate. here's gridview in asp.net: <asp:gridview id="topicstbl" runat="server" allowsorting="false" allowpaging="false" autogeneratecolumns="false"> <columns> <asp:boundfield headertext="cr" datafield="cr" /> <asp:boundfield headertext="pr" datafield="pr" /> <asp:boundfield headertext...

java - Eclipse will not start and I haven't changed anything -

i haven't updated @ least month. working , menus blank, decided restart eclipse. clicked "close" , "ok" save everything, nothing happened, clicked close again , eclipse closed. clicked on eclipse , loading screen flashes , disappears followed message telling me check .log file. i've since restarted pc multiple times, tried running in safe mode , ran eclipse.exe -clean , nothing works. any ideas? !session 2013-03-12 13:46:10.078 ----------------------------------------------- eclipse.buildid=i20120608-1400 java.version=1.7.0_07 java.vendor=oracle corporation bootloader constants: os=win32, arch=x86_64, ws=win32, nl=en_us framework arguments: -product org.eclipse.epp.package.jee.product command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product -clean !entry org.eclipse.ui 4 4 2013-03-12 13:46:55.800 !message internal error has occurred. !stack 0 java.lang.nullpointerexception @ org.eclipse.ui.intern...

windows runtime - Retrieving all files with GetItemsAsync without having to specify file types -

i'm trying list of files winrt device following code: var folder = knownfolders.documentslibrary; var items = await folder.getitemsasync(); this returns list of folders , files. problem file list contains files extensions have added package.appxmanifest is there way retrieve files? * . * ? i don't think there's direct way it. according this article can done pictures, music , videos library not documents library you must add file type associations app manifest declare specific file types app can access in location. if user select folder folderpicker , access items, though: var picker = new folderpicker(); picker.filetypefilter.add(".txt"); var folder = await picker.picksinglefolderasync(); var items = await folder.getitemsasync(); it enough user once. can add folder futureaccesslist , store token returns: var token = storageapplicationpermissions.futureaccesslist.add(folder); when user runs app next time can use token acces...

.htaccess - Unable to remove index.php in Codeigniter -

i want remove index.php access controllers directly. however, cannot directly go controller. have use index.php. example: want go http://example.com/my_controller/method instead of http://example.com/index.php/my_controller/method by way, used test server, not local server xampp. enabled apache mod rewrite in server. i tried lot of htaccess rules, conditions cannot work it. please me! this .htaccess file: <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php/$1 [l] </ifmodule> my config.php: $config['index_page'] = ''; $config['uri_protocol'] = 'request_uri'; how can go directly? how verifying mod_rewrite enabled. follow instructions here: how check whether mod_rewrite enable on server?

batch file - Is Windows %ERRORLEVEL% == $? in Linux -

trying hands on windows batch files, in below code found searching in www. @echo off rem call 2 arguments, , add them. set a=%1+%2 if %errorlevel%==0 (goto errors-0) else (goto errors-1) rem instead of using goto variable, uses if-else structure :errors-0 rem if successful echo %a% goto exit :errors-1 rem if had error: echo errors occurred. goto exit rem guess what, rem never ever read! skipped on gotos :exit echo. echo press key exit. pause>nul the code suppose take 2 arguments, add them , echo result. but won't execute success on windows 8.1 machine. below get: c:\projectdoc>add3.bat errors occurred. press key exit. so, u added echo errorlevel see value after executing command set . below output: c:\projectdoc>add3.bat 2 3 9009 errors occurred. press key exit. c:\projectdoc> so, errorlevel in windows equal $? of linux. should returning 0 every successful execution of command or different? reading docs relates linux $? isn't working $? in ...

Postgresql function doesn't work properly -

why function returning half zip codes? i mean if insert address(zip_code) values(99-100) it's doesn't work properly, because it's adding "99-". create function normalize_zip_code() returns trigger $$ begin if length(new.zip_code)<=4 , length(new.zip_code)>=6 raise exception 'wrong zip code!'; elsif length(new.zip_code)=6 , (substring(new.zip_code, 3, 1)='-') new.zip_code:= concat((substring(new.zip_code, 1, 2))::varchar(2),(substring(new.zip_code, 3, 1))::varchar(1), (substring(new.zip_code, 3, 5))::varchar(3)); return new; else new.zip_code := concat((substring(new.zip_code, 1, 2))::varchar(2),'-' (substring(new.zip_code, 3, 5))::varchar(3)); return new; end if; end; $$ language plpgsql;

ios - Swift get textbox value surounded by optional() -

my viewcontroller / mark: properties @iboutlet weak var textinput: uitextfield! @iboutlet weak var labeltop: uilabel! override func viewdidload() { super.viewdidload() textinput.delegate = self } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } // mark: uitextfielddelegate func textfieldshouldreturn(textfield: uitextfield) -> bool { textfield.resignfirstresponder() return true } func textfielddidendediting(textfield: uitextfield) { if (textinput != nil){ labeltop.text = "searching \(textfield.text)" textinput.enabled = false } } when press return on textfield code labeltop.text = "searching \(textfield.text)" is called. text of labeltop looks like: searching optional("the text") i looked @ optionals (most times use ? instead of ! right?) not understand how should value without surro...

javascript - Calculate text size before inserted to DOM -

is possible calculate height of text before inserted dom? width of div container known, need way calculate height before inserted. heights of 1 line of text known (css), height calculated multiplying height of 1 line amount of lines, question if possible calculated before it's dom. since question explicitly requires text not inserted dom precludes used method of inserting outside viewport , measuring there. an alternative approach: canvas 2d rendering context's measuretext function can used determine width if know styling (font width) apply in advance. some advanced css rules such letter-spacing may make results inaccurate.

mysql - unable to connect to system bus: failed to connect to socket /var/run/dbus/system_bus_socket -

i started use new vps system ubuntu 12.04 after following commands here installed php, mysql, apache2 php , apache working great when run : service mysql start i : unable connect system bus: failed connect socket /var/run/dbus/system_bus_socket: no such file or directory. i googled didn't find enough me. there no /var/run/dbus/ directory , don't know need create 1 or if problem mysql. i had error message , discovered sign initctl (the ' init daemon control tool ') being called (indirectly) without necessary privileges. in other words: it failed because: i not logged in root user, nor prefixing 'daemon control' command sudo . either 1 have solved issue. it's bit confusing because have thought 'privilage issue' trigger error message talks 'privilage thangs'. but, no. talks being "unable connect system bus". so, may suggest: try temporarily elevating privileges prefixing command sudo . as...

Laravel admin/user route prefix approach -

so have make system transport management. user can log in create/update/edit trips. admin can same users. have divided user , admin in route prefixes: route::group(['prefix' => 'admin/', 'middleware' => ['auth','admin']], function(){ route::resource('trips', 'tripscontroller', array('except' => array('show')));} route::group(['prefix' => 'user/', 'middleware' => ['auth', 'user']], function(){ route::resource('trips', 'tripscontroller', array('except' => array('show'))); } the problem in every method of tripcontroller have pass route variable correct url (the admin request have 'admin' prefix, , users have 'user' prefix) return view('trips.index', compact('users', 'route')); the question there way nicely or should pull trips route::resource out of both groups...

python - How to serve a static webpage from falcon application? -

i new python , hence falcon. started developing restful api , falcon far great it. there other requirement serve static web page , dont want write app or spawn server that. is possible falcon app serve static web page? first , important, have don't want that. should have nginx server on top of falcon app, , serve static file directly nginx (and redirect api calls falcon). this being said, can serve static files falcon. code looking for: import falcon class staticresource(object): def on_get(self, req, resp): resp.status = falcon.http_200 resp.content_type = 'text/html' open('index.html', 'r') f: resp.body = f.read() app = falcon.api() app.add_route('/', staticresource()) you may want set file name parameter in url, , in resource, static resource can serve requested file directory.

javascript - Firefox randomly close XMLHttpRequest connection if inactive. Why? -

in javascript class, xmlhttprequest connect server. server sending data, slowly. work fine in chromium, firefox close connection after random time (between ~4s , ~70s). why firefox close connection? , how avoid that? simplified js code: var options = {}; options['header']= { 'cache-control':'no-cache, max-age=0', 'content-type': 'application/octet-stream', 'content-disposition': 'inline' }; // request information this.http = new xmlhttprequest(); this.http.onreadystatechange = _streamingresponse.bind(this); this.http.open('post', url, true); (var in options['header']) { this.http.setrequestheader(i, options['header'][i]); } this.http.send(''); for php part, like: sleep(200); //wait long time, firefox close socket. if server send every few seconds (<5s) connection stay alive "forever...

java - Determine if an instance of a service is running and kill it -

i have android service, let's "service.java" i start instance , pass unique id each instance of service start (so don't have 2 service same uid running @ same time): intent intent = new intent(this, service.class); intent.putextra("key", uid); startservice(intent); say set variable in "service.java" uid: private string uid; @override public int onstartcommand(intent intent, int flags, final int startid) { super.onstartcommand(intent, flags, startid); if(intent != null) { bundle infobundle = intent.getextras(); this.uid = infobundle.getstring("key"); } ... } public string getuid() { return this.uid; } is there way somehow check if instance of "service.java" running given uid , kill it? i have list of key/value pairs want start instances of service @ specific times of day, if user "disables" time slot (key/value pair), want service stop. backstory: i have application...

loops - Making sure values do not get overwritten in Matlab -

i modelling spread of disease , want make image plots first time infection occurs in pixel of matrix. so got this: for t=1:30 infected=calc_infected(susceptibles, disease, row, col); if t < 8 % infection occurs in first week in these pixels lm(find(infected > 0))= 2 elseif t>=8 && t<15 % infection occurs in second week in these pixels lm(find(infected > 0))= 3; elseif t>=15 && t<22 lm(find(infected > 0))= 4; elseif t>=22 && t<30 lm(find(infected > 0))= 5; end t time in days. lm map on plot data. infected matrix contains temporal evolution of infection. question is: want show time first infection occurs, how can make sure value pixel not overwritten when becomes infected second time, within time classification? e.g. if pixel has value of 2 because got infected...

arrays - Optimum Way To Write Long Javascript Variables containing HTML -

hi guys i'm working on web app outputs heap of html , objects onto html page via javascript. its looking quite messy , made me wonder - optimum way write , why. this code var html_content = ''; html_content += "<div class='body-content'>"; html_content += "<h1>" + wowarr.name +"</h1><br />" + "<h2> arena titles (account wide)</h2>" + achievementz.join('<br />') + "<br /><br />" + "<h2>highest arena ratings</h2>" + "<span style='color: #ffffff;'>"+rating2v2.name+"</span>" + ": " + rating2v2.quantity + "<br/>" + "last reached on: " + gethighestdate(rating2v2) + "<br/><br/>" + "<span style='color: #ffffff;'>"+rating3v3.name+"</span>...

python - Unable to install older wxPython within virtualenv (Cannot unpack file / Cannot determine archive format) -

within virtualenv built off python 2.6.6, i'm trying pip install 2.8.10.1 2.6 unicode dmg found here thus: pip install -iv http://sourceforge.net/projects/wxpython/files/wxpython/2.8.10.1/wxpython2.8-osx-unicode-2.8.10.1-universal-py2.6.dmg/download granted, url bit of guess. i (dividing log in two): macbook-pro-de-pyderman:pyderman$ pip install -iv http://sourceforge.net/projects/wxpython/files/wxpython/2.8.10.1/wxpython2.8-osx-unicode-2.8.10.1-universal-py2.6.dmg/download -u --trusted-host sourceforge.net collecting http://sourceforge.net/projects/wxpython/files/wxpython/2.8.10.1/wxpython2.8-osx-unicode-2.8.10.1-universal-py2.6.dmg/download starting new http connection (1): sourceforge.net "get /projects/wxpython/files/wxpython/2.8.10.1/wxpython2.8-osx-unicode-2.8.10.1-universal-py2.6.dmg/download http/1.1" 302 519 starting new http connection (1): downloads.sourceforge.net "get /project/wxpython/wxpython/2.8.10.1/wxpython2.8-osx-unicode-2....

ios - Admob is crashing but very rare -

Image
usually ios app works fine. crashes. attached screenshot. called functions show admob interstitial. crashed. not sure how debug , why crashed time. code works fine of time crashes. my app uses arc. it iphone open gl es 2.0 game admob , iad how debug it? steps should done? i not sure when see such crash next time. crashes happen not often. if remove components iad , test not know when crash , how many tests run ensure removed part coursing problem or not. i not wish submit app sometime crashes. may course bad reviews. update crashes @try/@catch not helping. delegate update not helping either. i got such crash again , have no idea can or coursing it. wrap call try/catch.

Put Special words and symbols into an element with jquery -

i have text combine persian language , html elements , english words. want engilsh words , other symbols like( <> ) inside paragraph not other element(like pre) placed span tag. how jquery? before: در این قسمت تمرکز ما بر linq objects است که در پرس و جوی مجموعه ای از اشیاء در کد شما که رابط ienumerable<t> را پیاده سازی می کنند مورد استفاده<imge src="wp/contet/image.png"> قرار می گیرد. after: در این قسمت تمرکز ما بر <span>linq objects</span> است که در پرس و جوی مجموعه ای از اشیاء در کد شما که رابط <span>ienumerable<t></span> را پیاده سازی می کنند مورد استفاده<imge src="wp/contet/image.png"> قرار می گیرد. i use code $("p").each(function (){ var current_element = $(this); var old_value = $(this).text(); old_value = old_value.replace(/([a-za-z]+)/g, "<span>$1</span>"); current_element.html(old_value);}); but image hidden!

angularjs - angular $http.get error, unexpected token -

i starting test simple api using code: $http.get('/api/products?limit=10').then(function (response) { console.log(response.status); }); and error: syntaxerror: unexpected token { @ object.parse (native) @ fromjson ( http://localhost:8000/bower_components/angular/angular.js:1271:14 ) @ defaulthttpresponsetransform ( http://localhost:8000/bower_components/angular/angular.js:9460:16 ) @ http://localhost:8000/bower_components/angular/angular.js:9551:12 @ foreach ( http://localhost:8000/bower_components/angular/angular.js:340:20 ) @ transformdata ( http://localhost:8000/bower_components/angular/angular.js:9550:3 ) @ transformresponse ( http://localhost:8000/bower_components/angular/angular.js:10319:21 ) @ processqueue ( http://localhost:8000/bower_components/angular/angular.js:14792:28 ) @ http://localhost:8000/bower_components/angular/angular.js:14808:27 @ scope.$eval ( http://localhost:8000/bower_compon...