Posts

Showing posts from August, 2014

Primefaces datatable rowReorder get row -

i'm trying row object, in case of class story.class, while reordering row in primefaces datable. indexes, reorderevent, unfortunately not enough since have more 1 datatable reuse same rowreorder listener. here code fragments: <p:ajax event="rowreorder" listener="#{reorderstoryview.onrowreorder}" /> the following code line returns null: story story2 = context.getapplication(). evaluateexpressionget(context, "#{story}", story.class); the following code line returns not current rowdata, have problems determine row data get: story story =(story)((datatable)event.getcomponent()).getrowdata(); can't find additional information problem, maybe can me out. thx in advance /d you can read source table adding line listener code: string source = ((datatable)event.getsource()).getclientid(); an example listener method: public void onrowreorder(reorderevent event) { int = event.getfromindex(); ...

c# - Unexpected behavior using Enumerable.Empty<string>() -

i expect enumerable.empty<string>() return empty array of strings. instead, appears return array single null value. breaks other linq operators defaultifempty , since enumerable not, in fact, empty. doesn't seem documented anywhere, i'm wondering if i'm missing (99% probability). gameobject class public gameobject(string id,ienumerable<string> keywords) { if (string.isnullorwhitespace(id)) { throw new argumentexception("invalid", "id"); } if (keywords==null) { throw new argumentexception("invalid", "keywords"); } if (keywords.defaultifempty() == null) { //this line doesn't work correctly. throw new argumentexception("invalid", "keywords"); } if (keywords.any(kw => string.isnullorwhitespace(kw))) { throw new argumentexception("invalid", "keywords"); } ...

netlogo - Ask turtles to move to patch that is their state variable -

in model, have turtles start @ random location. location saved state variable home-xy using patch-here command. stored format (patch 234 345) . want turtles return location @ end of procedure. i've tried following 2 pieces of code: ask turtles [ move-to home-xy ] ask turtles [ let x [pxcor] of home-xy let y [pycor] of home-xy move-to patch x y ] these not work, think represent problem enough. thank you. not sure why first code didn't work. tested , it's fine (returns centre of patch started): turtles-own [home-xy] setup clear-all create-turtles 20 [ setxy random-xcor random-ycor set home-xy patch-here ] reset-ticks end go ask turtles [ setxy random-xcor random-ycor ] end go-home ask turtles [ move-to home-xy ] end you might want inspect turtle , make sure home-xy being set properly.

php - mb_stripos not working with accented characters -

i'm trying make mb_stripos work accented characters can't find way it. $word = "leilao"; $text = "leilao leilões lllleeil"; $result = mb_stripos($text, $word); //works $word = "leilão"; $text = "leilão leilões lllleeil"; $result = mb_stripos($text, $word); //doesn't works i checked mb_internal_encoding() , set utf-8 can me? what need search in long text if array of keywords exists , return true. need accented character found aswell. there way it? thanks in advance! [update] i found problem. i'm trying text database,and set utf8. //after query assign this: $text = $rows[0]["description"]; if use mb_detect_encoding result ascii encoding. , there no function change that! tried all, iconv , mb_convert_encode , utf8_encode , result ascii . , need match accented characters/words result 0.

r - How to read logical data with header from file -

i want read following table #logical.table col_a col_b row_a true false row_b false true the resulting object in r should have column , row names file(at least 1 of them) , logical columns , rows i tried: matrix(ncol=2, byrow=t, scan(file = 'logical.table', what=true, skip=1)) miss col/row-names. deleting rownames, w<-read.table(file='logical.table', colclasses = "logical", header=t) is.logical(w[1]) , is.logical(w[1,]) return false solution derwin mcgeary wrote: x <- read.table(file="logical.table") works fine. logical columns use x[,col] , logical rows ended t(x)[,row] . the function read.table smart enough read file , give appropriate row , column names. x <- read.table(file="logical.table") str(x) cut , pasted example including line #logical.table , still worked.

java - Loading information from file in different ways -

my program has working: bank bank = new bank(); bank.openaccount(new checkingaccount(10100, new customer("first", "last"),500.00,false)); bank.openaccount(new checkingaccount(10101, new customer("first", "last"),2000.00,true)); bank.openaccount(new savingsaccount(2010, new customer("first", "last"),5000.00,0.02)); now trying load information file instead, ran bit of wall. want new customer information include both first , last name stored in separate index positions separate variables, while work: new customer[first_index], i can't seem accept 2 index positions without creating new customer again. turn causing issue method in accounts i'd keep same format. how can go doing this? public checkingaccount(int accountnumber, customer owner, double currentbalance, boolean freechecks) { super(accountnumber, owner, currentbalance); this.freechecks = freecheck...

gcc - GNU assembly Inline: what do %1 and %0 mean? -

i new gnu assembly inlining, have read multiple write ups still not understand going on. understanding: movl %eax, %ebx\n\t move whatever in %eax ebx , not add contents each other addl %eax, %ebx\n\t add contents of %eax ebx , keep @ right register addl %1, %0\n\t confused, adding 1 , 0? why need have %0 there? the whole asm inline block looks like: asm [volatile] ( assemblertemplate : outputoperands [ : inputoperands [ : clobbers ] ]) or asm [volatile] ( assemblertemplate : outputoperands) in assemblertemplate assembly code, , in output/inputoperands, can pass variable between c , asm. then in asm, %0 refers first variable passed outputoperand or inputoperand, %1 second, etc. example: int32_t = 10; int32_t b; asm volatile ("movl %1, %0" : "=r"(b) : "r"(a) : ); this asm code equivalent "b = a;" a more detailed e...

c# - DbSet doesn't contain definition for FirstOrDefault? -

i migrated existing project .net 4.5 , changed out project using data access (switching entity framework). for reason time try access functions dbset ( where , first , firstordefault , etc) throws error: error 53 'system.data.entity.dbset 1<myproject.data.customer>' not contain definition 'firstordefault' , no extension method 'firstordefault' accepting first argument of type 'system.data.entity.dbset 1' found (are missing using directive or assembly reference? this uses .net 4.5 , read these functions no longer in system.linq stored in system.core. have added reference system.core project still getting error. there using statement system.linq, not system.core. can see why getting error? suggestions on how fix? update: this line throws error: vimodel db = new vimodel(); customer = db.customers.firstordefault(c => c.customerid == customerid && c.isprimary); and dbcontext: public partial class vimodel ...

ruby on rails - Mailer not working on column update -

i have mailer sending out email every time change column balance user via admin platform @ adminium. can change column via adminium , saves fine , changes in db email doesn't send. user.rb after_update :balance_has_changed? def balance_has_changed? if balance_changed? # balance # balance_was # send email! usermailer.balance_changed(self, balance, balance_was).deliver end end handle_asynchronously :balance_has_changed? usermailer def balance_changed(user, new_balance, old_balance) mandrill_mail( template: 'balance_changed', subject: 'new earnings through bundel!', to: { email:user.email }, vars: { 'old_balance' => old_balance, 'new_balance' => new_balance } ) end using mandrill mailchimp - template uploaded mandrill no errors side. any brilliant. how similar / different adminium gems such rails_admin o...

ios - VoiceProcessingIO while using AVPlayer -

i'm working on application has unusual requirements. we're trying record sound microphone while playing video file user. worked great using avcapturesession record microphone , avplayer play video - except capture session recorded video sound , got terrible feedback/echo. we next tried use remoteio voiceprocessingio subtype record audio , suppress echo. worked great - except there no sound coming avplayer. is possible use audiounit record sound while playing video (with sound) on avplayer , cancel echo? nb: did find this question has contradicting answers.

Override UserId in Segment Analytics -

basic question here related segment analytics. unfortunately haven't been able find answer after fair bit of searching turning here. i have couple of analytics events need logged against multiple users, e.g. "matched" is there way override "userid" property on event without calling identify again (which override user future events & risks race conditions or blocking on analytics)? this not possible analytics.js . if need send events userid 1 had called .identify() with, should use server side library send event. all server side libraries need userid defined place send particular event. also segment got brand new community post these questions fyi.

python - Column and row dimensions in OpenPyXL are always None -

why openpyxl reading every row , column dimension none? case regardless of whether table created via openpyxl or within microsoft excel. import openpyxl wb = openpyxl.load_workbook(r'c:\data\mytable.xlsx') ws = wb.active print ws.row_dimensions[1].height print ws.column_dimensions['a'].width prints none , none. these aren't hidden columns/rows. have dimensions when viewed in excel. i know loading workbook iterators prevent dimension dictionaries being created, results in key errors, , i'm not using iterators here. is there alternative way determine width/height of cell/row/column? ===============solution================= thanks charlie, realized following best way list of row heights: import openpyxl wb = openpyxl.load_workbook(r'c:\data\test.xlsx') ws = wb.active rowheights = [ws.row_dimensions[i+1].height in range(ws.max_row)] rowheights = [15 if rh none else rh rh in rowheights] rowdimension , columndimension objects exist...

html - Why does Chrome show nothing but div tags when I view the dom elements for an Ext JS app? -

Image
i thought of ext js objects translate directly non-div html tags. why <div> in element view when viewing app in debug mode? never see <button> , <img> , <a> or other usual html tag. for clarification: here example how textfield looks like. inside of divs, tables, etc. there input component. use "magnifier" tool fined precise component interested in. actual question or problem?

running docker request from php -

i have encapsulated pdftk (pdf tool kit) program can run inside of fedora docker image. allows me run pdftk on newer aws ami image not support pdftk. when replacing pdftk in our php program docker run command, works great when running php program command line, when running cron job or mailbox command, docker not run. have made cron , mailbox users part of docker group, checked permissions , paths, still no joy. the exec php command looks like: $command = 'docker run -i -t --privileged -v /var/www/mbx/forms/inbox:/workdir -w /workdir/ brnlab/aultman-pdftk ./'.basename($files[$i]).' burst output ./pg_%03d.pdf'; oddly return on $command when running cron or mailbox command blank, not sure if there error or not. not appear hang up. ideas on best way diagnose issue further?

C++ display cURL progress meter during download -

i going attempt display progress meter during curl download using system() command. following method, char command[] = "curl -c cookies.txt -b cookies.txt -k https://www.example.com/data/format/json' > ~/location/file.json"; system( command ); the progress meter ( pretty seen here ) printed stdout, need somehow capture display in app. code halted @ system() command until download finished, don't seem have way of doing in code while curl command downloading. so i'm wondering if i'm missing magical curl option , if there alternatives or methods system() may have missed, or if has other helpful pointers how progress meter may piped stringstream in real-time, or that. mac 10.8.5

python 3.x - Django creating aliased query outputs -

in question, working query gave output: [{ 'type': 'o', 'count': 54},{ 'type': 'e', 'count': 125},{ 'type': 'c', 'count': 2}] one of respondents asked why didn't shortcut this: { 'o': 54, 'e': 125...} while original question nicely answered pure genius, thought of persons input still in mind. how "alias" field in query such as: models.subscription.objects.values("subscription_type").annotate(c=count("subscription_type")) to genius recommending? thanks you can transform data in python this: result=[{ 'type': 'o', 'count': 54},{ 'type': 'e', 'count': 125},{ 'type': 'c', 'count': 2}] result_as_dict=dict([(type_and_count['type'], type_and_count['count']) type_and_count in result]) print(result_as_dict) maybe there solution in django orm. don't k...

c# - Split a string with '[' and ']' -

i know regex split pattern (using c#) string packed [ , ] . for example, string: this [word1] , [word2] i should word1 , word2 . the following should trick: \[(?<word>[^\]]*)\] i suggest use regex tool assist you. i'm sure there couple use expresso , helps these pesky things :)

asp.net - Uploading digital products with size more than 5MB in nopCommerce results "Upload failed" error -

i have shop digital products built nopcommerce (a famous eccommerce software). uploading digital products size more 5mb results "upload failed" erro, solution? first of all, check nopcommerce setting catalogsettings.fileuploadmaximumsizebytes . second can try edit web.config folows <system.webserver> <security> <requestfiltering> <requestlimits maxallowedcontentlength="52428800" /> <!--50mb--> </requestfiltering> </security> </system.webserver>

Polymer force narrow forceNarrow is not working -

i trying use forcednarrow=true paper-drawer-panel. page not responding. here code. apparently none of other api working. there solution problem? have tried restructuring web page. feature seems cannot accessed. <paper-drawer-panel forcednarrow='true'> <paper-header-panel main navigation flex> <paper-toolbar id='mytoolbar'> <div id='company_name'>kurier </div> </paper-toolbar> <paper-toolbar id='secondary'> <paper-icon-button icon="menu" paper-drawer-toggle on-tap="menuaction" ></paper-icon-button> <paper-button raised>login</paper-button>" <paper-button raised>sign up</paper-button> </paper-toolbar> <div id='signup'> <form method="get" action="{% url 'transport:index' %}"> ...

php - Woocommerce Product Navigation should not show next category -

i using woocommerce plugin , have woocommerce product navigation link plugin navigate inside products... i want have show product navigation inside category.. showing navigation products.. i.e., if 1 category completed showing navigation button next product in next category.. here code have in woocommerce-product-navigation.php file .. here's eval what mistake doing , can ? $output = '<div class="wpn_buttons ' . $wpn_custom_class .'">'; if ( $previous != '' ) $output .= '<span class="next"> ' . $previous . '</span>'; if ( $next != '' ) $output .= ' <span class="previous">' . $next .'</span>'; $output .= '</div>'; i think should consider hooks , write function filter contents if category changed exit .i guess should use woocommerce_before_single_product hook .

c# - Session Expired in selenium IE webdriver -

i have secured site need scrape data particular pages. page should opened strictly on ie. opened login page selenium , pass handle webdriver. user surfs various pages , pop ups of website. timer runs , checked whether particular page opened or not. being checked following code. var windowiterator = driver.windowhandles; foreach (var windowhandle in windowiterator) { popup = driver.switchto().window(windowhandle); if (popup.title == pagetitle) //pagetitle string value , saved in app config { dowork = true; //scraping started on page break; } } it working other sites in testing environment. in live environment pop page displaying session expired message , asking user credentials. once given working fine. architecture of website being scraped unknown me. could body tell me why happening , way out. possibly takes of time scrap data before page updated/changed. i believe site give browser one-session-cookes. check of cookies s...

How to do a zpl batch printing -

i able print labels sending zpl commands printer. how batch printing of zpl labels programatically. suppose if have multiple labels printed in single printjob. you should able send labels single zpl command string. just ^xz command end current label , ^xa start next one.

java - memory leak due to Oracle JDBC driver(ojdbc6-11.2.0.jar) on OpenShift/jbossews/Tomcat7.x -

i using openshift/jbossews(tomcat-7) , spring 4.x & oracle 11g(ojdbc6-11.2.0.jar) database connectivity configured using tomcat jndi datasource. when try re-deploy code(war) using ci(jenkin build)..in application oracle classes gives memory leak notification in server logs. did faced type of issue ,please me clear severe error. there can clean these? openshift tomcat server logs:- sep 30, 2015 1:35:12 org.apache.catalina.core.standardservice startinternal info: starting service catalina sep 30, 2015 1:35:12 org.apache.catalina.core.standardengine startinternal info: starting servlet engine: apache tomcat/7.0.54 sep 30, 2015 1:35:13 org.apache.catalina.startup.hostconfig deploywar info: deploying web application archive /var/lib/openshift/546d3268d14ee9564d002626/app-root/runtime/dependencies/jbossews/webapps/root.war sep 30, 2015 1:35:34 org.apache.tomcat.jdbc.pool.datasourcefactory performjndilookup warning: name "jdbc/dmdatas...

c++ - Forwarding cv-ref-qualifier for member functions -

if there no overloadings (say, f(t &) or f(volatile t &&) ) of (member) function template template< typename t > f(t &&); , t && so-called forwarding reference , , t either u , or u & cv-qualified type u . cv-ref-qualifiers of member functions there no such rule. in struct s { void f() && { ; } }; s::f() has rvalue-reference qualifier. in generic code useful avoid definition of 4 (or 8, if consider volatile qualifier) overloadings of member function, in cases if of them doing same thing. another problem arises in way, impossibility define effective cv-ref-qualifier of *this in particular sense. following code not allows 1 determine whether ref-qualifier of member function operator () && of & . #include <type_traits> #include <utility> #include <iostream> #include <cstdlib> #define p \ { \ using this_ref = d...

php - verification register with email using codeigniter -

i tried project verification email there obstacles . when submit data registers error . please give explanations on coding me , went wrong ..... ...... please explanations controllers : <?php defined('basepath') or exit('no direct script access allowed'); class register extends ci_controller { public function __construct(){ parent::__construct(); $this->load->model('m_register'); } public function index() { $this->load->helper('form'); $data = array ( 'isi' => 'login/vregister'); $this->load->view('layout/wrapper',$data); } function submit() { //passing post data dari view $_post['dob'] = $_post['year'].'-'.$_post['month'].'-'.$_post['day']; $firstname = $this->input->post('firstname'); $lastname = $this->input->post('lastname'...

send data using controller in app.blade laravel 4 -

i have usercontroller , want send data usercontroller function app.blade.php . function sessionuser(){ $data['status'] = auth::user()->status; $data['id'] = auth::id(); $data['values]=db::table('user_permission)->get(); return view('app.blade', compact('data')); } and in app.blade.php dd($data); try it: function sessionuser(){ $data['status'] = auth::user()->status; $data['id'] = auth::id(); $data['values']=db::table('user_permission')->get(); return view('app')->with($data); } or function sessionuser(){ $status = auth::user()->status; $id = auth::id(); $values = db::table('user_permission')->get(); return view('app', compact('status','id','values')); } then echo dd($status);

android - How to change background color of custom view placed in actionbar? -

what did view v=getlayoutinflater().inflate(r.layout.action_bar, null); v.setbackgroundresource(r.color.primary_color); actionbar.setcustomview(v); everything worked fine how again change color of custom view below statement not working why. getactionbar().getcustomview().setbackgroundcolor(color.parsecolor("#3f51b5"));

The site doesn't appear in python requests -

check code below, think there wrong cookie because when pass browser's cookie works. import requests header = { 'accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'accept-encoding':'gzip, deflate, sdch', 'accept-language':'en-us,en;q=0.8', 'cache-control':'max-age=0', 'connection':'keep-alive', 'host':'secure.in.gov', 'content-length':'6917', 'upgrade-insecure-requests':'1', 'user-agent':'mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, gecko) chrome/45.0.2454.101 safari/537.36', } requests.session() session: session.get("https://secure.in.gov/sos/online_corps/name_search.aspx",headers=header,verify=true) session.cookies['__utma'] = '58...

ios9 - iOS 9 iphone 6s Application stuck at didFinishLaunchingWithOptions due to Hockey and Flurry -

i using flurry analytics , hockey. set in didfinishlaunchingwithoptions. [[bithockeymanager sharedhockeymanager] configurewithidentifier:@"67905f839393846c26d406894437830e"]; [[bithockeymanager sharedhockeymanager] startmanager]; [[bithockeymanager sharedhockeymanager].authenticator authenticateinstallation]; [[bithockeymanager sharedhockeymanager].feedbackmanager setfeedbackobservationmode:bitfeedbackobservationmodethreefingertap]; // activate flurry [flurry setcrashreportingenabled:yes]; [flurry startsession:flurry_key]; [flurry setuserid:[helpers getuser]]; i don't know why stuck when try register. using flurry , hockey in other app okay. how shall do? just update flurry sdk. it's fixed in newest version

bigdata - How Can I know how much data is written to which executer during Shuffle-write in spark? -

i ran simple wordcount , trying understand how spark processed data there 3 executers below , i want know more shuffle , first executer wrote 16.2 kb of data how did write each executer ? shuffle write disk or disk + memory ? aggregated metrics executor time |tasks| failed| succeed| input/records | shuffle write/records 1.4min 6 0 6 1536.0 mb/15571058 16.2 kb / 1638 1.4min 6 0 6 1536.0 mb/15571061 16.4 kb / 1638 1.5min 7 0 7 1682.5 mb/17056569 19.0 kb / 1911 finally figured out how shuffle works in spark. shuffle write -> each executer produce local file on disk after map stage shuffle read -> cumulative data fetched executer other executers.

php - Phpexcel xls file showing garbage data while downloading -

i using phpexcel 1.8.0 in project. when want generate , download .xls file data database, file downloaded garbage data. here code: $result = mysql_query("select * my_table"); ob_start(); //excel code $this->load->library('excel'); //activate worksheet number 1 $this->excel->setactivesheetindex(0); //name worksheet $this->excel->getactivesheet()->settitle('test worksheet'); $rownumber = 5; while ($row = mysql_fetch_assoc($result)) { $col = 'b'; foreach ($fields $cell) { $this->excel->getactivesheet()->setcellvalue($col .$rownumber, $row[$cell]); $col++; } $rownumber++; } // ob_end_clean(); // ob_clean() ; $filename='report.xls'; //save our workbook file name header('content-type: application/vnd.ms-excel'); //mime type header('content-disposition: attachment;filename="'.$filen...

ios - Diawi shows wrong identifer of the app -

i have created app today , watch kit extension. app build , created ipa. ipa install in device using itune sync. when upload ipa diawi , download in device did not download. have notice diawi show wrong bundle identifer. have used identifer below for ios app com.appname.ios for widget extension com.appname.widget for watchkit extension com.appname.watchkit as app using com.appname.ios identifier diawi showing com.appname.watchkit . don't know why happen. because of issue not able install app in device diawi

html - What does these text nodes signify in DOM tree? -

Image
for html code, <p> <strong>c</strong>ascading <strong>s</strong>tyle <strong>s</strong>heets </p> below dom tree, using dom inspector tool, -- these text nodes(highlighted in red) signify? note: beginner

php - Scale down an image to a fixed width and Height with same aspect resolution -

i trying scale down uploaded image fixed , height example: width=200px , height 200px . tried scale down width of image fixed width , calculate new height new width. trying achieve scale down both width , height fixed size width=200px & height =200px my html: <form action="do_upload.php" method="post" enctype="multipart/form-data"> <input type="file" name="upload_image"> <br/> <br/> <input type="submit" value="submit"> </form> do_upload.php: <?php move_uploaded_file($_files["upload_image"]["tmp_name"], "uploads/" . $_files["upload_image"]["name"]); $image_path = "uploads/" . $_files["upload_image"]["name"]; $src = imagecreatefromjpeg($image_path); list($width, $height) = getimagesize($image_path); $newwidth = 200; $newheight = ($height / $width) * $neww...

bash - How to escape hyphen(-) in shell script? -

this question has answer here: why should there space after '[' , before ']' in bash? 4 answers my bash script keeps failing because gets confused @ hyphen: if [ ! -d "$openssl-1.0.1i"]; ... how escape correctly? it's not hyphen, must leave space surrounding each argument in test construct: if [ ! -d "$openssl-1.0.1i" ]; .. why have $ before openssl? it's not variable it? if not, should just: if [ ! -d "openssl-1.0.1i" ]; ..

javascript - How to cycle through a series of images onClick -

i have page div holding grid of img elements. want each image, on click, cycle next image in series of three. repeat on each click until third image clicked , loops first image. i have considered writing in javascript, struggling write method can without referencing specific filenames; easy if had 1 image wanted cycle 2 others because have conditional function called next image based on current one. can't write out each time 100+ images in grid on page. have long list of img elements , css defining divs right now, , i'm lost next step. i'm eager suggest best language in , give me general sense of script doing , how interact img elements; don't expect write me! css: .grid { width: 980px; height: auto; margin-left: auto; margin-right: auto; } img { width: 200px; padding-left: 20px; padding-right: 20px; padding-bottom: 20px; } htm...

relayjs - how to pass value to the root query in react-router-relay -

suppose have following root query in relay react-router-relay project: export default { calc: () => relay.ql`query querytype ($number: string) { auth (number: $number) }`, } initial value of $number comes server hidden input , want use number in first query server. how can pass $number query using current react-router-relay api? neither queryparam or stateparam . you should able like: import {createhistory} 'history'; import react 'react'; import reactdom 'react-dom'; import {route, router} 'react-router-relay'; import mycomponent './components/mycomponent'; import mycomponentqueries './routes/mycomponentqueries'; function addauthparam(params, route) { return { ...params, number: 'secret', }; } reactdom.render( <router history={createhistory()} createelement={reactrouterrelay.createelement}> <route component={mycomponent} path="/thing/:id" ...

authentication - redirect a whole group on condition with slim -

i'm working slim , created groups simplify routes file. since group should unauthorized non admin users, redirect routes in group instead of redirect routes 1 one this: index.php $app->group('/admin', function () use ($app) { // crée un "groupe d'url" $app->get('/users', function () use ($app){ if(isset($_session["type"]) && $_session["type"] == "admin") { $ctrl = new usercontroller(); $ctrl->listing($app); }else{ $app->redirect($app->urlfor('indexadmin')); } }) $app->get('/users', function () use ($app){ if(isset($_session["type"]) && $_session["type"] == "admin") { $ctrl = new usercontroller(); $ctrl->listing($app); }else{ $app->redirect($app->urlfor('indexadmin')); } }) as see s...

excel - Creating folders and new *.xlsx file with macro from template like xlsm file -

i have code creates folder , saves actual file in it, want saves copy 1 sheet in it . file code works template... you write stuff , press button , saves .xlsx file 1 sheet (the sheet form) in new created folder... hundreds of files folders. so in end should work this: you open .xlsm file code below in. you got sheets 1 form (what should "exported" later on) , list copy stuff in form. when filled form , press button , saves form sheet in new folder .xlsx , can continue in .xlsm file. if it's unclear please ask. the code have now sub macro1() dim strfilename, strdirname, strpathname, strdefpath string on error resume next ' if directory exist goto next line strdirname = range("d81").value ' new directory name strfilename = range("d8").value 'new file name strdefpath = application.activeworkbook.path 'default path name if isempty(strdirname) exit sub if isempty(strfilename) exit sub mkdir strdefpath & "\...

jcs - Java Caching System MaxLife vs MaxLifeSecond -

i'm using java caching system (jcs - https://commons.apache.org/proper/commons-jcs/ ) i'd know difference between maxlife , maxlifeseconds maxlife: if specify elements within region not eternal, can set max life seconds. if exceeded elements removed passively when client tries retrieve them. if using memory shrinker, items can removed actively. maxlifeseconds: if elements not eternal, option defines maximum life of each object before removed. if memory shrinker running, objects removed shrinker; if not, removed when they're accessed. option defaults -1, disables option. these definitions seem same. is change in name? my guess maxlifeseconds depricated. with jcs 2.0-beta-1 have: cacheaccess.getcachecontrol().getelementattributes().setmaxlife(arg0); cacheaccess.getcachecontrol().getelementattributes().getmaxlife(); and jcs documentation lists maxlife region (element) property jcs regionproperties in old mailing list archive (...

Can we drop and recreate primary key in SQL Server table @ Production environment? Do we have to down the server for it or we can do it live? -

can drop , recreate composite primary key in sql server table in production environment? have take down server it, or can live? because have add more columns primary key. if done in live problems have face? you can remove primary key table.this remove clustered index of table if have't mentioned explicitly on other column. to remove primary key run below query -- drop check constraint table alter table /*schema*/./*table*/ drop constraint /*constraint_name*/ go and add primary key run below code -- add new check constraint table alter table /*schema*/./*table*/ add constraint /*contraint_name*/ /*constraint_type*/ (/*constraint_column_name*/ /*logical_expression*/) go

c# - Reading text files with 64bit process very slow -

i'm merging text files (.itf) logic located in folder. when compile 32bit (console application, .net 4.6) works fine except outofmemory exceptions if there lots of data in folders. compiling 64bit solve problem running super slow compared 32bit process (more 15 times slower). i tried bufferedstream , readalllines , both performing poorly. profiler tells me these methods use 99% of time. don't know problem is... here's code: private static void readdata(dictionary<string, topic> topics) { foreach (string file in directory.enumeratefiles(path, "*.itf")) { topic currenttopic = null; table currenttable = null; object currentobject = null; using (var fs = file.open(file, filemode.open)) { using (var bs = new bufferedstream(fs)) { using (var sr = new streamreader(bs, encoding.default)) { string line; while ((li...

xaml - How to do relativesource mode find ancestor (or equivalent) in UWP -

i trying 1 think should simple (at least in wpf). have page listbox , datatemplate, datatemplate calls user control button in it. nothing fancy, buttons command not part of listboxsource, , can’t find simple way tell button command. here scenario <page x:class="app1.mainpage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:app1"> <page.resources> <datatemplate x:key="mydatatemplate"> <local:mybutton /> </datatemplate> </page.resources> <listbox itemtemplate="{staticresource mydatatemplate}" itemssource="{binding customers}" /> </page> <usercontrol x:class="app1.mybutton" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <b...

implement full audit trail for firebase use -

how go implementing full audit trail users interacting firebase database? i need comply guidelines medical records i.e. reference identity of user, authorizations schema, action (c/r/u/d), subject of action. based on feedback far options logging client or setting service listens changes. however client can tampered , service listening changes miss reads. ideally use .write , .read rules because there have auth token payload , ruledatasnapshots. far can gather can return boolean , not perform database interactions in rules file.

android - How to get malformed JSON in Retrofit 2 -

i sending request, getting exception, though request successful(the api interacting with, sends otp on success). the exception is: com.google.gson.stream.malformedjsonexception: use jsonreader.setlenient(true) accept malformed json @ line 1 column 2 path $ @ com.google.gson.stream.jsonreader.syntaxerror(jsonreader.java:1573) @ com.google.gson.stream.jsonreader.checklenient(jsonreader.java:1423) @ com.google.gson.stream.jsonreader.dopeek(jsonreader.java:575) @ com.google.gson.stream.jsonreader.peek(jsonreader.java:429) @ com.google.gson.internal.bind.typeadapters$13.read(typeadapters.java:349) @ com.google.gson.internal.bind.typeadapters$13.read(typeadapters.java:346) @ com.google.gson.typeadapter.fromjson(typeadapter.java:256) @ retrofit.gsonconverter.frombody(gsonconverter.java:42) @ retrofit.okhttpcall.parseresponse(okhttpcall.java:144) @ retrofit.okhttpcall...

javascript - modenizr complete not executing when already loaded files load again -

i using modenizr load js , css files after loading files have function. on complete of modenizr wrote code. problem when first time files loaded executes complete if load file loaded not executing complete.help me sort out problem my code given below function loadfilesandexecutecallback(files, callback) { modernizr.load({ load : files, complete : function() { callback(); } }); }

Some PHP variables not appearing when contact us form is used -

below php code contact form, website live @ moment , when use form send query using contact form, not information gets through: in email receive, information comes through $subject , message ($name move in on $move.\r\n\n";). no other data client inputs on website listed in email. have looked @ code , cant seem find wrong. i appreciate help. <?php if(!$_post) exit; $to = 'mydomain@email.com'; $name = $_post['txtname']; $email = $_post['txtemail']; $phone = $_post['txtphone']; $comp = $_post['txtcomp']; $emp = $_post['txtemp']; $move = $_post['txtmove']; $comment = $_post['txtmessage']; if(get_magic_quotes_gpc()) { $comment = stripslashes($comment); } $subject = 'you\'ve been contacted ' . $name . '.'; $msg = "you have been contacted $name.\r\n\n"; $msg .= "$comment\r\n\n"; ...

jar - Java Runtime.getRuntime().exec() disable network on win 7 -

how can enable/disable network java program .jar how can use : runtime.getruntime().exec() is can process result = runtime.getruntime().exec("ipconfig/release"); thank you you can me fix processbuilder pb = new processbuilder("netsh", "lan", "disabled","name=\"lan\""); pb.redirecterrorstream(true); process process = pb.start(); bufferedreader reader = new bufferedreader( new inputstreamreader(process.getinputstream())); string line = null; while ((line = reader.readline()) != null) { system.out.println(line); }

ios - Adding 30 seconds to NSDate -

this question has answer here: how add time interval nsdate? 5 answers how can convert nsdate seconds? need in seconds can added 30 secs date , convert nsdate schedule local notification. better ways of doing welcome too. you can use datebyaddingtimeinterval , pass in value 30. return nsdate 30 secs ahead. nsdate *newdate = [previousdate datebyaddingtimeinterval:30];

Regex to validate a character at start and end but also multiple occurences in between -

i need prevent character / occurring in java string @ start , end , // anywhere alphanumerics allowed along .,()?'+/ i have ^[^/]?([\w\-\?:().,'+]/?)*[^/]$ the main problem allows invalid characters # , ## @ start. also tried ^[^/]?([^\w_\-\?:().,'+]/?)*[^/]$ remove _ underscore issue caused \w so these invalid / a//a a/ # ## but these valid a/a a/a.,()+a give chance simple. there's no need negated character classes ( [^x] - "anything x") or negative lookarounds ( (?<!x) , (?!x) - "nothing, or not x"). know characters allowed everywhere in string, spell out: ^[a-za-z0-9?:().,'+-]+(?:/[a-za-z0-9?:().,'+-]+)*$ you don't need specify slash ( / ) can't first, list characters can. , when slash appear, make sure it's followed @ least 1 of other allowed characters. , anchors ( ^ , $ ) ensure nothing else gets in.

reactjs - Module can not be found - Javascript React -

i have react project 2 source files: rmain.jsx , rcategory.jsx . building project using browserify this: gulp.task('builddt', function(){ browserify({ entries: ['src/app/datatree/rmain.jsx', 'src/app/datatree/rcategory.jsx'], transform: [reactify], debug: true }) .bundle() .pipe(source('listapplication.js')) .pipe(streamify(uglify({file:'listapplication.js'}))) .pipe(gulp.dest('src/app/datatree/')); }); unfortunatelly, following error: events.js:85 throw er; // unhandled 'error' event ^ error: cannot find module 'rcategory.jsx' the module in correct location. why happening?

Rails generate HTML in custom helper -

i have following simplified helper works: module myhelper def widget link_to new_flag_path content_tag(:i, '', class: "fa fa-flag") end end end i output second link such as: module myhelper def widget link_to new_flag_path content_tag(:i, '', class: "fa fa-flag") end link_to new_comment_path content_tag(:i, '', class: "fa fa-comment") end end end the solution outlined in pugautomatic article uses "concat" concatenate multiple helpers within single block helper. http://thepugautomatic.com/2013/06/helpers/ works standard link_to helpers such as: module myhelper def widget concat link_to("hello", hello_path) concat " " concat link_to("bye", goodbye_path) end end when using glyphon in href need use link_to block helper such as: link_to new_comment_path content_tag(:i, '', class: ...

Expose a docker port on Mac Osx to other computer -

i open docker port running on mac osx other computer on same network. i've found work around boot2docker not toolbox. and not simple -p or -p. access docker port running on macosx other computer on same network. regards , thanks port forwarding should work same way boot2docker. vboxmanage controlvm "<name_of_your_vm>" natpf1 "tcp-port8000,tcp,,8000,,8000"; then should able access port 8000 under localhost:8000 and different computer in same network <ip_of_you_machine>:8000 for more information check boot2doicker github page workarounds

c# - Does calling Count on IEnumerable iterate the whole collection? -

this question has answer here: difference between ienumerable count() , length 3 answers consider following code: static ienumerable<int> getitems() { return enumerable.range(1, 10000000).toarray(); // or: .tolist(); } static void main() { int count = getitems().count(); } will iterate on 10 billion integers , count them one-by-one, or use array's length / list's count properties? if ienumerable icollection , return count property. here's source code : public static int count<tsource>(this ienumerable<tsource> source) { if (source == null) throw error.argumentnull("source"); icollection<tsource> collectionoft = source icollection<tsource>; if (collectionoft != null) return collectionoft.count; icollection collection = source icollection; if (collection != null) retu...

asp.net - How can we validate a string variable for numeric format? -

the if condition checking null or empty, wouldn't fix flaw. want check whether year string contains number. string year = request.params[""year""]; if (year == null || year.equals("""")) { year = system.datetime.now.year.tostring(); } use tryparse: int x; if (year == null || year.equals("""") || !int.tryparse(year, out x)){ // code }