Posts

angularjs - Convert all falsey values in a Javascript object to blank string -

is there way convert undefined, nan, etc. values in javascript object blank string (so it's @ least defined). ex: javascriptobject = defineundefined(javascriptobject) something works that. one idea might check if value nan, , set equal 0 (or value of choosing). if (isnan(x)) x = 0; for more information on isnan, can take here: https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/isnan

Wordpress Meta Field - Finding the values of a select meta- field -

i have created custom field ( select box) post type - flavors. custom field type can have flavors vanilla, chocolate etc.. set @ run-time administrators. i have requirement, need list values @ run time has been set custom field type choices. how do this? get_post_meta return value set particular post id. if understand requirement right (and tbh i'm not sure), following code should need. global $wpdb; $flavors=$wpdb->get_col('select `meta_value` `' . $wpdb->prefix . 'postmeta` `meta_key`=\'flavor\' group `meta_value`;'); if (count($flavors) > 0) { foreach ($flavors $flavor) { //do whatever need $flavor (meta_value) } }

Enhance MediaWiki Search -

i wondering if can enhance search facility in mediawiki, returning suggested result set closest search key instead of return 0 results page. for eg. have created ff: articles, guidelines database management guidelines sql reporting but when try search entering guidelines , instead of showing me or suggesting me close, returns 0 results prompting me if want create it. would little suggestive, can make little suggestive? try installing lucene in place of default mediawiki search engine, merely mysql full-text indexing. lucene not solve above problem, work if you'd mistyped "guidlines" , ask, "did mean 'guidelines'?" http://www.mediawiki.org/wiki/extension:lucene-search http://www.mediawiki.org/wiki/extension:mwsearch lucene nontrivial install, results worth it.

c# - Value cannot be null. Parameter name: entity -

this question has answer here: asp.net mvc: why view passing null models controller? 2 answers i have following view (basic "edit" template) @model successstories.models.testimonials @using (html.beginform()) { @html.antiforgerytoken() <div class="form-horizontal"> <h4>testimonials</h4> <hr /> @html.validationsummary(true, "", new { @class = "text-danger" }) @html.hiddenfor(model => model.id) <div class="form-group"> @html.labelfor(model => model.testimonial, htmlattributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @html.editorfor(model => model.testimonial, new { htmlattributes = new { @class = "form-contro...

c++11 - C++ run time with different loops -

why both of these loops take same amount of time, shouldn't if statement make first single loop slower? // example program #include <iostream> #include <string> #include <vector> using namespace std; int main() { int counter = 0; #ifdef single cout << "one loop\n"; for(int =0;i<10000000;i++) { if(i != 50000) counter+=i; } #else cout << "two loops\n"; for(int = 0;i<50000;i++) { counter+=i; } for(int = 50001;i<10000000;i++) { counter+=i; } #endif return 0; } i get, time, following results: time ./test 1 loop real 0m0.004s user 0m0.001s sys 0m0.002s and two loops real 0m0.004s user 0m0.001s sys 0m0.002s i did research , said cause of branching i'm not sure if reason, compiled g++ -std=c++11 -o3 test.cpp -dsingle -o test the overall loop bare...

osx - automating zsh shell scripts within OS X -

is there way automate task (zsh shell script) using type of scheduler. if so, how? for example, if running zsh shell script within system named zshprogram1.zsh within directory /users/myname/zshtest , want run @ 1:35 pm hst daily, how go doing that? also, i'm assuming work if laptop on. work if it's on in sleep mode? check out crontab or launchctl . for example, crontab run crontab -e terminal , paste following line editor comes up 35 13 * * * /users/myname/zshtest/zshprogram1.zsh to have zshprogram1.zsh run @ 1:35 pm every day. launchctl bit more complicated configure, apple recommends on crontab future, might worthwhile check out.

Javascript check if transparent image on canvas has been clicked -

i have canvas, , drew image transparent, , has polygon shape. need check if image has been clicked. i have cords { x:30, y:20, w:100, h:100 } i check box or circle click if rigid polygon there pixel click test or convex algorithm(but don't want have specify edges)? thank you. one solution implement pixel detection secondary canvas used map. draw shape onto scene canvas. draw exact shape onto second canvas, set color rgb(0,0,0). store color reference in sort of map reference first 'shape' e.g. var pixelmap = { '000' : 'rectangle 1', '001' : 'rectangle 2' }; every time draw new shape canvas, increase rgb 1. unless have on 16.7 million shapes (256^3), method should suffice. heres example implementation : https://jsfiddle.net/mikeschultz/nbtnxpf2/