Posts

Showing posts from July, 2011

javascript - Datatables single column search -

i have basic table , search one column. the code have far here in fiddle . as can see @ bottom of each column there search filter, there 1 search filter, on office column. it if search filter @ top, , not @ bottom now. basically i'd table similar this one , instead of filter on each column, want one filter on one column. any appreciated. my code below. // setup - add text input each footer cell $('#example tfoot th').each(function() { var title = $(this).text(); $(this).html('<input type="text" placeholder="search ' + title + '" />'); }); // datatable var table = $('#example').datatable(); // apply search table.columns().every(function() { var = this; $('input', this.footer()).on('keyup change', function() { if (that.search() !== this.value) { .search(this.value) .draw(); } }); }); <script src="https://ajax.goog...

python - Scikit learn Error Message 'Precision and F-score are ill-defined and being set to 0.0 in labels' -

im working on binary classification model, classifier naive bayes. have balanced dataset following error message when predict: undefinedmetricwarning: precision , f-score ill-defined , being set 0.0 in labels no predicted samples. 'precision', 'predicted', average, warn_for) i'm using gridsearch cv k-fold 10. test set , predictions contain both classes, don't understand message. i'm working on same dataset, train/test split, cv , random seed 6 other models , work perfect. data ingested externally dataframe, randomize , seed fixed. naive bayes classification model class file @ beginning of before code snippet. x_train, x_test, y_train, y_test, len_train, len_test = \ train_test_split(data['x'], data['y'], data['len'], test_size=0.4) pipeline = pipeline([ ('classifier', multinomialnb()) ]) cv=stratifiedkfold(len_train, n_folds=10) len_train = len_train.reshape(-1,1) len_test = len_test.reshape(-1,1) para...

opencart2.x - how to add two product in opencart? -

how add 2 products . example added product1 . want split product1 product media , product1 without media. quantity same . in product list has show in 2 different entries . below code adding product. taking 1 .. $this->data[$key] = array( 'key' => $key, 'product_id' => $product_query->row['product_id'], 'name' => $product_query->row['name'], 'model' => $product_query->row['model'], 'shipping' => $product_query->row['shipping'], 'image' => $product_query->row['image'], 'option' => $option_data, 'download' => $download_data, 'quantity' => $quantity, 'minimum' => $product_query->row['minimum'], 'subtract' => $product_query->row['subtract'], ...

Why below interface code of TypeScript executes? -

in below code snippet, have declared imath interface , implemented in add method , works, absolutely fine. however, in multiply method should have given compile error passing 1 parameter , 2nd parameter not optional. interface imath { (a: number, b: number): number; } // using interface var add: imath; add = function (a: number, b: number) { return + b; } var sum = add(5, 3); alert(sum); var multiply: imath; multiply = function (c: number) { return c; } var result = multiply(5, 3); alert(result); but not compile error in visual studio, guess? this because function of type (number) -> number can assigned type of (number, number) -> number . it’s second argument ignored , thrown away doesn’t mean not call 2 arguments, making assignment valid. see following minimal example shows valid assignment: var f: (a: number, b:number) => number = function (a:number):number { return 0; } f(1, 2);

c# - Azure website deployment: routing behavior not the same as localhost tests -

the problem trying solve explained in this post . tl;dr : multilingual website, redirecting translated .cshtml views depending on language. azure treating view re-routing differently in case of home/index, made patch solve (see own-answer in previous post). current problem : thought solved, because css cached. mess, say: routing of css elements seems have changed after deploying azure. again: can not reproduced in localhost. anybody has idea how deal seemingly undebuggable differences between localhost tests , azure?

dependency injection - Register multiple interfaces that has explicit implementation on a single instance -

i using autofac , not ioc master. consider scenario: public interface ibeforerequesttask { void execute(); } public interface iafterrequesttask { void execute(); } public class taskexecutor : ibeforerequesttask, iafterrequesttask { void ibeforerequesttask.execute() { // code } void iafterrequesttask.execute() { // code } } so, have explicit implementations. how register these interfaces? i think can't this: builder.registertype<ibeforerequesttask> ... builder.registertype<iafterrequesttask> ... i read in autofac registration docs must register concrete types. similar question not treating autofac one: tinyioc: register multiple interfaces on single instance well, know can easy doing 1-1 (one interface per class, register concrete type). curious it. don't remeber saw below code using structuremap (can wrong): action.addtypesof<ibeforerequesttask>(); action.addtypesof<iafterrequest...

android - startActivity in onPause() not working after opening new app -

i start second activity when first activity paused. firstactivity.java @override public void onpause(){ super.onpause(); startactivity(new intent(this, secondactivity.class)); } when press on homescreen button, secondactivity start delay. in delay, there enough time open new app (like messenger instance). however, when open new app, secondactivity not start anymore (it won't call oncreate method of secondactivity). how can still start secondactivity when open new app? override onbackpressed() method , start new activity there, instead of adding code onpause(). @override public void onbackpressed() { startactivity(new intent(this, secondactivity.class)); super.onbackpressed(); }

c# - MVC Chart just displaying text stream -

Image
i trying put sort of dashboarding mvc application , cannot render chart correctly. seems display byte-stream rather image. on main index page have button post controller acquire data (sample data in example) , update results section. datapoint.cs public class datapoint { public datetime datemark { get; set; } public int count { get; set; } } index.cshtml @model ienumerable<charttest.models.datapoint> @using (ajax.beginform("generate", new ajaxoptions() { insertionmode = insertionmode.replace, updatetargetid = "results" })) { @html.antiforgerytoken() <div class="form-horizontal"> <div class="panel-group"> <div class="panel panel-danger"> <div class="panel-heading" style="background-color: #80929c; color: #f6e0c7"> <div class="row"> <!-- stuff user request in...

java - hibernate query for list<t> in where clause -

i've @manytomany mapped classes in spring application want of tasks i've assigned particular user id. task class public class task { @id @generatedvalue(strategy=generationtype.auto) @column(name="taskid") private string taskid; @column(name="subject") private string subject; @manytomany(fetch=fetchtype.eager) @jointable(name = "jt_assign_tasksmap", joincolumns = { @joincolumn(name = "taskid") }, inversejoincolumns = { @joincolumn(name = "assignedto_uid") }) private list<users> to; //getters , setters } user class public class users { @id @generatedvalue(strategy=generationtype.auto) @column(name = "uid") private string id; @column(name = "username") private string username; @manytomany(targetentity=task.class, mappedby="to", fetch = fetchtype.eager, cascade=cascadetype.all) @fetch(fetchmode.select) private list<task> assignedto; //getters , setters } now want...

javascript - Multiple linecharts with different Y scales with shareable X Axis using d3js -

Image
im working on project have big amount of data. it's segmented categories soybean, ma20, ma50, ma100, bbw_2 , date . i've done far use code can filter , zoom in data. result selecting soybean: selecting ma50: selecting bbw_2 !here problem! : problem when bbw_2 selected. can see orange line touching x axis. bbw_2. has it's y' axis max value of 2, infinitely smaller 1200, scale doesn't work expected. doesn't occur other categories because have similar y' axis values. what want achieve? i want plot categories user selects appending selected categories`generated linechart same x axis different y scales. 1 example of one: . what i've tried: change y scale changing when user selects bbw_2. plot in different svg`s. doesnt work great because loses zooming effect. the code: https://jsfiddle.net/ldepaula/3q1k9hyj/1/

How broadcast data of HTTP post method in angularjs -

i'm using same http method in different controller following sample: service: var method="samplemethod" hotalstatisticservice.getreservations = function (data) { return $http({ method: 'post', data: data, cache: false, url:'http://sample.com/'+method }); } first controller .controller("sampleactrl", function ($scope,hotalstatisticservice ) { hotalstatisticservice.getreservations({start:start, end:end, type:type}) .success(function (data) { $scope.samplea=data; }) } second controller .controller("samplebctrl", function ($scope,hotalstatisticservice ) { hotalstatisticservice.getreservations({start:start, end:end, type:type}) .success(function (data) { $scope.sampleb=data; }) } how use here method in 1 controller? let me other solution uses factories better solution.usi...

ios9 - Universal Link not working on iOS 9 (device) -

this apple-app-site-association json: { "applinks": { "apps": [], "details": [ { "appid": "{team_id}.com.domain.myapp", "paths": [ "/activation/*"] } ] } } i have signed apple-app-site-association file following command (from terminal on os x 10.11): $ cat apple-app-site-association-unsigned | openssl smime -sign -inkey /etc/pki/tls/private/{filename}.key -signer /etc/pki/tls/certs/{filename}.crt -certfile /etc/pki/tls/certs/{filename}.ca -noattr -nodetach -outform der > apple-app-site-association i have placed signed apple-app-site-association file on root directory of domain , set htaccess in such way content-type application/pkcs7-mime: $ curl -i https://www.domain.com/apple-app-site-association http/1.1 200 ok server: apache content-type: application/pkcs7-mime ... on xcode (v7.2) on project target, on ...

reporting services - Split report parameters in stored procedure -

i work crm 2015. when try create report multiply-values parameter, can not split on list id. tried many ways like: alter procedure [dbo].[pn_rep_loadresources] (@stage nvarchar(1000)) where(stage.new_stageid in (select value dbo.fnsplit(@stage,','))) where(stage.new_stageid in (select value dbo.split(@stage,','))) where(stage.new_stageid in (select value dbo.split(@stage,','))) where(stage.fn_getguidsfromstring in (select value dbo.split(@stage))) and other, nothing works. have problem this?

url rewriting - IIS URL Rewrite not working after first forward slash, but URL forward works fine -

so if enter url like: http://sample.com/maindir/test123 rewrite works fine. if enter url like: http://sample.com/maindir/test123/test234 breaks, giving 500 error. both of these work if change redirect instead of rewrite rule <rule name="test" stopprocessing="true"> <match url="^maindir\/?(?:([^\/]+))?\/?(?:([^\/]+))?\/?(?:([^\/]+))?\/?(?:([^\/]+))?\/?" /> <action type="rewrite" url="maindir/?a1[]={r:1}&amp;a1[]={r:2}&amp;a1[]={r:3}&amp;a1[]={r:4}" /> <conditions> <add input="{request_filename}" matchtype="isdirectory" negate="true" /> </conditions> </rule> after frustration this, trying find solution, figured see if else can see what's going on here. thank in advance.

asp.net - How to know if a vector on the right hand side -

Image
let me first define problem, i working on indoor navigation problem. constructed graph simulate possible paths. can calculate shortest path dijkstra , draw on map. far, good. but not enough, i need give instruction user navigate him. for example: "turn right" "turn left" "go on left" to give these kind of instructions need know path on left , path on right. and here have solve this: 1. undirected weighted graph 2. shortest path contains vertices , edges 3. x , y coordinates of each vertices by way in .net using beacon technology. do know how separate left , right edges can give direction messages user? thanks. the easiest way can think of take cross product of vector representing direction player facing/traveling , vector representing direction want player go in. whether player must turn left or right depends on whether result's y-coordinate positive or negative, which depends on handedness of coordinate syste...

import - Importing .csv files and saving as .dta -

i have folder containing number of csv files, e.g. "leeds dz.csv", "leeds gh.csv", "leeds fr.csv". first part of file names constant (i.e. "leeds"). i want import each stata individually, convert .dta file , save it. have code: cd "etcetc" clear local myfilelist : dir . files"*.csv" foreach file of local myfilelist { drop _all insheet using `file', comma local outfile = subinstr("`file'",".csv","",.) save "`outfile'", replace } the code works fine if rename .csv files manually delete "leeds" part, ie if each .csv named "dz.csv" instead of "leeds dz.csv" etc. however, if not deletion receive error "invalid 'dz.csv' " i'm guessing has 3rd line of code, in particular "*.csv". i'm unsure how adapt code/ why won't allow me import files space in name? the line insheet using `file', c...

c# - Setting value of CheckBoxFor -

i trying set checkbox value (true/false) field. can value, cannot set it. within model have: public bool receivenewsletter { get; set; } in view have: model project.models.parent @using (ajax.beginform("register", "parentregister", new ajaxoptions { httpmethod = "post", updatetargetid = "parent_register" })) { @html.checkboxfor(u => u.receivenewsletter, new { @class = "checkbox", type = "checkbox" }) } in controller have: [httppost] public actionresult register(models.parent register) { return content(register.selectedindex.tostring()); } when load application, checkbox unchecked because receivenewsletter false however, when check checkbox , click submit, doesn't set value true does know doing wrong? i don't know action method looks like(i'm assumed correct), passing in type of parent named register httppost action method. httppost action method should like: [httppost]...

php - moodle frontpage show categories list as button -

Image
i need change theme show categories list on frontpage buttons image instend of show simple categories list: which file need edit? can find documentation this? searche google did not find nothing about there isn't standard functionality this. here overview though. first need create central region displaying blocks, instructions here how add block center of page in moodle? then create own block layout want. follow instructions here https://docs.moodle.org/dev/blocks then once installed, add new block frontpage , move central region.

sql server - PHP: Connect to MSSQL database with IPv6 -

using php (with dblib driver), trying connect mssql server ipv6 address. code looks this: <?php $db_host = 'ff3e:30:fd66:98:5837::'; $db_port = '1433'; $db_name = 'thedb'; $db_user = 'theuser'; $db_pass = 'thepass'; $conn = new pdo("dblib:host=$db_host:$db_port;dbname=$db_name", $db_user, $db_pass); $conn->setattribute( pdo::attr_errmode, pdo::errmode_exception ); $conn = null; running php check.php returns [err] sqlstate[hy000] unknown host machine name (severity 2) , though host , port 100% correct , there no firewall issue, since can nmap it: $ nmap -6 -pn -p 1433 ff3e:30:fd66:98:5837:: starting nmap 6.00 ( http://nmap.org ) @ 2016-02-05 16:50 cet nmap scan report <hostname> (ff3e:30:fd66:98:5837::) host (0.0019s latency). port state service 1433/tcp open ms-sql-s why doesen't work? ipv6 issue? if helpful, executing pdo::getavailabledrivers() results in array ( [0] => dblib [1] ...

jquery - Creating a collapsing left nav style column -

i'm trying figure out how combine type of sidebar navigation layout have in jsfiddle . in first example, sidebar collapses main icons , see how done using nav tag not ideal it's physical space not respected content of page. slides under content of page instead of pushing on resize. ideally, i'd nav placed in column keeps it's own space , top aligned other rows in second jsfiddle, resizing rows , columns right accordingly depending on open or collapsed state of it. or there simpler way achieve leaving out nav tag altogether? sidebar functions like: html: <body> <div class="row"> <div class="col-md-12" style="height:60px;"> header area </div> </div> <div class="row"> <div class="col-md-1"> <nav class='sidebar sidebar-menu-collapsed'> <a href='#' id='justify-icon'> <span class='glyphicon glyphicon-align-just...

amazon web services - AWS API gateway logs -

is there way access execution time per each request made aws api gateway? i need single values, not aggregate metrics (= visible in cloudwatch metric dashboard). if enable cloudwatch logs you'll able see each request including timing data per request: https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-cloudwatch-logs/

google chrome - Issue with force install policy? -

i have created extension in production in few hospitals. this published in chrome web store private, , have told clients use force registry key install. apparently works fine , everywhere. [hkey_local_machine\software\policies\google\chrome\extensioninstallforcelist] "1"="nnajclegamhecjhfmefiakmkbompdlfk; https://clients2.google.com/service/update2/crx " then made small update the manifest fix issue content page getting injected twice. added last two: "content_scripts": [ { "matches": ["*://*/*"], "js": ["content.js"], "run_at": "document_end", "all_frames": false } ], so not wanting affect running software in hospital, decided create separate extension package same name , new version (1.1). [hkey_local_machine\software\policies\google\chrome\extensioninstallforcelist] "1"="hmbilmpjeklcbgohfnpnclfn...

javascript - Adobe Acrobat toggle button - show/hide field -

what want button in acrobat hide field if it's visible , show if it's hidden, alternatively. i know there way 1 or either on mouseup, want both using same button. this got far: var strikethrough = this.getfield("text_strikethrough"); if(strikethrough.display = display.hidden){strikethrough.display = display.visible } else {strikethrough.display = display.hidden} unfortunately, doesn't seem working. any appreciated. try following: var strikethrough = this.getfield("text_strikethrough"); if(strikethrough.display == display.hidden){strikethrough.display = display.visible } else {strikethrough.display = display.hidden} i used '==' instead of '=' in "if condition".

c# - Noisy audio clip after decoding from base64 -

Image
i encoded wav file in base64 (audioclipname.txt in resources/sounds). here source wave file then tried decode it, make audioclip , play this: public static void createaudioclip() { string s = resources.load<textasset> ("sounds/audioclipname").text; byte[] bytes = system.convert.frombase64string (s); float[] f = convertbytetofloat(bytes); audioclip audioclip = audioclip.create("testsound", f.length, 2, 44100, false, false); audioclip.setdata(f, 0); audiosource = gameobject.findobjectoftype<audiosource> (); as.playoneshot (audioclip); } private static float[] convertbytetofloat(byte[] array) { float[] floatarr = new float[array.length / 4]; (int = 0; < floatarr.length; i++) { if (bitconverter.islittleendian) array.reverse(array, * 4, 4); floatarr[i] = bitconverter.tosingle(array, * 4); } return floatarr; } every thing works fine, except sound 1 noise. i f...

javascript - Cannot display data in a view in a express nodejs app -

i'm brand new express , node , i'm creating simple express app gets data stored in json file,on post/details view data stored not rendering.i believe way pull data json file can't see error?? here code: posts.json [ { "name": "first name", "description": "test first description", "slug": "first-name", "id": "2f065d59" }, { "name": "second name", "description": "test second description", "slug": "second-name", "id": "0071b034" } ] postslist.js var express = require('express'); var creatordb = require('./database/posts.json'); var fs = require('fs'); var uuid = require('node-uuid'); var list = function () { return creatordb; }; var getbyid = function (id) { for(var i=0;i<creatordb.lengt...

Upgrade dompdf to newer version -

i have old version of dompdf, , need upgrade support headers properly. how go doing this? tried copying new files in directory, no go... from/to versions? dompdf 0.5.x , 0.6.x drop-in compatible, though may need reset font directory, namely removing dompdf_font_family_cache file. file may or may not have .php extension depending on version you're starting from. do not delete file includes .dist in name. you will, of course, need reload fonts. 0.7.0 requires bit more work on implementation side. easiest path replace dompdf directory. usage same, though method names have changed , you'll need reference dompdf namespace. there's work-in-progress migration guide may , usage documentation might useful.

osx - Using docker on Mac. Is it possible to start docker daemon using docker-machine and pass in arguments? -

i have private repo need pass in via "--insecure-registry myprivateregistry:5000" argument works fine in linux environment via command: docker -d --insecure-registry myprivateregistry:5000 i'm not sure how pass when i'm starting mac client however. use docker-machine start , stop default instance, don't see how pass in option. please help. i figured out. need add argument in file after docker-machine ssh default (my running daemon): /var/lib/boot2docker/profile extra_args='--insecure-registry myprivateregistry:5000' restart docker daemon via docker-machine restart default , can connect! this article useful: docker daemon config file on boot2docker / docker-machine / docker toolbox

java - Providing context for @Value fields from a unit test -

i have class this: @service("someclient") public class someclient { @value{some.value} private string somevalue; public void somemethod() { return somevalue; } } and test this: @contextconfiguration(locations = "classpath:/some/where/testapplicationcontext.xml") @runwith(springjunit4classrunner.class) public class someclienttest extends testcase { @value{some.value} private string somevaluetest; @test public void shouldwork() { ... someclient.somemethod() ... } } when wider application running, field somevalue inside someclient class populated properties file referenced testapplicationcontext.xml. when run test in debug mode can see somevaluetest populated in test, when test calls class under test, value not populated. i use advice! can change visibility of field in class, or provide setter, avoid if possible. if isn't, please advise. in order populate fields @value annotation in test need co...

c# - How do I conditionally output HTML with Razor syntax? -

this question has answer here: razor if/else conditional operator syntax [duplicate] 1 answer what i'm trying simple: <td class="bold-and-caps">@{if (++i == 1) { subsec.title } else { string.empty } } </td> except i'm getting "only assignment, call, increment, decrement, await , new object expressions can used statement" on subsec.title , string.empty . how supposed write "if condition, output x" type statements in razor? you can use ternary operator like: <td class="bold-and-caps">@( (++i == 1) ? subsec.title : string.empty)</td>

ionic tabscontroller make not-first active on startup -

when start ionic application tabbar on bottom, starts app first tab active. but have 3 tabs, , want tab in middle active tab starts when open app. can't find in docs how this. someone? there $ionictabsdelegate needs. can inject controller, or app's run block. similar example: function myctrl($scope, $ionictabsdelegate) { //use 1 select second tab (starts 0) $ionictabsdelegate.select(1); } if want have when app starts, put in in run block

download - Web Audio API downloading encoded audio -

i trying decode audio file, apply effect, encode again .wav format user can save file computer. at moment when press "play" button sound plays should, no download box popping up, user download encoded file. <!doctype html> <html> <head> <meta charset="utf-8"/> <title>offlineaudiocontext example</title> <script src="recorder.js"></script> </head> <body> <button class="play">play</button> <script> // define online , offline audio context var audioctx = new audiocontext(); var offlinectx = new offlineaudiocontext(2,44100*10,44100); // define variables var myscript = document.queryselector('script'); var play = document.queryselector('.play'); var stop = document.queryselector('.stop'); // decodeaudiodata decode audio create buffer function getdata() { request = new xmlhttprequest(); ...

Kendo ui grid - get data send on READ on my php -

i have seen this answer reagarding sending params on performing read operation, how access var on on php? this code on client-side: datasource = new kendo.data.datasource({ transport: { read: { url:"basedados.php", type: "post", datatype: "json", data: { "my_param": 1, access_token : "my_token" }, // send parameter "access_token" value "my_token" `read` request }, but on .php file, how access it?: else { $verb = $_server["request_method"]; if ($verb == "post") { header("content-type: application/json"); if($_post['access_token']) // this? { $formdata = $_post["access_token"]; echo $formdata; } edit: answering rick s, let show more of code: parameterm...

machine learning - features' range in logistic regression -

i use logistic regression. know supervised method , needs calculated feature values both in training , test data. there 6 features. although functions produce these features’ values different , maximum value can 1, there 4 features (both in training , test data) have low values. e.g. range between 0 , 0.1 , never 1, more 0.1!!!. these features’ values close each other. other features distributed (they range between 0 , 0.9). difference between these 2 kinds of features high, think causes trouble in learning process logistic regression. right?! need transforming/normalizing these features? highly appreciated. in short: should normalize features prior training. typically - each either in range (like [0,1]) or whitened (mean 0 , std 1). why important? in order make "small" features important lr need high weights in dimension. however, use regularized lr (typically l2 regularized) - in such case hard assign high values these vectors, regularization penalty force m...

sql server - SQL - Complex Delete with Multiple Linking Tables -

i have sql delete need construct, makes use of complex data structure includes 6 tables: users (userid, etc) catalogs (catalogid, etc) libraries (libraryid, etc) user_catalogs (userid, catalogid) user_libraries (userid, libraryid) catalog_libraries (catalogid, libraryid) in order make sense of this, business logic follows: a user assigned catalog (user_catalogs); assigns libraries in catalog (catalog_libraries) user (user_libraries) the user can remove libraries don't want view (hense separate linking table, user_libraries) the problem need solve when catalog deleted, need remove user libraries contained within catalog, not if libraries present in different catalog user has access to. i've been stuck on while now, greatly appreciated.

haskell - How to execute INSERT prepared statement using sqlite-simple? -

sqlite-simple able create prepared statements, cannot figure out how use them instructions not return results. is: main = db <- open "test.db" let = 1 let b = 2 withstatement db "insert test values (?, ?)" $ \stmt -> bind stmt (a, b) ??? reset stmt the 1 api "fits" in ??? nextrow requires data returned. so, how prepared statements return no results supposed used?

php - How can I change this function to display only twice articles? -

Image
i have page in wordpress: link code php: <?php query_posts('cat=16'); $count = 0; while (have_posts()) : the_post(); $count++; if ($count == 1) { ?> <div class="row"> <div class="col-lg-6 col-height" > <div class="text-box-right"> <div class="title-home"><?php the_title(); ?></div> <div class="content-home"><?php the_content(); ?></div> </div> </div> <div class="col-lg-6 col-height" > <div class="prod-box-left"> <?php the_post_thumbnail('news'); ?> </div> </div> </div> <div class="row"> <div class="col-md-4"><div class="content-ho...