Posts

Showing posts from February, 2010

ruby on rails - Notifications not working with Test::Unit on Mac -

i've got rails project test suite uses test::unit. i'm trying set guard , spork run tests automatically , fire notifications on pass/fail; guard , spork running fine, , fire notification when start up, can't test notifications work. i've tried using both growl , mac os x notifications terminal-notifier-guard. here's relevant part of gemfile: group :test gem 'sqlite3' gem 'selenium-webdriver' gem 'rr', :require => false gem 'capybara' gem 'database_cleaner' gem 'timecop' end group :test, :development gem 'guard' gem 'spork' gem 'spork-testunit' gem 'guard-test' gem 'guard-rake' gem 'guard-spork' gem 'terminal-notifier-guard', :require => false gem 'rb-inotify', require: false gem 'rb-fsevent', require: false gem 'rb-fchange', require: false end and test_helper.rb: # -*- encoding : utf-8 -*-

swing - INSERT stsement not working in java program -

hi have program connects embedded derby database , should reference database data. trying test database out using simple insert statement, not working. please help. import java.awt.borderlayout; import java.awt.eventqueue; import java.awt.label; import javax.swing.jframe; import javax.swing.jpanel; import javax.swing.border.emptyborder; import javax.swing.jtabbedpane; import javax.swing.jlabel; import javax.swing.jtextfield; import javax.swing.buttongroup; import javax.swing.jcombobox; import javax.swing.jradiobutton; import java.awt.button; import java.awt.event.actionlistener; import java.awt.event.actionevent; import javax.swing.jbutton; import javax.swing.jlist; import java.awt.list; import java.sql.connection; import java.sql.drivermanager; import java.sql.resultset; import java.sql.sqlexception; import java.sql.statement; import java.sql.resultsetmetadata; public class auto extends javax.swing.jframe implements actionlistener { /** * */ private stati

c - How do you add a SQLite3 created function to an iOS 9 project? -

i trying build simple sqlite full text search (fts4) ios 9/xcode 7 project w/ swift 2.2. accessing sqlite3 c api directly swift, see no need use bloated wrapper library. have full text search working perfectly. need create ranking function results. have c code ranking function, problem have no idea how to: get c source or compiled executable of ranking function code compiled ios project. create or load ranking function within sqlite (sqlite3_create_function) have sqlite recognize created function so basically, have c source code of ranking function , have failed @ every attempt sqlite recognize function. thanks help.

console application - C# I can't get CreateNoWindow to work - not even the msdn.com example -

i have looked here https://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.createnowindow(v=vs.110).aspx and understand a) not every program respects createnowindow request and b) requires useshellexecute=false (default true). c) meant indicate whether window created. (it won't ever hide parent window). it's speaking of whether window created child process. (msdn says 'new window') d) createnowindow defaults false. i running cmd, though clicking play in visual studio illustrates same behaviour. i set createnowindow false i'd have thought it'd create new window child process. but not. task manager shows second instance of cmd.exe there's still 1 window can see. below paste 1 window. has loaded child cmd.exe in parent window (the 1 cmd window) if set createnowindow true or false, seems make no difference. so i'm not getting example @ msdn link work. c:\crp>type aaa.csc using system.diagnostics; cla

linux - Fast ways to make new multiple files from one file matching multiple patterns -

i have 1 file called uniq.txt (20,000 lines). head uniq.txt 1 103 10357 1124 1126 i have file called all.txt (106,371,111 lines) head all.txt cg0001 ? 1 -0.394991215660192 cg0001 ab 103 -0.502535661820095 cg0002 10357 -0.563632386999913 cg0003 ? 1 -0.394991215660444 cg0004 ? 1 -0.502535661820095 cg0004 10357 -0.563632386999913 cg0003 ab 103 -0.64926706504459 i make new 20,000 files all.txt matching each line pattern of uniq.txt. example, head 1.newfile.txt cg0001 ? 1 -0.394991215660192 cg0003 ? 1 -0.394991215660444 cg0004 ? 1 -0.502535661820095 head 103.newfile.txt cg0001 ab 103 -0.502535661820095 cg0003 ab 103 -0.64926706504459 head 10357.newfile.txt cg0002 10357 -0.563632386999913 cg0004 10357 -0.563632386999913 is there way can make new 20,000 files fast? current script takes 1 min make 1 new file. guess it's scanning all.txt file every time makes new file. you can try aw

java - How can I remove a specific object from an arrayList and how can I check if it contains this object? -

i have arraylist type shopping cart. when add new item shopping cart, check first if shopping cart has item. cart.contains(item) method didn't work, return false there same item in cart. second problem not able remove item object shopping cart arraylist. code shows below: @controller @requestmapping("/addto.htm") public class addtocontroller{ @suppresswarnings("unchecked") @requestmapping(method=requestmethod.get) protected modelandview handlerequestinternal(httpservletrequest request, httpservletresponse response) throws exception { httpsession session = request.getsession(); string action = request.getparameter("action"); system.out.println(action); modelandview mv = new modelandview(); arraylist<item> cart; if(session.getattribute("cart") != null) { cart = (arraylist<item>) session.getattribute("cart"); }else { cart = new

javascript - JS - Confusion on function that rewrite tyself -

to js experts, im still trying learn js using books stoyan stefanov (object-oriented js). get stuck on page 83 , following codes must work, a = a(); // first call function a() { alert('a'); = function() { // this. redefining functions. alert('b'); }; } a(); // second call the book suggested if call/invoke 2nd time alert b after alert occur. however, instead of working gives typeerror: not function after alert a. whats mistake here?? thank you the first line: a = a(); calls function , assigns return value a . function's return value undefined - function doesn't explicitly return value return implicitly return undefined (unless called new , can ignore here). on last line when a() saying undefined() . , of course undefined not function. did code in book a = a(); ? change a() , it'll work expected. alternatively change function return new function on first call rather overwriting a directly: a =

mysql - how can i get variables after login without using session in php? -

i made login system using php connected mysql database, how can make show username after login, goes on main login screen -> database check -> success page. without using session on success page how can show username, registered? so, said: how can show username, registered? in other word, need username displayed correct password, whatever user logged-in , right? so process login screen -> submit -> save username in cookie -> db check, password correct -> fetch user full name , return html login screen -> submit -> save username in cookie -> db check, password wrong -> show error. i think fit request : display username in fact, the user not in "logged-in" status, therefore, user can nothing identity if first few homework in "web programming 101", may save username in cookie when login succeed. read username value cookie identify user made request. but that's nightmare security, kid can hack sy

java - Using a method to convert Integer to String and print in TextView -

i trying calculate number of pages seek progress bar , having trouble printing string textview. appreciated. here code update: gives me value cannot divide 0 when runs through update(); method in calculate_pages new_book.java package com.example.barbersp.dailyreader; import android.app.activity; import android.content.intent; import android.os.bundle; import android.util.log; import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.seekbar; import android.widget.textview; import android.widget.toast; public class new_book extends activity { public int first_page_number_update, number_of_days_to_read_update, last_page_number_update; private textview book_title; private edittext edit_book_title; private textview author_name; private edittext edit_author_name; private textview first_page_number; private seekbar edit_first_page_number; private textview last_page_number; private seekbar edit_last_page_number; private textvie

c# 4.0 - Verify if two lists share values in C# -

i'd know if 2 lists share values before applying intersection. bool dointersect(lista, listb) fabulous! this code came with: // person class id , name properties list<person> people1; list<person> people2; // populate people1 , people2... // current solution (pseudocode obviously)... if (dointersect(people1, people2)) { people1 = people1.intersect(people2) } else { /* no shared people */ throw exception; } // continue process... it depends on want: // there common values between , b? public static bool sharesanyvaluewith<t>(this ienumerable<t> a, ienumerable<t> b) { return a.intersect(b).any(); } for lists don't overlap, iterate through , b each once. lists overlap, iterate way through a, through b until first overlapping element found. // contain of b? (ignores duplicates) public static bool containsallfrom<t>(this ienumerable<t> a, ienumerable<t> b) { return !b.except(a).any(); }

How do I stop a node.js script after it runs some time -

my script has module wait web response , stuck there because of web environment. want automatically stop after stucks 5 min (or 30 seconds) , don't want wait response timeout. how can that? edit: comment @yerken need , works the article https://davidwalsh.name/essential-javascript-functions includes function poll() may you're looking for. if doesn't work, please explain more want do. thanks!

python - Sublime Text 3 API plugin for regex replacing text -

i'm writing small plugin in sublime text 3 replace empty lines. used re module regex replace text. these codes test on console: >>> text = 'abc \n\nok' >>> print(text) abc ok >>> text = re.sub(r'^\n','',text) >>> text 'abc \n\nok' i can search on st3 ctrl+f = '^\n' . why pattern ^\n not working in plugin? because didn't use multiline flag in code. try this: re.sub(re.compile('^\n', re.multiline), '', s)

C# LINQ Group By Base Class -

i build base class keeps primary keys like: public class primarykey { [key] [column(order = 1)] public datetime date { get; set; } [key] [column(order = 2)] public int id1 { get; set; } [key] [column(order = 3)] public int id2 { get; set; } } and more classes different kind of data derived class. then want use 1 method create lists these derived class groupby primary keys. have done right is: private ienumerable<igrouping<primarykey, t>> datagroupbyprimarykey<t>(ienumerable<t> source) t : primarykey { return source.groupby(s => new primarykey { date = s.date, id1 = s.id1, id2 = s.id2 }); } but looks not working since after program runs through method, lists same set of primary keys still keep ungrouped. i experimented like source.groupby(s => new { s.date, s.id1, s.id2 }); a

c# - How to get Text in GridView when selected? -

i'm working on project in i'm setting content using json binding in grid view want text of item when selected. xaml code: <gridview itemssource="{binding}" horizontalalignment="center" margin="0,10,0,0" x:name="datalist" verticalalignment="center" selectionmode="none" selectionchanged="datalist_selection"> <gridview.itemtemplate> <datatemplate> <stackpanel width="450" height="300"> <image source="{binding top}" margin="0,0,0,0" stretch="none" /> <textblock x:name="title" text="{binding title}" foreground="black" horizontalalignment="center" fontfamily="assets/font/mixbrush.ttf#mixbrush" fontweight="bold" fontsize="50" margin="0,10,0,0" /> <

javascript - Data Tables Jquery Dynamic Fill -

i using datatables in 1 of projects in have fill oracle query results. referring this document . problem: all 10 columns returned query displayed in row 1 column 1 of table. javascript $('#inquiryform').submit(function(){ var cnic = "data="+ $( "#cnicind" ).val(); //alert(cnic); $.ajax({ type: "post", url: "php/inquiryind.php", data: cnic, success: function(datapage) { //$("#errmsg").html(data).show(); var datacopy = [[datapage]]; prompt("result",datacopy); $('#datatables-example').datatable({ responsive: true, "data": datacopy, columns: [ { title: "policy no." }, { title: "client name" }, { title: "gross premium" }, { title: "next due date" }, { title: "commencement date" }, { title: "

android - Cannot replace fragments in an activity -

my activity contains navigationdrawer .i need change fragments in activity when items in navigation drawer pressed.i error while replacing fragments. activity package in.yusoft.yuride.yuride; import android.app.fragmentmanager; import android.app.fragmenttransaction; import android.content.context; import android.support.v4.app.fragment; import android.support.v4.widget.drawerlayout; import android.support.v7.app.actionbar; import android.support.v7.app.actionbardrawertoggle; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.adapterview; import android.widget.arrayadapter; import android.widget.baseadapter; import android.widget.imageview; import android.widget.listview; import android.widget.textview; import android.widget.toast; public class homeactivity extends appcompatactivity implements adapterview.onitemclicklistener { drawer

java - Getting error Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT) for operation '=' -

i getting error below when trying select through stored procedure in mysql illegal mix of collations (utf8mb4_unicode_ci,implicit) , (utf8mb4_general_ci,implicit) operation '='. show variables variable_name 'character\_set\_%' or variable_name 'collation%'; 'character_set_client', 'utf8' 'character_set_connection', 'utf8' 'character_set_database', 'utf8mb4' 'character_set_filesystem', 'binary' 'character_set_results', 'utf8' 'character_set_server', 'utf8mb4' 'character_set_system', 'utf8' 'collation_connection', 'utf8_general_ci' 'collation_database', 'utf8mb4_unicode_ci' 'collation_server', 'utf8mb4_unicode_ci' all tables in utf8mb4_unicode_ci character set utf8mb4. stored procedure code: create definer=`dev_u

regex - Why doesn't Perl v5.22 find all the sentence boundaries? -

this fixed in perl 5.22.1. write in perl v5.22 adds fancy unicode word boundaries . perl v5.22 added unicode assertions tr #29 . i've been playing sentence boundary assertion, seems find start , end of text: use v5.22; $_ = "see spot. (spot dog.) see spot run. run spot, run!\x{2029}new paragraph."; while( m/\b{sb}/g ) { "sentence boundary @ ", pos; } the output notes sentence boundaries @ start , end of text, not after full stops, sentence terminators, or parens: sentence boundary @ 0 sentence boundary @ 70 the unicode breaks tester shows them expect them based on tr #29 . i couldn't find non-trivial tests in perl source feature. i'm digesting technical report create appropriate test cases, far looks untested , broken feature. calle dybedahl's comment gets right (and when turn answer i'll accept that). broken feature in v5.22.0, , far can tell, untested. had issue compiling stuff latest perls last night , end

MPI C - Root node receives more than one arrays -

each slave send array num length len root node. how able store these array in 2d array? if (world_rank == root) { for(i=1; i<world_size;i++) { // clueless } mpi_waitall(world_size-1, &rcv_request[1], &status[1]); } else { mpi_isend(num, len, mpi_float, i, 1, mpi_comm_world, &send_request[i]); mpi_wait(&send_request[1], &status[1]); }

html - Bootstrap nesting, shows on page but not on print -

Image
i cant seem right, made divider through css divs , shows on page when in print lines made doesnt show..what other options should do? im running out of ideas, doing wrong how can achieve this here want ot achieve heres css heres print preview page code: <div id="page-wrapper"> <div class="row"> <div class="col-md-12"> <div class="panel-body"> <p style="text-align:center;"><b>property acknowledgement receipt</b></p> <p style="text-align:right;">control no.</p> <div class="row"> <div class="col-md-16"> <table class="table table-hover table-striped table-bordered table-condensed" class=""> <thead> <tr> <th style="text-align:center;">

c# - Control cannot fall through from one case label ('case 1:') to another -

this question has answer here: control cannot fall through 1 case label 5 answers im trying make space invader style game in visual studios xna, , after creating basic game have attempted input menu screen. in order have moved around alot of code , put bulk of under case state.playing: . rest of fine 'case' coming above error message , im stumped. should looking? //updating playing state switch (gamestate) { ***case*** state.playing: { // todo: add update logic here int rightside = graphicsdevice.viewport.width; int leftside = 0; //moving of aliens (int r = 0; r < rows; r++) (int c = 0; c < collumes; c++) { i assume you're missing break s @ end of cases. use this: switch (gamestate) { case state.playing: { // code break; }

javascript - How to clear the form controls after submit the data? -

in google chrome when coming saved page empty in mozilla when return same form showing saved data in controls is. how clear form controls after submit data? modelstate.clear(); but not working. , put below code in saving form. window.onbeforeunload = function() { return "you work lost."; }; its clearing fields when return saving page when clicking save button throwing alert. so how save without ask 'leave page' option , work clearing fields after save page? try doing instead of return view() use return redirecttoaction("index") [httpget] public actionresult index() { return view(); } [httppost] public actionresult index() { //your code// //model.savechanges(); return redirecttoaction("index"); }

objective c - How Do I Embed Local HTML into Cocoa Binaries? -

i'm using objective c cocoa application on osx local html files loaded webkit widget. however, virus modify html files. so, added crc hash detect tampering, shows warning , closes application. however, there way additionally protect local html further s uch compiling binary of application itself , or compiling single resource file ? noticed qt have way put html resource file , change webkit urls load there instead of file://. objective c in case. it's not possible objective c or swift qt. there no http url can pass webkit widget pull content out of asset catalog.

javascript - How to set a localStorage item as function? -

i set localstorage item function, when gets saved string. localstorage.getdata = function (key="def") { let data = null; if (this[key] && !_this.isdataavailableinlist(this[key])) { data = this[key].data; } return data; }; the above function stored string , not function. note: kindly not provide alternatives or other suggestions, aware of alternatives , curious know how works. have not provided entire context lets assume in need of setting localstorage item function unfortunately local storage strings. arrays or other data converted strings. for dead data without cycles can use of course json.stringify , json.parse , in other cases or code or other javascript entities unsupported json (like infinity or undefined ) need serialize , deserialize yourself. javascript provides eval , can store function f converting first string f+"" , function eval(s) . won't work closures , cannot know if function indeed closure or not

html - Text not going to next line, staying on the same line as previous text -

the text after icons not going under icon no matter try; staying on right side of icon: https://jsfiddle.net/mo5zjm2n/1/ this html: <div class="container-fluid"> <br><p class="p-head">gallery</p> <hr class="p-div"> <div class="row"> <div class="col-md-3"> </div> <a href="#"><div class="col-md-3 padding-gallery"> <div class="gallery-bg"><i class="fa fa-lightbulb-o"></i><br> <p>prom</p></div> </div></a> <a href="#"><div class="col-md-3 padding-gallery"> <div class="gallery-bg"><i class="fa fa-tree" aria-hidden="true"></i><br><p>great outdoors</p></div> </div></a> <di

regex - regex_search C++ not matching substrings -

this question has answer here: is gcc 4.8 or earlier buggy regular expressions? 3 answers regex_search not matching "ter" in "computer computer" when i'm using following code - #include <iostream> #include <regex> using namespace std; int main() { string str("computer computer"); cout << regex_search(str, regex("ter")); return 0; } the above code gives me 0, whereas there "ter" in subject. going on here. know php's regex matches substring fine, whats wrong here? i'm using c++11 gcc, problem since read somewhere has poor support regex. it reruns 1 type bool, means pattern match found in word .run program. #include <stdio.h> #include<iostream> #include <regex> using namespace std; int main(void) { cout << regex_search(string("c

Liferay 7 + MySql 5.5.44 not support -

i downloaded liferay 7 (liferay-portal-7.0-ce-ga1) on ubuntu 14.04 when try connect mysql db, :then found error inthat: liferay7 not support lesser mysql 5.6.4 . i've installed mysql 5.5.44 on environment. on earlier version of mysql i.e. 5.5.44 other portals running perfectly. here logs, 01:43:13,809 info [elasticsearch[jade dragon][clusterservice#updatetask][t#1]][metadata:317] [jade dragon] [liferay-0] update_mapping [liferaydocumenttype] __ ____________________ _____ __ / / / _/ ____/ ____/ __ \/ \ \/ / / / / // /_ / __/ / /_/ / /| |\ / / /____/ // __/ / /___/ _, _/ ___ |/ / /_____/___/_/ /_____/_/ |_/_/ |_/_/ starting liferay portal community edition 7.0.0 ce ga1 (wilberforce / build 7000 / march 31, 2016) 01:43:18,624 info [localhost-startstop-1][startupaction:110] there no patches installed 01:43:18,760 error [localhost-startstop-1][startupaction:169] please upgrade @ least mysql 5.6.4. portal no longer supports older versions of m

javascript - how to implement contrast using fabric js -

i trying implement contrast using fabric js. seems fabric not support contrast, found link here this not working. me how achieve contrast using fabric js.

listview - Disable a specific Button on click in react native -

i have list of buttons on react native (around 3000 buttons) listed on listview component. how disable button number 365 on button click? you have not mentioned key point here, how plan disable button? want disable button in response action or want disable button by-default? please specify. i'm assuming few things here- you want disable button upon action, have maintain state. you have used touchablehighlight or touchablewithoutfeedback use rowid intelligently disable exact item. populate array of disaled ids , accordingly disable item. your render method renders listview render: function(){ return( <listview datasource={this.state.datasource} renderrow={(rowdata, sectionid, rowid) => renderitem.bind(this, rowid)} style={styles.listview} /> ); }, renderitem: function(id){ return <item id={id} enabled={this.state.isenabled} data={{name: 'foo', details: 'bar'}} /&g

Global variables in octave -

i'm using gnu octave, version 3.2.4. i have 2 functions. first function, f1.m, has global variable. i'm accessing global variable in function, f2.m. it works fine in following situation: # file f1.m function testglobal1() clear all; global var1 = []; testglobal2(); endfunction #file f2.m function testglobal2() global var1; isglobal("var1") var1 var1 = [var1, 10] endfunction the result after running f1 follows: ans = 1 var1 = var1 = 10 now, if run f1 again, following result: ans = 1 var1 = 10 var1 = 10 10 upon subsequent running of f1, vector var1 continues grow. my question is, why isn't variable, var1, getting reinitialized in f1 (line 3) though code session (is it's called?) on , new 1 begins when run f1 again? the funny thing is, if assign value var1 in f2, instead of appending on vector, new value gets assigned var1. code f2 modifications given below: function f2() g

java - New objects: new operator vs serialization -

as understood i've read there 2 ways create new objects in java: 1) using new operator , 2) means of serialization (for deep copying, example). other object manipulations (like assigning, instance) deal references existing objects. difference between 2 above mentioned ways in terms of inner logic? seems 1 difference serialization somehow doesn't use constructor methods. right? there other differences? by 'inner logic' mean how compiler (or whoever deals it) creates object step-by-step, algorithm uses, methods used , on. more margaret bloom writing in answer in more detail. further confusion clarification: so right during deserialization copy of object: class class1 { static array_length = 10; public class1() { int[] anarray = new int[array_length]; anarray[0] = 5; ... anarray[9] = -2; } } will include copy of array created elsehow (how? since no constructor has been called)? , furthermore, though original array

aggregation framework - Display all data in a row using mongodb -

i have collection mycollection, id datetime myid cost flag 1 '2016-07-01t00:00:00' 2048 1 'o' 2 '2016-07-02t00:00:00' 2049 2 'o' if write sql query it "select datetime, myid,flag, min(cost) mycollection group datetime, myid" it display fields in data e.g datetime, myid,flag, min(cost) but in mongo aggregation framework can group db.mycollection.aggregate([ { $group: { _id: { datetime: '$datetime', myid: '$myid' }, mincost: { $min: '$cost' } } } ]) which return me datetime, myid, min(cost) but need "flag" field in single query. tried out $push works array. in sql server, query select datetime, myid,flag, min(cost) mycollection group datetime, myid is invalid in select list because column flag not contained in either aggregate function

Why javascript callbacks are asynchronous? -

why javascript callbacks asynchronous , how works javascript engine ? why javascript callbacks asynchronous they don't have be, if function accepts callback isn't asynchronous might data using return value instead. and how works javascript engine ? usually binding event listener.

php - JavaScript-enabled checking routine works on Chrome/Opera/IE but not Firefox/Safari -

i've written short routine check whether javascript enabled on browser. it works on chrome, opera, , ie11. not work on firefox or safari; on browsers causes infinite refresh loop. want understand why it's failing on firefox , safari, , how make work on browsers. i've whittled down 4 separate php files, provided below, may copy , run. luck, you'll same success have had on chrome, opera, , ie, , same failure on firefox , safari. in brief: index.php makes ajax call written in pure javascript (i.e., no jquery needed). default, , firstly, false.php copied body_message.php , later included in index.php <body> message. if javascript enabled in browser, <script> section calls ajax_copy_file.php , in turn overwrite body_message.php true.php . result index.php display short message indicating whether javascript enabled on browser. the javascript minified, luck, seeing full routine not necessary (even in minification main jist can gotten). this ind