Posts

Showing posts from June, 2010

html - cakePHP input with characters counting -

i have html code this: <label>main text (<span class="main_text_count">0</span><span>) characters</span></label> <textarea name="data[news][sentence]" id="main_text" class="form-control" required rows="8"></textarea> and don't know how create text area this, using form helper of cakephp. simply done using form helper (both cakephp 2 , cakephp 3 ):- echo $this->form->textarea( 'news.sentence', [ 'id' => 'main_text', 'class' => 'form-control', 'rows' => 8, 'label' => 'main text (<span class="main_text_count">0</span><span>) characters</span>' ] ); in future make sure you've read cake's documentation.

wordpress - Contact Form 7 SMS integration with twilio -

how setup can send out sms whenever has fill in form? i'm using https://www.twilio.com sms. include actions in contact form 7 when submitting form? appreciate here, thanks! you can hook in cf 7 process. have here , here , here more information , examples on how it. hooking where/after mail sent might interesting want do.

vb.NET Screen Location -

i'm working multi monitor setup. know can screen.allscreens(x) specific screen, there way identify screen in position? i.e. screen 0 on right, screen 1 on left, screen 2 in middle i'm trying position 1 form @ top left of each screen, , way can think me.location = new point(-screen.allscreens(1).bounds.width, screen.allscreens(1).bounds.top) (that assuming screen 1 on left) any help? wrapping in sort of loop autogenerate forms each screen amazing too, can handle myself. need know how position each 1 @ top left of each screen.. thanks :3 as mentioned on site, if i'm understanding correctly should want: private sub button1_click(sender object, e eventargs) handles button1.click dim number = 1 each scr in screen.allscreens.orderby(function(s) s.bounds.left) dim f new form {.text = number.tostring(), .startposition = formstartposition.manual, .location = scr.bounds.loc

xcode - How to blur the background when an alert is showing? -

Image
i apply blur effect existing view when alert shown on screen, , doing displaying imageview ( blureffect:blurbackgroundsignup ) on top of view, hiding , showing when calling following code: [self blureffect:blurbackgroundsignup]; the blureffect method works blurred view when put code in viewdidload method, when check alert or add code displaying alert refuses show. guessing there needs overridden , not know how this. in short, there's nothing in uialertview prevent image view blurred image showing up. it's simple. you have diagnostics identify source of problem. problem snapshot itself. pause execution @ point snapshot created, hover on uiimage variable holds blurred snapshot, click on "quick look" button (looks eye; ), , confirm blurred image looks correct: the next thing check make sure image added image view , image view added view hierarchy. can continue execution of app , hit view debug button : or can run app, hit "pause"

html - submenu not positioning exactly side-by-side -

i found issue .sub_menu code left:-; , transform:translatex(-%); ,so changed position relative , re-positioned 2 codes above, seemed work 2 sub menus have no longer side-by-side. separate few centimeters top:, not sure made happen, appreciated,thanks jsfiddle sub menu pops when hover on gallery .sub_menu { display: none; position:relative; top:-60%; left:-350%; transform:translatex(-40%); width: auto; } .sub_menu > li { display:inline-block; } .sub_menu li { background:-webkit-linear-gradient(#77047e,#ff00ff); background:-o-linear-gradient(#77047e,#ff00ff); background:-moz-linear-gradient(#77047e,#ff00ff); background:linear-gradient(#77047e,#ff00ff); } .sub_menu li a:hover { background:#ff00ff; top:1em; } from understand @ taking quick sub.menu s odd. have style position: absolute , , make them align in same exact place. can see doing here: .sub_menu { display:none; position:absolute; top:-37%; left:-47%; transform:transla

java - Gradle: Adding sources.jar file within /lib folder of published dist.zip along with all my other dependencies -

i have java project building using gradle. releasing dist.zip folder project , want add sources.jar project /lib subfolder within dist.zip. able create sources.jar file along dist.zip file not sure how add sources.jar within dist.zip. how can this? i've tried copy .jar /lib folder after creating unable work. below publishing , sourcesjar task within gradle.build script. task sourcesjar(type: jar, dependson: classes) { classifier = 'sources' sourcesets.main.allsource } publishing { repositories { maven { url 'localfolder' } } publications { maven(mavenpublication) { groupid 'ca.project' artifactid applicationname version version components.java artifact sourcesjar { classifier "sources" } artifact distzip { classifier "dist" } } }

go - Append to golang gob in a file on disk -

i'm trying save gob -encoded data in file on disk simple datastore. however, when open next time gob encoder ignores whatever data in file, , starts on sending definitions of sent formats before sending data. seeing gob.encoder takes io.writer , rather io.readwriter , makes sense. encoder has no idea what's in file, because cannot read it. this is, however, quite inefficient. it's unnecessarily hard parse, since have reset decoder each time encoder restarted when writing file, since gob type id's might've changed. how can continue write end of file containing gob data? have create new file, moving data on gob encoder knows types sent, or there way me tell encoder types should know already, or other way? need work across software restarts. it not possible reconstruct encoder state other encoder had when writing stream of gob values. if cannot use original encoder when appending values, have couple of options: move data on suggest. use framing me

javascript - D3 - changing the data of multiple lines onclick -

i want make code changes data of y , x-axis when press radio button, have working except fact don't know how change data of multiple lines. i want change data off lines using .csv document,at start use "databelgium.csv" , want change data "datanetherlands.csv" here radiobuttons in html code: <form> <input type="radio" onclick="updatedatatobelgium()" name="country" value="updatetobelgium" checked>belgium <br> <input type="radio" onclick="updatedatatonetherlands()" name="country" value="the_netherlands">the netherlands </form> here define lines (the data use csv-document linked code) // define lines var crime = d3.svg.line() .x(function(d) { return x(d.date); }) .y(function(d) { return y(d.crime); }); var gdp = d3.svg.line() .x(function(d) {return x(d.date); }) .y(function(d) { return y(d.gdp); }); here add

c# - Automatically delete Blob files in Azure based on a future date -

i curious see if there way automatically delete blob file in future in microsoft azure setting future date or time? when set time elapse, blob file automatically deleted. using c# asp.net. a blob never going delete itself. contradict consistency , reliability of azure if objects started deleting themselves. the simplest thing can think of set webjob monitor storage account , remove blobs specified number of days old. or if store metadata blob in app database have webjob database , delete blob deletedate today. webjobs can, if you're site isn't under real pressure, deployed existing webapp process @ no additional cost. if expect either webapp or webjob particularly busy consider separating them don't compete resources. there's great blog post here tells need know started webjobs. it's worth noting webjob can run continuously, on demand, on defined schedule , in response message queues or file being dropped in blob storage.

PHP echo $result '{"status" : "success"}'; -

this question has answer here: php parse/syntax errors; , how solve them? 11 answers could please tell me wrong function. found in video: https://www.youtube.com/watch?v=871_pmieyxi (1:24) i'm getting error: parse error: syntax error, unexpected ''{"status" : "success"}'' (t_constant_encapsed_string), expecting ',' or ';' in c:\xampp\htdocs\myproject\application\controllers\usercontroller.php on line 26 line 26 line: echo $result '{"status" : "success"}'; public function add() { $postdata = file_get_contents("php://input"); $request = json_decode($postdata); $name = $request->name; $city = $request->city; $id = $this->user_model->adduser($name,$city); if($id) { echo $result '{"status" : "success"}

c# - How do I change the content of a WinForms label from the Program.cs main method? -

so have start-up routine in main method checks make sure there content in .txt file. fileinfo finfo = new fileinfo(datadir); if (finfo.length < 64) { //do stuff here if file not long enough } i want able make label on winforms app display text , want grey out controls, can't seem find way reference said label/controls, or object in form matter. beginner, , struggling figure out. if want able work form object main() method need pass in object instead of using new keyword. this see (visual studio produces code). static class program { static void main() { application.enablevisualstyles(); application.setcompatibletextrenderingdefault(false); application.run(new form1()); } } what can work form object. static class program { static void main() { application.enablevisualstyles(); application.setcompatibletextrenderingdefault(false); form1 myform = new form1(); //create object her

Scala function that returns requested type -

i have configuration file several properties in (mostly) json format "server_name": "fooserver", "server_port": [9999], "debug": "false", "max_users": [1000], "max_instances": [5] that i'm loading via typesafe config library. have wrapper class has function returns property based on name. want able call config.get("server_name") and have string "fooserver" returned me. or int, or boolean, depending on value type in configuration. my current function here: val factory = configfactory.load() def get(configvalue: string) : anyref = { val javaobject = factory.getanyref(configvalue) //return } which sadly not compile. getanyref function returns whatever config value unwrapped boxed java object, handles type inference config file. should match on type of object? should return type function? anyref closest thing found all-inclusive type. i realize scala f

php - MySQL Table with frequent TRUNCATE, UPDATE, & SELECT -

i building application requires mysql table emptied , refilled fresh data every minute. @ same time, expected table receive anywhere 10-15 select statements per second constantly. select statements should in general fast (selecting 10-50 medium length strings every time). few things i'm worried about: is there potential select query run in between truncate , update queries return 0 rows? need lock table when executing truncate-update query pair? are there significant performance issues should worry regarding setup? there propably better way achieve goal. here's possible answer question anyway: can encapsulate queries meant executed in transaction. off top of head like begin transaction; truncate foo; insert foo ...; commit; edit: above part plain wrong, see philip devine's comment. thanks. regarding performance question: repeatedly connecting server can costly. if have persistent connection, should fine. can save little bits here , there executing mul

C# DataGridView CRUD on Database -

i have datagridview in form displays data database, , can add data there, remove there, , save database. problem when add row, id random negative number, when saved database isn't negative. removed visibility of id column in datagridview cannot change anyway. problem however, when go , @ database, row added, id's should auto increment way off. had 5 entries, added 6th , id showed 1005. others had id's of 1, 2, 3, 4, 5 should. how can fix this?

javascript - Retrieving values from a php service in HTML -

i trying build website displays google map user location (lat/long) php service wrote. i have php script gets lat/long mobile app (via post client), stores in db, , read db 2 variables, let's call them $lat , $long. make sure have right values in $lat , $long, did simple echo , got 2 values. i struggling understanding how read these values index.html script. examples have seen suggest keeping php code in html file rather keep them separate. not sure how assign these values parameters in html/javacript can display them on map. so questions are: 1. how call php file html? 2. , how read $lat , $long php service , assign them parameters in html/javascript can display on map? edit: here php code , index.html (which 1:1 copy google maps v3 docs). location.php: $content = file_get_contents('php://input'); $post_data = json_decode($content , true); $lat = $post_data['lat']; $long = $post_data['long']; //connect mysql $con1 = mysql_connect("loca

php - Magento Product Insert Error -

i installed magento 1.9.1 , took tables magento 1.5 database. made necessary changes, making request normally, registering client normally, changing product normally. however, when trying add new product, error: sqlstate[23000]: integrity constraint violation: 1062 duplicate entry '25811-1' key 'idx_stock_product' the query was: insert `cataloginventory_stock_item` (`product_id`, `stock_id`, `qty`, `use_config_min_qty`, `is_qty_decimal`, `backorders`, `use_config_backorders`, `use_config_min_sale_qty`, `use_config_max_sale_qty`, `is_in_stock`, `low_stock_date`, `use_config_notify_stock_qty`, `use_config_manage_stock`, `stock_status_changed_automatically`, `use_config_qty_increments`, `use_config_enable_qty_increments`) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) the unique changes saw in product tables column stock_status_changed_automaticall in magento 1.5 called stock_status_changed_auto changed in new store. change error persists.

templates - How to create ionic apps using visual studio 2013 Community? -

Image
is there tutorial on how build ionic apps on visual studio ? have used ionic templates in vs ? when try open template, i'm getting error: this extension not installable on of installed products. if download , install through vs 2013 community templates (in new project dialogue) error after creating project: the imported (cordovatools) project not found question: how can .targets files here not found vs? it's because template support visual studio 2015 rc using vs 12.0 vs2013. [ update ] note: following content may moved blog or somewhere can shared others in future. environment : tools: visual studio 2013 update 4 + tools apache cordova ctp 3.1 os: windows 8.1 pro topic : how develop ionic starting template on https://github.com/driftyco/ionic-starter-tabs in visual studio 2013 step 1: created new blank cordova app in visual studio 2013. file->new->project->javascript->apache cordova apps -> blank app (na

Stripping invalid characters from a PDF in PHP -

we're getting pdfs vendor have 58,000+ null characters following legal end of document %%eof. we're working vendor see if can correct it, want ahead of issue in case can't. using php (or classic asp, though doubt that's possible) want find eof marker strip after and resave file valid pdf. i've not worked binary files before , have vague idea of start.

Can't get values from Dictionary Property in C# -

i have following code class called role public static class role { private static dictionary<string, list<permissions>> _userrole; private static list<permissions> _userpermission; public static dictionary<string, list<permissions>> userroleinfo { { return _userrole; } } public role() { _userrole = new dictionary<string, list<permissions>>(); _userpermission = new list<permissions>(); }} in class i'm trying value of matching key userroleinfo property list<permissions> value = role.userroleinfo(authenticatedusername) but following error error 7 non-invocable member 'user.role.userroleinfo' cannot used method. any idea how around or mistake, because using if(role.userroleinfo.containskey(authenticatedusername)) works fine the right syntax getting dictionary value in c# is role.userroleinfo[authenticatedusername] initializing sta

ios - App enters background determine current ViewController -

i working on ios app , want add notification notification center if , if user looking @ view controller when left app. app has count down timer , if looking @ count down timer , go send text or other app send notification once timer @ 0. if on view controller have no need send notification. great thanks. within uiviewcontroller wish detect app going background going need register uiapplicationwillresignactivenotification , uiapplicationwillterminatenotification notifications nsnotificationcenter when viewwillappear called. nsnotificationcenter .defaultcenter() .addobserver(self, selector: selector("callback"), name: uiapplicationwillresignactivenotification, object: nil) nsnotificationcenter .defaultcenter() .addobserver(self, selector: selector("callback"), name: uiapplicationwillterminatenotification, object: nil) when screen calls method handling notification, schedule uilocalnotification trigger @ current time, plus timer count. can use

How can I get the class of a hidden element using JQuery? -

this must possible. see sorts of answers how class of div etc. here doing: var $outmap = $('img').not(':hidden'); alert($outmap.attr("class")); it comes undefined . know $outmap valid because can use make said hidden element .fadeout want retrieve class of element. came above code after trying: alert($('img').not(':hidden').attr("class")); i sure doing same thing don't know else try. the problem appears while jquery's selectors return number of elements found, attr function operates when there's single element. to illustrate let's have page 5 images (doesn't matter if hidden or visible). if $('img') you'll 5 results, , calling .attr('class') returns undefined . however, if select single image, selecting id attribute, .attr('class') work: $('#some-image-id').attr('class') give class. if need class each of several images you'l

hook - Mercurial list files from changegroup -

i want simple command list of files differ after pushing mercurial repository on server, differences between previous push , current push. on server, have hook on changegroup event calls bash script. $hg_node revision first commit in changegroup. my attempts: hg status --rev $hg_node:: exclude changes made in first commit hg status --rev $hg_node^1:: includes changes affected parent revision through others pushes. hg log -v --rev $hg_node:: | grep ^files include committed reverted changes, still has 'files:' , files not 1 per line hg status --rev $hg_node:: && hg status change --rev $hg_node does not give want, rather change between parent first commit in changegroup + change between 1 (instead of 2 changesets merged) hg status --rev some_tag ; hg tag --remove some_tag ; hg tag --local some_tag (have not tried, idea?) uses local tag keep track of head last push, updates each time. also want monitor default branch, assume use --rev "revis

bash - sed command creation via shell script - quotes and sed -

i'm implementing template renderer in shell script. template variables represented in template @var_name@ , values defined in separate shell script. sample code: # template variables values contact_email="myemail" contact_name="myname" vars="contact_email contact_name" template_filepath="mytemplate.txt" # template renderer set -x sedargs= var in $vars; sedargs+=" -e \"s,@$var@,${!var},\"" done sed -r $sedargs $template_filepath sed command executed shell , printed because of "set -x": + sed -r -e '"s,@contact_email@,myemail,"' -e '"s,@contact_name@,myname,"' mytemplate.txt sed output: sed: -e expression #1, char 1: unknown command: `"' i know single quotes around each sed expression causing non-intuitive error message, not know why added. what wrong? you have embedded quotes inside sedargs variable. these not removed when command e

c - segfault when using strtok_r -

i want split string in c code: char *search = "+" ; char *temp1; char *temp2; char *saveptr1, *saveptr2 ; int operand1 ; int operand2 ; int result ; char sumbuff [5][25] temp1 = strtok_r(sumbuff[sumcounter-1], search, &saveptr1) ; operand2 = atoi(strtok_r(null, search, &saveptr1)); temp2 = strtok_r(temp1, ".", &saveptr2) ; operand1 = atoi(strtok_r(null, ".", &saveptr2)) ; but when run in main code segmentation fault. , trace stack result: #0 0x00007ffff7834517 in ?? () /lib/x86_64-linux-gnu/libc.so.6 #1 0x00007ffff7830f60 in atoi () /lib/x86_64-linux-gnu/libc.so.6 #2 0x000000000040108c in plusexec (arg=0x0) @ cm.c:112 #3 0x00007ffff7bc4182 in start_thread () /lib/x86_64-linux-gnu/libpthread.so.0 #4 0x00007ffff78f147d in clone () /lib/x86_64-linux-gnu/libc.so.6 cm.112 operand2 = atoi(...) how can correct error? you not check return of strtok_r , can null , therefore crash atoi . and in case: temp2 = strtok

PHP contact form goes to a blank page -

my beloved php contact form goes blank page, email not going through either. i've added echo function @ end see if goes through entire code. worked, echoed line showing up. quite newbie in php, please don't bite head off. project i'm working on: http://www.designbynoemi.co.uk . any direction highly appreciated. and here code: <?php /* * contact form class */ error_reporting(e_all); ini_set('display_errors', 1); header('cache-control: no-cache, must-revalidate'); header('expires: mon, 26 jul 1997 05:00:00 gmt'); header('content-type: application/json'); $admin_email = 'contact@designbynoemi.co.uk'; // email $message_min_length = 5; // min message length class contact_form{ function __construct($details, $email_admin, $message_min_length){ $this->name = stripslashes($details['name']); $this->email = trim($details['email']); $this->subject = 'contact website

html - Numbering with CSS Counter for Headings -

i'm trying achieve css counting headers. ex. <h1>first heading</h1> <h2>second heading</h2> will converted 1. first heading 1.1 second heading that works fine css counter. doesn't work when h2 h3. result h3 heading add "1.0.1" instead of 1.1.1, because there no h2 heading counter h2 0. <h1>first heading</h1> <h3>third heading (should 1.1.1)</h3> will converted 1. first heading 1.0.1 third heading (should 1.1.1) any suggestion how solve (is possible) ps. example headings can found here http://jsfiddle.net/6xpveu0t/ please use headlines in semantically correct way. in earlier days, people rather misused different headline-tags suit design, rather styling them correctly done today (hopefully everywhere). in terms of semantic usage of headlines , headline 1 followed headline 2 followed headline 3. may refer w3c school headline priority . in printed books, never find nested subchapter insi

ios - Objective C new Header File marked with gray icon and cannot import Frameworks -

i new xcode , objective may doing stupid haven't been able find solution following problem: 1) create new header file in want import framework (drobboxsdk.h) 2) icon file darker other files 3) can't import dropbox header using <> nor autocomplete me (as all other existing files... what doing wrong? how come previous files can import framework? i ve tried add build phase in build phases dialogue tutorial suggested submenu in build phase greyed out... dark icon means have unsaved changes in file. if can't import sdk in other classes too, make sure have set correct header search path. also, xcode has bug autocompletion in cases, write yourself #import <dropboxsdk/dropboxsdk.h>

javascript - Infinite Loop when setting requireADLogin: true, on $stateProvider -

i have following piece of code, want instead of use route provider, use state provider. function config($stateprovider, $urlrouterprovider, $oclazyloadprovider, idleprovider, keepaliveprovider, adalauthenticationserviceprovider, $httpprovider) { adalauthenticationserviceprovider.init( { instance: 'https://login.microsoftonline.com/', tenant: 'mysaasapp.onmicrosoft.com', clientid: '33e037a7-b1aa-42ab-9693-6c22d01ca338', extraqueryparameter: 'nux=1', //cachelocation: 'localstorage', // enable ie, sessionstorage not work localhost. }, $httpprovider ); // configure idle settings idleprovider.idle(5); // in seconds idleprovider.timeout(120); // in seconds $urlrouterprovider.otherwise("/dashboards/dashboard_1"); $oclazyloadprovider.config({ // set true if want see , when dynamically loaded debug: false }

angularjs - angular permission show message and set the button disabled -

i'm using "angular permission" . validate user role , works perfect, want show message when user doesn't has these role , if possible shows button disabled. me this? this router definition: $stateprovider.state('actionaccess', {url: '/actionaccess', templateurl: 'views/actionaccess.html', controller: 'actionaccesscontroller', data: { permissions: { only: ['admin'] } } }) and function define if user has or not role: .run(function (permission, authorizationfactory){ // define anonymous role permission.definerole('admin', function (stateparams) { return authorizationfactory.isinrole("admin"); }); }) according the documentation on project page, can specify in router config redirectto property. data: { permissions: { except: ['anonymous'], redirectto: 'login' } }

Python recursive call for list elements -

i've tried create rough implementation of g-means break sample down clusters clusters gaussian using recursion, program seems going in 1 direction (downward). input values of method data set, x, , list of centres. i'm having trouble figuring out how solve recursive bit of method (the last loop , beyond). after of recursive calls, want have list of centres in c can returned main method. so here's happens in last loop. i'm iterating through list of clusters (found using cluster centres), clust, contain values in each cluster. run test see if there significant evidence values in each cluster gaussian. if there evidence, want remove cluster centre , add 2 new centres above , below. want run through recursive call , evaluate these new centres see if clusters match gaussian or not. the problem program evaluating lower centre bound. seems never reach upper centre though return statement means program stop upper centre ever being reached. does know how can method co

c++ - Returning an integer to determine which switch statement to show -

i'm creating board game (stratego) in c++ , wondering if considered poor practice return integer class method in order determine case in switch statement show user. example: in stratego, can't attack board pieces part of own army have message "you cannot attack own army" when user tries so. same thing if movement performed result in player jumping off board, moving many spaces, etc. each of these invalid movements has it's own unique message, avoid printing them class.cpp file, player's moves validated, have class.cpp file returning integer switch statement in main() called from. recommended way handle how messages called? class test { public: test() { } int validate_move(int valid) { if (valid > 0 && valid < 5) { return 1; } else if (valid > 5) { return 2; } } }; int main() { int entry; std::cout << "enter move: &q

html - Segmented Progress Bar in Bootstrap 3 -

Image
i have webpage user needs enter data. once enter 10 items, can continue. i'm trying create progress bar visually represent how many items have entered/have left enter. here image of i'm trying create so far, closest i've gotten using bootstrap's stacked progress bars. however, stacked bars, the unfilled section single unbroken region - doesn't show how many segments left. here's fiddle showing mean. here's markup fiddle: <div class="container"> <div class="progress progress-bar-segmented"> <div class="progress-bar" style="width: 10%"></div> <div class="progress-bar" style="width: 10%"></div> <div class="progress-bar" style="width: 10%"></div> </div> </div> i've searched similar examples adapted meet needs, haven't had luck. i'm not sure should searching or ca

vba - SolidWorks 2013 Macro - String manipulation? -

solidworks uses vba macros, different excel vba (which i'm accustomed to). made difficult (and quite possibly impossible) manipulate strings in sw. i've tried using left() function , mid() function, can not figure out how make work. need do, save .dxf file , name title, without sheet name. sheet name causing problem , i'm trying cut out. can use part.gettitle to string of title which, example like pa0000 - sheet1 and want pa0000 sometimes length different, i've tried using left(part.gettitle,instr(part.gettitle, " ")-1) but gives type mismatch error. doing wrong? that's left macro cut out " - sheet1". i have made changes code @ help.solidworks.com; should work you. change folders needed. dim swapp object dim part object dim boolstatus boolean dim longstatus long, longwarnings long 'http://help.solidworks.com/2012/english/api/sldworksapi/save_file_as_pdf_example_vb.htm sub main() dim swapp

java - Do not request Window.FEATURE_ACTION_BAR issue -

i'm trying build app without success.. tried several way nothing worked. exception is: caused by: java.lang.illegalstateexception: activity has action bar supplied window decor. not request window.feature_action_bar , set windowactionbar false in theme use toolbar instead. my style.xml is: <resources> <style name="apptheme" parent="theme.appcompat.light"> <!-- theme customizations --> <item name="colorprimary">@color/colorprimary</item> <item name="colorprimarydark">@color/colorprimarydark</item> <item name="coloraccent">@color/coloraccent</item> <item name="android:windownotitle">true</item> <item name="android:windowactionbar">false</item> <item name="android:textcolorprimary">@color/ldrawer_color</item> <item name="actionme

java - Linux server with Android client: connection timed out -

i working on android app connected server programmed in java. server , client communicating programmed when test server application on windows. now have moved experiment linux ubuntu os. android app (client) able send strings when server on linux tries send string android fails. takes longer time , gives error: testing.newjframe$1 run severe: null java.net.connectexception: connection timed out @ java.net.plainsocketimpl.socketconnect(native method) @ java.net.abstractplainsocketimpl.doconnect(abstractplainsocketimpl.java:339) @ java.net.abstractplainsocketimpl.connecttoaddress(abstractplainsocketimpl.java:200) @ java.net.abstractplainsocketimpl.connect(abstractplainsocketimpl.java:182) @ java.net.sockssocketimpl.connect(sockssocketimpl.java:392) @ java.net.socket.connect(socket.java:579) @ java.net.socket.connect(socket.java:528) @ java.net.socket.<init>(socket.java:425) @ java.net.socket.<init>(socket.java:208) @ testing.newjframe$1.run(newjframe.java:178) @ java.

scikit learn - n_classes order in LinearSVC.coef_ -

i'm working linearsvc classify text data 3 classes. input data tfidf scores per word. i'm interested in seeing "contribution" words make classification. first question can use coef_ this? documentation states: coef_ : array, shape = [n_features] if n_classes == 2 else [n_classes, n_features] so, i'm assuming "n_classes" corresponds each of 3 classes documents can classified, , n_features coefficient values tfidf features. assuming case, what's order of classes in coef_? how can match each row in array 1 of classes? thanks, nick without digging source code, believe there 2 answers questions: the classes sorted. if have classes ['a', 'b', 'c'], class order ['c','a','b']. (this may odd, make list in python , .sort() it. that's order.) there undocumented class member, linearsvc().classes_ , holds order used class (see this method documentation ).

c++ - The values of int fmt in format() -

currently using opencv3, in opencv2, there way format matrix outputs. used in tutorial here . the format function seems have changed format(mat, str) in opencv2 format(mat, int) opencv3. making call: cout << "4x4: " << endl << format(fourbyfour, "python") << endl; yields following error: error: invalid conversion ‘const char*’ ‘int’ [-fpermissive] /usr/local/include/opencv2/core/operations.hpp:371:16: note: initializing argument 2 of ‘cv::ptr<cv::formatted>cv::format(cv::inputarray, int)ptr<formatted> format(inputarray mtx, int fmt) i can plug in ints random printing formats, assume in opencv3, int fmt meant sort of "cv_" macro, can't seem find in documentation, nor in operations.hpp . would happen know proper values fmt? just looked @ code on github, , seems constant looking cv::formatter::fmt_python . can see code here .

file - Read content of folder without AIR in AS3 (no flash.filesystem) -

i'm working on project , need dynamically check in onhe of folder. idea have id of quest, , there folder name after id. code needs check if folder exist , if there in it. after that, show picture inside folder. goal have add picture in folder have them appear in game. i tried find way check content of folder, need flash.filesystem, means need use air. air not work in firefox or other browser. here website make me understood that: http://www.experts-exchange.com/software/photos_graphics/web_graphics/macromedia_flash/q_26118847.html how can explore content of folders then? there absolutely no way explore local file system without user interaction in flash. if want it, must make air application, not browser-based. security feature imposed each browser (you can't in js either) , implemented identically adobe. you can use filereference allow user select file(s) flash have access or save file, interaction filesystem possible without opening air (which not lim

uncaught exception - handle uncaught_exception in clojure -

i have clojure endpoint in project updates document in couchdb. (^{put true path "/{id}" produces ["application/json"] consumes ["application/json"] apioperation {:value "update" :notes ""} } method_name [this ^{pathparam "id"} id body] (require 'com.xx.x.xx.xx.xx-response) (let [doc (json/read-json body)] (if-let [valid-doc (validate doc)] (try+ (->> (assoc valid-doc :modificationdate (utilities/getcurrentdate)) (couch/update-document dbs/xx-db) (core/ok-response)) (catch java.io.ioexception ex (log/error "line num 197") ) (catch java.lang.exception ex (log/error "line num 200"))) ))) this endpoint throws 500 uncaught exception when there document confli

android - Manipulate a tab fragment during runtime -

i got 3 fragments each on seperate tab. on 1 tab want have fragment in card-style. 1 row should [ ________ ________ +]. after pressing +button want second identical row appear. how achive that? professional way manipulate tagfragments during runtime? how can implement trancisions? i got it. can add additional rows by: @override public void onclick(view v) { switch (v.getid()) { case r.id.imagebuttonadd: if(i==0){ raisecounterbyone(); counter.settext(counterstart.tostring()); test = getactivity().findviewbyid(r.id.testview3); test.setvisibility(view.visible); i++; } else if(i==1){ raisecounterbyone(); counter.settext(counterstart.tostring()); test = getactivity().findviewbyid(r.id.testview4); test.setvisibility(view.visible); i++; } break;

python 2.7 - Extratcing all square submatrices from matrix using Numpy -

say have nxn numpy matrix. looking fastest way of extracting square chunks (sub-matrices) matrix. meaning cxc parts of original matrix 0 < c < n+1 . sub-matrices should correspond contiguous rows/columns indexes of original matrix. want achieve in little time possible. you use numpy slicing, import numpy np n = 20 x = np.random.rand(n, n) slice_list = [slice(k, l) k in range(0, n) l in range(k, n)] results = [x[sl,sl] sl in slice_list] avoiding loops in numpy, not goal itself. long being mindful it, there shouldn't overhead.

mocha - Mochajs external script onload test -

i trying create mochajs test detect script.onload event has been executed or script.onerror. have setup tests detect script exists in dom not sure how check actual loading. describe("load external abc library", function() { var h = document.getelementsbytagname('head')[0]; var s = document.createelement('script'); s.src="http://host.com/script.js"; s.id="abc"; s.async=false; h.appendchild(s); var l = document.getelementbyid('abc'); it.skip("is in dom", function () { expect(l).to.not.equal(null); console.log('is in dom skipped'); }); it("is child of head", function () { expect(l.parentelement).to.equal(document.head); }); }); one way uses virtual dom via mocha-jsdom . example in coffeescript using mocha , chai , sinon , , sinon-chai : adddynamicscript.coffee: module.exports = (scriptname, callback) -> script = document.createelement 'scr

arrays - In C language, What is the difference between extern buffer[] and extern *buffer? -

i read below piece of information in microsoft article; https://support.microsoft.com/en-us/kb/44463 the text below presents example of common programming mistake, is, confusing array , pointer declaration: consider application divided several modules. in 1 module, declare array follows: signed char buffer[100]; in module, declare following variables access array: extern signed char *buffer; // fails extern signed char buffer[]; // works if view code in codeview debugger, indicates *buffer declaration produces different address buffer[] declaration does. but can't understand why cannot access array using *buffer , can access using buffer[] . someone please explain me difference between 2 types? see these questions in c faq list: http://c-faq.com/aryptr/aryptr1.html http://c-faq.com/aryptr/aryptr2.html http://c-faq.com/aryptr/aryptrparam.html

gruntjs - Warning: Task "webTest" not found -

i cannot figure out why cannot register these 2 tests in 1 gruntfile. when run grunt test , runs fine. when run grunt web , gives me warning: task "webtest" not found . code within each task same, why if grunt allowing 1 task register? // gruntfile.js module.exports = function(grunt){ // load grunt mocha task grunt.loadnpmtasks('grunt-mocha'); grunt.loadnpmtasks('grunt-mocha-test'); grunt.loadnpmtasks('grunt-contrib'); grunt.initconfig({ pkg: grunt.file.readjson('package.json'), // webtest webtest: { test: { options: { reporter: 'list', timeout: 2000 }, src: ['all.js', 'test/groups.js', 'test/doctors.js', 'test/patients.js', 'test/diet.js'] } }, // mocha test mochatest: {

Traits with PhP and Laravel -

i using laravel 5.1 , access array on model trait when model before model uses appends array. i add items appends array if exists trait. don't want edit model in order achieve this. traits usable in scenario or should use inheritance? array_push($this->appends, 'saucedbycurrentuser'); here how current setup works. trait <?php namespace app; trait awesomesaucetrait { /** * collection of sauce on record */ public function awesomesauced() { return $this->morphmany('app\awesomesauce', 'sauceable')->latest(); } public function getsaucedbycurrentuserattribute() { if(\auth::guest()){ return false; } $i = $this->awesomesauced()->whereuserid(\auth::user()->id)->count(); if ($i > 0){ return true; } return false; } } model <?php namespace app; use app\awesomesaucetrait; use illuminate\database\eloquent\model; class fairlyblandmodel extends model { us

mysql - SQL Subquery between two tables, the max date to compare with another date -

i have 2 tables: first order product date of order 4772 cf007115 2014-03-31 14:24:29.000 and second product date of buy price cf007115 2014-03-18 111.398 cf007115 2014-03-27 103.121 cf007115 2014-05-08 0.061 cf007115 2014-07-21 0.062 cf007115 2015-01-22 0.065 cf007115 2015-05-29 0.068 i need next result order product date of order date of buy price 4772 cf007115 2014-03-31 2014-03-27 103,121 the result must show price near order. i trying this: select distinct dbo.opsinvalor.orden, dbo.opsinvalor.codcomponente, dbo.opsinvalor.fecha_declaracion, dbo.entradasparaop3.fechaingstock, dbo.entradasparaop3.ppp dbo.opsinvalor left outer join dbo.entradasparaop3 on dbo.opsinvalor.codcomponente = dbo.entradasparaop3.articulo (dbo.opsinvalor.codcomponente = 'cf007115') group dbo.

performance - Fast access to matrix as jagged array in C# -

i've created lower triangular distance matrix (because of size issues) jagged array note: distances between objects symmetric var dm = new double[size][] (var = 0; < size; i++) { dm[i] = new double[i+1]; (var j = 0; j < i+1; j++) { dm[i][j] = distance(data[i], data[j]); } } i need access matrix made following method it private double getvalueofdm(int row, int column, double[][] dm) { return column <= row ? distancematrix[row][column] : distancematrix[column][row]; } with visual studio performance analysis 1 sees major speed issue lies in row of getvalueofdm method. has idea how speed up? you remove conditional in method , increase memory usage increase access performance so: var dm = new double[size][]; (var = 0; < size; i++) { dm[i] = new double[size]; (var j = 0; j < i+1; j++) { dm[i][j] = distance(data[i], data[j]); dm[j][i] = dm[i][j]; } } private double getvalueofdm(int row, int column,

optimization - Unity 4 - using AssetBundle to pre-load assets that are shared across multiple scenes? -

i have several areas in game project split on several scenes, instance let's there first area called "basement" split in basement_1, basement_2 , basement_3 scenes; , area, "attic", split on attic_1 , attic_2. some assets (textures atlas , sounds) shared across scenes of area , thought make assetbundle shared assets "basement", , assetbundle shared assets "attic" area. when player enter "basement" area, i'd load "basement" assetbundle, when call application.loadlevel("basement_1"), application.loadlevel("basement_2") or application.loadlevel("basement_3"), shared assets (which have been loaded in bundle) aren't unnecessarily reloaded, scene-specific assets loaded. if point game knows basement assets no longer necessary, or not long time @ least, i'd unload bundle, free memory, , load whatever other bundle may relevant (the attic 1 instance). my question is: how works? in, i