Posts

Showing posts from January, 2014

How to Override A Method in Java -

i play robocode (it java programming game). want change method public void onscannedrobot (scannedrobotevent e) { } to public int onscannedrobot(scannedrobotevent e){ } so can adapt robot more if scanned true or false. i heard possible overriding method. tryed it: i wrote: public void onscannedrobot(scannedrobotevent e) { public int onscannedrobot(scannedrobotevent e) { return 1; } } but won't work this won't work because return type of overriden method should same or subtype of return type declared in original method. @ link overriding , overloading

android - linearLayout not included in R java file -

so following tutorial found here: developer site . my code looks below : import android.os.bundle; import android.app.activity; import android.widget.linearlayout; import com.google.android.gms.ads.adrequest; import com.google.android.gms.ads.adsize; import com.google.android.gms.ads.adview; // simple {@link activity} embeds adview. public class mainactivity extends activity { // view show ad. private adview adview; // ad unit id. replace actual ad unit id. private static final string ad_unit_id = "insert_your_ad_unit_id_here"; // called when activity first created. @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); // create ad. adview = new adview(this); adview.setadsize(adsize.banner); adview.setadunitid(ad_unit_id); // add adview view hierarchy. view have no size // until ad loaded. linearlayout layout = (linearlayout) findvi

c++ - Doing a section with one thread and a for-loop with multiple threads -

i using openmp , want spawn threads such 1 thread executes 1 piece of code , finishes, in parallel n threads running iterations of parallel-for loop. execution should this: section (one thread) || section b (parallel-for, multiple threads) | || | | | | | | | | | | | || | | | | | | | | | | | || | | | | | | | | | | | || | | | | | | | | | | | || | | | | | | | | | | v || v v v v v v v v v v i cannot write parallel-for #pragma omp once because not want thread executes section execute for-loop. i have tried this: #pragma omp parallel sections { #pragma omp section { // section } #pragma omp section { // section b; #pragma omp parallel (int = 0; < x; ++i) something(); } } however, parallel

function - Meteor - Setting Session variables in Asynchronous Calls -

i have problem setting session variables inside of meteor.call function. appears meteor won't set session variables whatever ask outside of scope of function. meteor.startup(function () { // code run on server @ startup // prompt name var playername = prompt("please enter name:", ""); meteor.call('createplayer', playername, function(error, result) { console.log("player_id: " + result); session.set("myplayerid", result); console.log("session_player_id: " + session.get("myplayerid")); }); console.log("session_player_id2: " + session.get("myplayerid")); session.set("gamestate", show_lobby); }); the console prints out: player_id: correct id session_player_id: correct id session_player_id2: undefined as can see, session variable no longer correct outside of scope of function. suggestions? the call createplayer asynchronous, order of exec

nginx - Show in php how many 502 errors the server has -

i want show using php how many 502 errors server(nginx) have in last 24 hours. couldn't find simple way thanks! there no single way this. better solution, proxy server accepting requests local ip address. work (not tested) the simple solution: grep '502' access.log | wc -l the complex solution: http { upstream error_logger { server 127.0.0.1:80 } } server { error_page 502 /502.html location / { # config here } location /502.html { internal; proxy_pass http://error_logger/502.php; } } the script (502.php); <?php if($_server['remote_addr'] != '127.0.0.1') die(); // logging here

multithreading - Java When using synchronized do I get volatile functionality for free? -

i read several posts concurrency problems i'm still unsure something. can when using synchronized, volatile functionality free, because when lock on object released, next thread reads modified object. volatile, value of object reflected other threads. when use synchronized, there no possibility reflect due lock on object. when lock released, thread may access it. don't have care reflecting value other threads. understand right? [update] example prints 1 2 3 4 5 6 7 8 9 without volatile. package main; public class counter { public static long count = 0; } public class usecounter implements runnable { public void increment() { synchronized (this) { counter.count++; system.out.print(counter.count + " "); } } @override public void run() { increment(); increment(); increment(); } } public class datarace { public static void main(string args[])

c# - Event aggregator and BLL -

i've got winform app 3 layer architecture ui bll (business logic/layer) dal (data access layer) the dal contains factory instantiate proxies used communicate various apis, require credentials of private methods when app starts, 1 or more proxies initialised singletons (1 per api). references singleton kept within app @ ui , bll levels (and maybedal later). the user can choose @ time modify api credentials via ui. in case, want initialise new instances of the singletons, , make sure correct instances used everywhere (ui, bll, dal) what did far is: notify factory of credentials changes, singletons reinitialised used event aggregator pattern in ui, components holding references singleton notified of credential changes , call proxy factory fresh instance however, wanted use event aggregator pattern in ui. question is: how notify objects in bll/dal of change? a solution never hold instances , call factory, there way of doing want properly? edit : have class

java - why data members are initialized with default values whereas local variables are not? -

can 1 time reason behind assigning default values data members , not local variables ? there specific reason ? example : class { b b; public void f(){ int a; } in above class b initialized null, compiler throws , error saying variable inside f() not initialized. i (as always) practical reason. can initialize object @ 1 point , use time later - have have mechanism ensure initialized default value in case cannot set them immediately. local object on other hand used after declared - can safely assume programmer able initiate them target value, , should encouraged. bottom line - practical reasons, encouraging practices prevent errors, nothing technical limitations.

html - Increasing the size of the field generated from jquery -

Image
the following tag : <input type="text" class="timepicker" name="selectedtime" id="timepicker" /> with of jquery : /* jquery timepicker * replaces single text input set of pulldowns select hour, minute, , am/pm * * copyright (c) 2007 jason huck/core 5 creative (http://www.corefive.com/) * dual licensed under mit (http://www.opensource.org/licenses/mit-license.php) * , gpl (http://www.opensource.org/licenses/gpl-license.php) licenses. * * version 1.0 */ (function($){ jquery.fn.timepicker = function(){ this.each(function(){ // id , value of current element var = this.id; var v = $(this).val(); // options need generate var hrs = new array('01','02','03','04','05','06','07','08','09','10','11','12'); var mins = new array('00','15'

Phalcon php orm can't relate tables -

i'm trying setup 3 tables relationship in phalcon, doesn't seem work. plese tell me doing wrong? here erd of these tables: (erd diagram) here code models , controller authors.php (model) <?php class authors extends \phalcon\mvc\model { /** * * @var integer */ public $id; /** * * @var string */ public $name; /** * * @var string */ public $lastname; /** * initialize method model. */ public function initialize() { $this->setsource('authors'); $this->hasmany('id', 'authorbook', 'authorid'); } /** * independent column mapping. */ public function columnmap() { return array( 'id' => 'id', 'name' => 'name', 'lastname' => 'lastname' ); } books.php(model) <?php class books extends \phalcon\mvc\model { /** * * @var integer */ public $id; /** * * @var string */ public $name; /** * * @var string */ public $yearp

excel - Finding a cell on one sheet, picking up data from the same cell on a different sheet -

basically, comparing sales figures previous years , want macro when new months data added compare same month last year. i have set macro find last cell data in pull through recent months data current year. there way select same cell on different sheet? cannot use same system of finding last line data because on previous years data complete. i hope makes sense! thanks! find cell on first sheet get address use address value second sheet for example: sub samecelldifferentsheet() dim r range, addy string set r = sheets("sheet1").cells.find("happiness") addy = r.address othervalue = sheets("sheet2").range(addy) end sub

php - divide data with a character from value database -

i have data database, : $data = "abcdefghi"; i want divide data each of 3 characters, , added character newline. confused did count characters split. know use modulo ( % 3) , if print : abc def ghi i not know syntax should used. can me? $data = "abcdefghi"; $newdata = implode("\n", str_split($data, 3)); var_dump($newdata);

html - Text typed in text box shown in URL bar / generating profile page -

text typed in text box shown in url bar including password. way fix not show on url bar? tried googling results irrelevant. it looks this: login_page.html?email=asdasdasd&password=asdasdasd you used method="get" in form this: <form method="get"> try using post method instead this: <form method="post"> then, if you're using php, example, on server side inputs of form, you'll have make sure you're looking super global $_post instead of $_get .

php - CakePHP: Simple Acl Controlled Application - Not allowing me to add new user the groups are missing -

i can't add user application because group_id missing.. followed tutorial: http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-controlled-application/simple-acl-controlled-application.html group select empty , need add group created before my model/user.php <?php app::uses('appmodel', 'model'); app::uses('authcomponent', 'controller/component'); class user extends appmodel { public $belongsto = array('group'); public $actsas = array('acl' => array('type' => 'requester')); /** validation rules */ public $validate = array( 'username' => array( 'notempty' => array( 'rule' => array('notempty'), ), ), 'password' => array( 'notempty' => array( 'rule' => array('notempty'), )

php - How to create the same secret key both for Android and server -

based on code of following link https://github.com/serpro/android-php-encrypt-decrypt i have made own implementation of encryption/decryption mechanism between android , server (api written in php). the example uses same iv in real world case scenario use different 1 in each call. easy implement since iv can transferred without caring whether listened or not. my question how create different secret key each new user during registration, both @ android device , server side (the unique secret key stored in mysql server side , sqlite or shared preferences on android side)? if secret key created either @ android or server , transmitted other part stolen "listener" , communication no longer safe. if secret key created algorithm, same algorithm must implemented in both android , server. android apk file decompiled , result algorithm found , secret keys predicted. it seems vicious circle. safe way create same unique secret key each user both @ client side (android)

javascript - <iframe> hidden by CSS not rendering correctly when shown -

Image
i have <iframe> google maps on website. have map hidden css (it inside <div> display: none; ) when show map again (using jquery 's .show() method), <iframe> not rendered correctly (instead of showing area selected shows full world minimal zoom). tested in chrome, firefox , ie (only chrome renders correctly, in cases). am doing wrong or bug in browser? is there simple solution can use prevent these errors appearing? thanks advices :) edit : changed different maps provider , works bit better, still has errors: rendering bug in firefox: iframe code: <iframe src="http://api4.mapy.cz/frame?url=http%3a%2f%2fmapy.cz%2fs%2f9hdw&amp;z=13&amp;x=14.484938099932673&amp;y=50.10842090294788&amp;o=0&amp;layer=14&amp;dx=14.484938099932673&amp;dy=50.10842090294788&amp;dt=kovaneck%c3%a1%202295%2f9&amp;move=1&amp;prev=1&amp;w=500&amp;h=333" width="500" height="333" style="

javascript - jQuery text change smoothly -

i have following html , jquery code warn users using 'remember me' check box follows: in html: <input type="checkbox" id="remember" name="remember"> remember me <span id="remember_feedback"></span> in script: $('#remember').change(function(){ if(this.checked){ $('#remember_feedback').text('(don\'t use on public computer)'); }else{ $('#remember_feedback').text(''); } }); it works fine text smoothly / changes i've seen on sites not pops in , out now, possible without using plugins? you can this: $('#remember').change(function(){ if(this.checked){ $('#remember_feedback').hide().text('(don\'t use on public computer)').fadein('slow'); }else{ $('#remember_feedback').fadeout('slow'); } }); jsfiddle example

javascript - Sort unparsable tablesorter date column by unix timestamp -

i need sort jquery tablesorter unix timestamp rather unpredictable displayed date depends upon locale, want try possible solution hidden span can used sort date column. how can element inserted in front of text or @ beginning of element while retaining existing text contents in containing element? basic intent given element: <td id="mytd">difficult date parse</td> i'd turn this: <td id="mytd"> <span style="display:none">1398019663</span> difficult date parse </td> this looks job html5 data attributes , in : <td id="mytd" data-sortkey="1398019663"> difficult date parse </td> you can , set value of data attributes using data function in jquery.

Croogo : Different layout for different Locate -

how set different layout different locate "translate plugin" ex: with link: [http://example.com/eng] should render default.ctp english and link: [http://example.com/ja] should render default.ctp japanese one way can reading $this->request->params['locale'] variable, available in controller/appcontroller.php file, , change layout according it. this: class appcontroller extends croogoappcontroller { public function beforerender() { // code... // first, checks if locale parameter not empty if(!empty($this->request->params['locale'])) // then, sets layout each case. // in example, user eng , ja switch($this->request->params['locale']) { case 'eng': $this->layout = 'croogo.eng'; break; case 'esp': $this->layout = 'croogo.ja'

data is not showing when come back to the previous tab in android -

in application, i'm showing 4 tabs using viewpager. tab1 | tab2 | tab3 | tab4 public class sports_swipe extends fragmentactivity implements actionbar.tablistener { private viewpager viewpager; private sports_swipeadapter madapter; private actionbarsherlock msherlock; private actionbar actionbar; // tab titles private string[] tabs = { "tab1", "tab2", "tab3", "tab4", "tab5"}; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.sports_swipe); // initilization viewpager = (viewpager) findviewbyid(r.id.pager); madapter = new sports_swipeadapter(getsupportfragmentmanager()); viewpager.setadapter(madapter); actionbar.setnavigationmode(actionbar.navigation_mode_tabs); // adding tabs (string tab_name : tabs) { actionbar.addtab(actionbar.newtab().settext(tab_name).settablistener(this)); } /**

objective c - convert a unicode string like "\udddd\udddd" to human readable string -

now have string "\u7c6e\u54c1\u23a8\u8357/\u4e01\u8f77\u7ba2\u7409" in xcode, want convert "籮品⎨荗/丁轷箢琉" objective-c. but can't find api finish. should do? string content instead of string literal. my application not need convert, situation that: have response server name = "\u672a\u6765\u822a\u8def"; i print log: nsstring *n = dict[@"name"]; nslog(@"%@",n); //未来航路 i think application same.

Bluetooth Socket not connecting android bluetooth -

i want connect 2 android devices via bluetooth,but not connecting @ all. here code connect far.....what can done,i have searched on internet have no solution yet....... kindly me out // unique uuid application private static uuid my_uuid_secure = uuid.fromstring("00001101-0000-1000-8000-00805f9b34fb"); private static uuid my_uuid_insecure=uuid.fromstring("00001101-0000-1000-8000-00805f9b34fb"); private class connectthread extends thread { private final bluetoothsocket mmsocket; private final bluetoothdevice mmdevice; private string msockettype; public connectthread(bluetoothdevice device, boolean secure) { mmdevice = device; bluetoothsocket tmp = null; msockettype = secure ? "secure" : "insecure"; system.out.println("uuid created "+my_uuid_secure); // bluetoothsocket connection // given bluetoothdevice try { if (secure) {

C++ Visual Studio succesful compiling but exe not found in debug -

my project compiles , run in release. but when set debug, compiles, not run. .exe disappears when try run , throws me error " xxx.exe not found" the weirdest thing when remove specific function/method calls on code, runs. i've found issue, antivirus (avast), deleting .exe without noticing me. (i'am answering own question maybe can other people)

html - Delayed loading GIF image from CSS background -

this situation; displaying ads on website want display specific banner if visitor using ad blocker. first thing i've looked script detects ad blocker, after trying few different scripts seems of them no longer work (at least, couldn't them work). so gave on , went different solution. displaying css background image behind ad if ad isn't shown, image is. because typical ad takes moment load made background image gif image 2 seconds of transparency. works charm first time, when reload page or open different page gif animation doesn't play , instantly displays last frame, skipping transparency. i've tried adding random stuff behind url in css, didn't work. i've tried data/inline version of image, didn't seem work either. i'm kinda running out of solutions. the css: .ads { position: relative; top: 15px; float: right; height: 60px; width: 468px; background-image: url('/images/ads/ads_top.gif?randomstuff=39485') } i'm looking eit

javascript - How to get the function name from within that function? -

how can access function name inside function? // parasitic inheritance var ns.parent.child = function() { var parent = new ns.parent(); parent.newfunc = function() { } return parent; } var ns.parent = function() { // @ point, want know child called parent // ie } var obj = new ns.parent.child(); in es5, best thing is: function functionname(fun) { var ret = fun.tostring(); ret = ret.substr('function '.length); ret = ret.substr(0, ret.indexof('(')); return ret; } using function.caller non-standard , arguments.callee forbidden in strict mode. edit: nus's regex based answer below achieves same thing, has better performance! in es6, can use myfunction.name . note: beware js minifiers might throw away function names, compress better; may need tweak settings avoid that.

javascript - Testing animations angular 1.2+ -

anyone know how test animations in angular? animations built using either $animateprovider or angular.module('', []).animate() ? i'm building animations library, , it's nice, can't find proper way test animations using $animate. never work. have hacked work, i'm pretty recreating animations inside each test. make sure it's not animations, created new 1 on test. got straight out of angular's source code , still not work. describe('testing async animations', function() { var = false; beforeeach(module('nganimate')); beforeeach(module('nganimatemock')); beforeeach(module(function($animateprovider){ $animateprovider.register('.fade', function(){ return { enter: function(element, done){ console.log('here'); = true; done(); } }; }); })); /* done() method mocha provides. make work in jasmine, follow example using asynchronous te

$ sign in jquery to javascript -

i looking way write file in javascript.i found excatly looking here but problem uses jquery.i suppose task pure javascript. my question how convert $ sign pure javascript without including jquery script in code. in short how convert code pure javascript if possible. function createdownloadlink(anchorselector, str, filename){ if(window.navigator.mssaveoropenblob) { var filedata = [str]; blobobject = new blob(filedata); $(anchorselector).click(function(){ window.navigator.mssaveoropenblob(blobobject, filename); }); } else { var url = "data:text/plain;charset=utf-8," + encodeuricomponent(str); $(anchorselector).attr("download", filename); //when try document,getelementbyid not work. $(anchorselector).attr("href", url); } } $(function () { var str = "kgopelo name in place"; createdownloadlink("#export",str,"file.txt"

php - How can I suppress a notice error in codeigniter? -

i want suppress notices in codeigniter error log during cronjob. i've tried using @ in front of line, still prints notice in log: this row generating notice: @$resultarray[1][2]++; the notice: ... severity: notice --> undefined offset: 1 ... what doing wrong here? (i'm using overthought, please no messages claiming not use @, :) ) to have php report errors except e_notice, call php error_reporting function so: error_reporting(e_all & ~e_notice); i believe best way configure index.php @ root of application first detect application environment , conditionally set php errors reported. index.php if (defined('environment')) { switch (environment) { case 'development': case 'testing': case 'staging': error_reporting(e_all & ~e_notice); break; case 'production': error_reporting(0); break; default: exit('the application environment not set correctl

How PostgreSQL execute query? -

can explain why postgresql works so: if execute query select * project_archive_doc pad, project_archive_doc pad2 pad.id = pad2.id it simple join , explain looks this: hash join (cost=6.85..13.91 rows=171 width=150) hash cond: (pad.id = pad2.id) -> seq scan on project_archive_doc pad (cost=0.00..4.71 rows=171 width=75) -> hash (cost=4.71..4.71 rows=171 width=75) -> seq scan on project_archive_doc pad2 (cost=0.00..4.71 rows=171 width=75) but if execute query: select * project_archive_doc pad pad.id = ( select pad2.id project_archive_doc pad2 pad2.project_id = pad.project_id order pad2.created_at limit 1) there no joins , explain looks like: seq scan on project_archive_doc pad (cost=0.00..886.22 rows=1 width=75)" filter: (id = (subplan 1)) subplan 1 -> limit (cost=5.15..5.15 rows=1 width=8) -> sort (cost=5.15..5.15 rows=1 width=8)

c - How to do this initialization? -

i have structure, need initialize @ compile time. here current (pseudo)code: struct { int a; int b; }; struct b { struct а[16][3]; }; #define default {{ \ .a = 1, \ .b = 2, \ }, \ { \ .a = 3, \ .b = 8, \ }, \ { \ .a = 11, \ .b = 29, \ }} #define default2 default, default #define default4 default2, default2 #define default8 default4, default4 #define default16 default8, default8 struct b b = {{default16}}; i don't understand code: why need double braces on last line? moreover, why need double braces in definition of default. understand { .a = 3, .b = 8, } is ordinary structure initialization. second pair of braces seems if initializing b array of 16 objects of type struct [3] . why not list values

javascript setTimeout(); doesn't work on linux (firefox) -

i making animation, uses settimeout(); function in javascript. animation works on chrome, firefox, on smartphone. problem firefox on ubuntu. console giving me error: referenceerror: loop not defined @ file:///home/nigga/github/imgdrop/imgdrop.js:45 the code: function loop() { regenerate(); animate(); settimeout("loop()", 1000/fps); } edit: i tried @lol suggested, works on linux, doesnt work on windows (firefox , ie). function loop() { regenerate(); animate(); settimeout(function() {loop();}, 1000); } or function loop() { regenerate(); animate(); settimeout(loop, 1000); }

supervisord - Nginx with Supervisor keep changing status b/w Running and Starting -

here's preview of status running supervisorctl status every 2 seconds: [root@docker] ~ # supervisorctl status nginx running pid 2090, uptime 0:00:02 [root@docker] ~ # supervisorctl status nginx starting [root@docker] redis-2.8.9 # supervisorctl status nginx running pid 2110, uptime 0:00:01 is normal thing nginx respawn every few seconds ? knowing nginx setup run in background setup: [program:nginx] command=/usr/sbin/nginx stdout_events_enabled=true stderr_events_enabled=true its been long time, might else... set daemon off in nginx config. supervisord requires processes not run daemons. you can set directly supervisor command: command=/usr/sbin/nginx -g "daemon off;"

maven - How to avoid the manifest file being overwritten by proguard -

i'm using several libraries in java application. in pom.xml proguard maven plugin includes them so: <inclusion> <groupid>javafx</groupid> <artifactid>jfxrt</artifactid> <library>true</library> <filter>!meta-inf/**</filter> </inclusion> i noticed, when include libraries <library> set true, manifest file gets replaced, allthough specify <filter> libraries. need include them <library> set true, since otherwise of them don't work. now after building jar, won't start, because manifest doesn't contain path main class more. i found 2 approaches, solve this. however, both don't work. first approach: <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-antrun-plugin</artifactid> <version>1.3</version> <executions> <execution> <phase>install</

c - ALSA programming: how to stop immediately -

i building audio app playback , stop features. function playaudio() playback, stopaudio() stop. expected file format wav. the main implementation of playaudio() below: playaudio() { ... ... int err = snd_pcm_open(&handle, "default", snd_pcm_stream_playback, 0); if ( err < 0 ) { printf("scm open failed: %s\n", snd_strerror(err)); exit(err); } while ( 0 < numofframes) { ... ... ssize_t frames = snd_pcm_writei(handle, &buffer[0], periodsize); ... ... } snd_pcm_drain(handle); snd_pcm_close(handle); } stopaudio() { snd_pcm_drop( m_handle ); } while audio playing back, program blocked @ line of snd_pcm_drain(handle); until playback completion. during period, expect stop audio play. action click stop button on ui , call snd_pcm_drop( m_handle ) finally. voice stopped, programm running still staying @ line of snd_pcm_drain(handle) untils several seconds later

javascript - Google map API resize doesn't work -

i have implement google map api. have 2 maps loading on same page. 1 directly shown when load page. second show when click on button. modal map appear. modal display none display block after click. map appear no in fullsize. here js append google map. $(document).ready(function() { function getdistancefromlatloninkm(lat1,lon1,lat2,lon2) { var r = 6371; var dlat = deg2rad(lat2-lat1); var dlon = deg2rad(lon2-lon1); var = math.sin(dlat/2) * math.sin(dlat/2) + math.cos(deg2rad(lat1)) * math.cos(deg2rad(lat2)) * math.sin(dlon/2) * math.sin(dlon/2); var c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a)); var d = r * c; return d.tofixed(0); } function deg2rad(deg) { return deg * (math.pi/180) } function initialize() { $('.map_canvas').each(function(index, element) { var markers = new array(); var map_

Java minimax abalone implementation -

i want implement minimax in abalone game don't know how it. exact don't know when algo need max or min player. if have understand logic, need min player , max ai ? this wikipedia pseudo code function minimax(node, depth, maximizingplayer) if depth = 0 or node terminal node return heuristic value of node if maximizingplayer bestvalue := -∞ each child of node val := minimax(child, depth - 1, false)) bestvalue := max(bestvalue, val); return bestvalue else bestvalue := +∞ each child of node val := minimax(child, depth - 1, true)) bestvalue := min(bestvalue, val); return bestvalue (* initial call maximizing player *) minimax(origin, depth, true) and implementation private integer minimax(board board, integer depth, color current, boolean maximizingplayer) { integer bestvalue; if (0 == depth) return ((current == selfcolor) ? 1 : -1) * th

Using QR decomposition to solve least squares in Matlab -

i using matlab estimate regression model ordinary least squares (ols). the model y = xb , x sparse matrix dimension 500000 x 2500 . i'm using qr decomposition: [c,r] = qr(x,y,0) and estimating b with b = r\c my question whether need worried numerical errors here. there additional iteration need do? should check condition number of r , or r'r ? guidance appreciated. the matlab recommended way is: b = x\y; check http://www.mathworks.com/help/matlab/ref/mldivide.html , section more about in particular, see how matlab handles different cases under hood. if want exploit sparseness of x declare x sparse, x = sparse(x) , before call \ .

database - Wordpress post content disappears when I click edit post -

i working on site: greatlakesecho.org when try edit post, content disappears visual editor. running latest version of word press happened on previous version well. using project largo theme site. the site migrated new host , has gone overhaul responsive design. first started happening when changed character encoding remove odd symbols posts. successful in changing utf16. @ point older posts created before migration disappear when clicked edit. have since updated latest version of word press , happens every post. i've made sure wp-config has correct encoding. happens themes. tried deactivating plugins. i see when enabling debuggin: wordpress database error: [table 'greatlak_wp776.wp_itsec_lockouts' doesn't exist] select lockout_host wp_itsec_lockouts lockout_active =1 , lockout_expire_gmt > '2014-04-22 19:52:36' , lockout_host ='35.9.132.246'; wordpress database error: [table 'greatlak_wp776.wp_itsec_lockouts' doesn't exi

html - JQuery script probably syntax mistake -

i don't know jquery, have script.js file: $(document).ready(function() { var main_nav = $("#main-nav"); var main_section = $("#main-section"); var main_footer = $("#main-footer"); var main_nav_position = main_nav.position(); $(window).scroll(function() { if ($(window).scrolltop() >= main_nav_position.top) { main_nav.addclass("main-nav-sticky"); main_section.addclass("sticky-adjust"); main_footer.addclass("sticky-adjust"); } else { main_nav.removeclass("main-nav-sticky"); main_section.removeclass("sticky-adjust"); main_footer.removeclass("sticky-adjust"); } }); }); $(document).ready(function() { switch (window.location.pathname) { case 'index.html': $('#shop-button').attr('id','shop-button-disabled'); break; case 'staff.html': $('#staff-button

Visual C++ Function Description Like in C# -

in c#, if typed console.writeline , intellisense show small tool-tip describes writeline function telling prints line console etc. on other hand, in c++ if type std::cout intellisense same. instead tells functions' overloads , inheritance. question: how c# intellisense provides me snippet descriptions functions while typing them ? instead of going internet reading description foreach function .

sql server - How to protect sql statement from Divide By Zero error -

i'm in process of creating reports take finite total (lets 2,500) of products (for example lets ice cream cones) , counts how many of them broken before serving. now actual count code of broken cones i've got down. select count(broken_cones) [ice].[ice_cream_inventory] broken_cones = 'yes' however, need percentage of broken cones total well. i've been playing around code keep running 'divide zero' error code below. select cast(nullif((.01 * 2500)/count(broken_cones), 0) decimal(7,4)) [ice].[ice_cream_inventory] broken_cones = 'yes' for right now, there aren't broken cones (and won't while) total right zero. how can show null scenario zero? i tried place isnull statement in mix kept getting 'divide zero' error. doing right? ::edit:: here's ended with. select case when count(broken_cones) = 0 0 else cast(nullif((.01 * 2500)/count(broken_cones), 0) decimal(7,4)) end [ice].[ice_cream_inventory] broken_cone

passport.js - Setting up Passport - LinkedIn OAuth2.0 Strategy; Cannot see Authorization page loaded -

i new developing spa. have using angularjs , nodejs passport. have succesfully implemented localstrategy. trying : , linkedinstrategy = require('passport-linkedin-oauth2').strategy when attempt login request, receive following error: xmlhttprequest cannot load "http://localhost:8000/login/linkedin. request redirected 'https://www.linkedin.com/uas/oauth2/authorization?state=some%20state&respon… %2fcallback&scope=r_emailaddress%20r_basicprofile&client_id=7708er3z2xorot'" , disallowed cross-origin requests require preflight. if manually click on link show me authorization page; also, notice in linkedin api request count going up, cannot authorization page appear? i found out had done wrong , wanted share correction , solution: originally, making $http.get call (using angularjs) client server (nodejs). server called function called passport. instead set window address $window.location.href = myserverroutelinkedin

jquery - error saving comment ajax -

i'm using simple_form gem tried doing without gem , still same error. don't think it's syntax, tried in haml , same error. update: new fixed issues comment below i'm getting "error saving comment" form comments controller below @ end i'm following tut http://twocentstudios.com/blog/2012/11/15/simple-ajax-comments-with-rails/ comments/_form.html.erb <%= simple_form_for comment, :remote => true |f| %> <%= f.input :body, :input_html => { :rows => "2" }, :label => false %> <%= f.input :commentable_id, :as => :hidden, :value => comment.commentable_id %> <%= f.input :commentable_type, :as => :hidden, :value => comment.commentable_type %> <%= f.button :submit, :class => "btn btn-primary", :disable_with => "submitting…" %> <% end %> comments/_comment.html.erb <div class="comment" id="comment-<%= comment.id %>"> <h

How to work with the Entity Registration module in Drupal 7? -

i working on entity registration module in drupal 7 site. have created entity-type , have added fields, stuck @ point have create registrants , display registration form on site. any suggestions me going? according community documentation of entity registrations module: create @ least 1 registration bundle (or type) @ admin/structure/registration/registration_types, content type. add registration field entity want enable registrations for. note display options: default, link registration form, , embedding actual form. when add or edit entity, select registration bundle want use for. registrations enabled entity , can configure registration settings via local task.

android - Elements SlidingMenu not clickable -

encountered such problem. slidingmenu use, , when put forward, in menu not active, not clickable. there simple test button, when push happens absolutely nothing. slidingmenu menu = new slidingmenu(this); // экземпляр класса menu.setmode(slidingmenu.left); menu.settouchmodebehind(slidingmenu.touchmode_fullscreen); menu.setshadowdrawable(r.drawable.shadows_menu_swype1); menu.setshadowwidth(15); menu.setfadedegree(0.50f); menu.attachtoactivity(this, slidingmenu.sliding_window); menu.setbehindwidth(300); menu.setmenu(r.layout.menu_swype); xml <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/shadows_menu_swype2" android:orientation="vertical" > <button android:layout_height="wrap_content"

c++ - Cannot properly memcpy a char array to struct -

so have construct called packet struct packet { unsigned int packet_type; wchar_t packet_length[128]; wchar_t file_name[256]; wchar_t template_name[256]; wchar_t file_name_list[1024]; wchar_t file_data[1024]; void serialize(char * dat) { memcpy(dat, this, sizeof(packet)); } void deserialize(const char * dat) { memcpy(this, dat, sizeof(packet)); } }; i'm trying desieralize data {byte[2692]} [0] 0 unsigned int packet_type; (4 bytes) [1] 0 [2] 0 [3] 0 [4] 50 '2' wchar_t packet_length[128]; (128 bytes) [3] 0 [5] 54 '6' [3] 0 [6] 57 '9' [3] 0 [7] 50 '2' [8] 0 [...] 0 [132] 112 'p' wchar_t file_name[256]; (256 bytes) [133] 0 [134] 104 'h' [...] 0 but memcpy in deserialze isn't giving me file_name, give me packet_length. what's this? thanks! edit: it's clear me wchar_t taking more space once thought; however, i

python - Pygame key press event -

hey guys i'm trying add movement sprite have , i'm having trouble, heres code. i'm using wasd keys move player around place, can't seem figure out why won't move. appreciated. import pygame import math sys import exit pygame.locals import * pygame.mixer.init class player(pygame.sprite.sprite): def __init__(self, screen): pygame.sprite.sprite.__init__(self) self.image = pygame.image.load("ryu.png") transcolor = self.image.get_at((1, 1)) self.image.set_colorkey(transcolor) self.rect = self.image.get_rect() self.dx = screen.get_width()/2 self.dy = screen.get_height()/2 self.rect.center = (self.dx, self.dy) self.screen = screen self.speed = 4 def update(self): self.rect.center = (self.dx, self.dy) def returnposition(self): return self.rect.center def moveleft(self): if self.rect.left < 0: