Posts

Showing posts from January, 2012

javascript - Files saved from Chrome trigger 403 when used in web projects -

whenever open image or text file in chrome , hit save, try load web project, receive 403 errors. way i've found reset permissions on these files upload file ftp server download on again. i've had happen on multiple machines now, figure it's more widespread 1 install. know way fix this? thanks!

Remove and later re-add all event handlers associated with a groupbox in C# winforms -

is there way collection of handlers associated groupbox in c# winforms? for cases checked statuses need changed programatically (not user), need turn off handlers other parts of program not fire. tedious hand many handlers. is there working code version of pseudocode not work below? foreach(control c in parent.groupbox1.controls) { c.disablehandlers() } //change controls handlers have interfered foreach(control c in parent.groupbox1.controls) { c.enablehandlers() } it possible use crazy reflection code this, don't want because you'll invariably run "well still want keep event not others". i recommend making class contains list of add-listener delegates , list of remove-listener delegates, , iterate through , execute each delegate @ appropriate times.

android - Scroll multiple recyclerviews on one recyclerview scroll -

i have arraylist of recyclerveiws in recyclerview , want know how scroll of them when 1 scrolled. have far, gives me stack overflow error: holder.rv.setonscrolllistener(new recyclerview.onscrolllistener() { @override public void onscrollstatechanged(recyclerview recyclerview, int newstate) { super.onscrollstatechanged(recyclerview, newstate); } @override public void onscrolled(recyclerview recyclerview, int dx, int dy) { super.onscrolled(recyclerview, dx, dy); if (dx != -199382734) (sched_vh vh : vhs) { if (vh != holder) vh.rv.scrollby(-199382734, dy); } } }); i have worked on problem friend few hours..the final answer simple. main idea 2 recyclerviews should use same onscrolllistener instead of different ones, listener recyclerview scrolling, , avoi

javascript - object Object error when passing object property to twitter api -

i using twitter npm package library create twitter bot interacts tweets on twitter retweeting, favoriting, , reposting tweets. functions operate correctly. however, every bot throw [object object] error , crash program until restarted. here functions using interact tweets. function interactposttweet(link, tweetparams) { client.post(link, tweetparams, function (error, tweet, response) { if (error) { throw error; //error thrown on line, , [object object] error message } }); } function posttweet(tweettext) { var update = 'statuses/update'; var params = {'status': tweettext}; interactposttweet(update, params); console.log("tweeted: " + tweettext); } function favoritetweet(id) { var favorite = 'favorites/create'; var params = {'id': id}; interactposttweet(favorite, params); } function retweettweet(id) { var retweet = 'statuses/retweet/' + id + ".json"; var params = {'id'

Is there a general way to index in jQuery? I know there's .first() but how about .second() or .third() -

this question has answer here: get element index in jquery 5 answers this seems pretty simple question couldn't find answer. have 3 forms on side open when button pressed , want autofocus cursor on whichever 1 of forms opens up. because forms identical, i'm having trouble referencing individual one, , it's on squarespace can't add id. grateful on this. thanks! you use .eq() method . supply index (they 0 based). given jquery object represents set of dom elements, .eq() method constructs new jquery object 1 element within set. supplied index identifies position of element in set.

javascript - Wrapper Not Expanding With Content -

Image
i in process of creating slide in/out side bar page cannot unless wrapper div covers whole length of body's width , height, doesn't , don't know why. i'm not entirely sure code include i've included here think is. if need preview code, have provided pastebin link below. image of issue - http://i.imgur.com/wwnaebp.png see code here if needs be: html - http://pastebin.com/tqt6xc4z css - http://pastebin.com/ms5gh56x thanks in advance. html: <div id="wrapper"> <div id="sidebar"> <nav id="nav"> <h3 id="welcometext">welcome to<br>lakeside books</h3> <div id="searchbar"> <form action="http://www.example.com/search.php"> <input type="text" name="search" placeholder=" book search" class="searchstyle"/> </form>

powershell - How to load multiple similar CSV files into sql server using batch files -

scenario : ftp server 100's of similar text files xxxxx1.txt,xxxxx2.txt .. same structure need down load , keep files 1 local folder local folder need load sql server after loading need move files backup / archive folder after load . using batch file move ftp server local , using bcp load files in sql server need load similar files. . note: have use bcp . can able load single file struggling load set of files it easy either informatica / ssis need batch files. please suggest. a for loop can repeat command on bunch of files for %a in (*.csv) type %a at it's basic. see for /? more.

wpf - Force update of a Delayed Binding -

we've been using bindingbase.delay property allow better user experience. value of 500 worked in our application it's causing problems. it's possible user click save button before update has been committed vm causing property not updated. is there command force delayed values pushed vm immediately?

swift - Parse iOS - Update PFUser.currentUser() and keep session -

i'm trying update current logged in user following code (ios): var currentuser:pfuser = pfuser.currentuser()! currentuser.setobject(true, forkey: "phoneverified") currentuser.saveinbackground() the user authenticated via username , password. the column "phoneverified" updated code, unfortunately current user session deleted in parse. after "invalid session token error" , user has login again. how can update current user data without deleting session? many thanks!! found problem: after removing "parse.enablelocaldatastore()" can change user without losing session. pfuser.enablerevocablesessioninbackground() still set.

MySQL - foreign key constrained by primary key in same table, error #1452 -

i created table cat_parent_id foreign key constrained primary key cat_id , using this: create table categories ( cat_id smallint not null auto_increment primary key, cat_parent_id smallint, cat_name varchar(40) index cat_id(cat_id), foreign key(cat_id) references categories(cat_id), ); when try insert record cat_parent_id null , error: #1452 - cannot add or update child row: foreign key constraint fails (`mydatabase`.`categories`, constraint `categories_ibfk_1` foreign key (`cat_id`) references `categories` (`cat_id`)) how can foreign key constraint fail when there no foreign key begin with? constraint possible if null not allowed? i can insert records if disable constraint, not want. need parent_id optional, , if has value existing cat_id only this create circular foreign key, prevent insertion table. foreign key(cat_id) references categories(cat_id), edit: perhaps meant put pk on cat_parent_id ?

c# - SQL query using sum(column) in pivot function -

from sql query count item report per day of month? i can report code: select name, [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20], [21], [22], [23], [24], [25], [26], [27], [28], [29], [30], [31], ([1] + [2] + [3] + [4] + [5] + [6] + [7] + [8] + [9] + [10] + [11] + [12] + [13] + [14] + [15] + [16] + [17] + [18] + [19] + [20] + [21] + [22] + [23] + [24] + [25] + [26] + [27] + [28] + [29] + [30] + [31]) total ( select name, id, datepart(day, [date]) day item month([date]) = 2 , year([date]) = 2015 ) x pivot ( count(id) day in ([1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19]

c++ - using classes to create a coin toss program -

having trouble figuring out constructors code in main() supposed test class can go on rest of program. instructions constructors this class has 2 constructors. default constructor (the 1 takes no arguments) should initialize value of coin penny (0.01) , side should initialized calling toss() method described below. the other constructor takes 1 argument: double holds initial value coin. passed in argument should used initialize value of coin. no error checking required. side should initialized calling toss() method described below. this code #include <iostream> #include <iomanip> #include <cstdlib> #include <ctime> #include <cstring> using namespace std; //put coin class definition after line class coin { public: coin() { value = 0.01; toss(); } coin(double ) { toss(); } void toss(); int getside(); double getvalue(); private: double value; char side[6]; }; int main() { //set random number g

python - Error while converting binary to integer when the last bit is zero [low] -

i using manual method convert binary decimal. code works fine last bit high eg: 1001. error arises when last bit zero[low]. eg: 1010 should give 10 gives 5 because last bit not considered.could 1 me in this. x=raw_input('enter binary value:') x=[int(xi) xi in x] sum=0 in range(0,len(x)): sum=sum+x[i]*(pow(2,i)) print sum you're misinterpreting problem. issue isn't it's ignoring last bit if it's 0, problem it's reading binary sequence backwards. when feed in "1010", processes "0101". sum = sum + x[i] * (pow(2, len(x) - - 1))

chicagoboss - How to connect Cassandra database with Chicago Boss Application? -

my cassandra database on vmware server. problem don't find database adapter can me in connecting cassandra database chicago boss(a web framework in erlang) application. tried cqerl on github not able use it. can tell me procedure connecting cassandra chicago boss. proper documentation great help. thank you.

update network and subnet quota during Openstack installation -

the default values 10 not enough our project. is there way modify network , subnet quota openstack apis , shell script? i advise follow: http://docs.openstack.org/user-guide-admin/content/cli_set_quotas.html in brief (repeating 1 of examples in link above) neutron quota-update --tenant_id {your_tenant_id} --network 3 --subnet 3 --port 3 -- --floatingip 3 --router 3 your_tenant_id project tenant id when updating limits l3 resource such as, router or floating ip. have put additional -- before the above guide proccess of updating quotas after have create networks. since in question mentioned 'during installation', update default quotas need change values in neutron.conf .

html - center float elements -

.key { width: 40px; height: 40px; background: red; float: left; border-radius: 50%; text-align: center; } .clearfloat { clear: both; } <div class="keywrap"> <div class="key"><span>1</span> </div> <div class="key">2</div> <div class="key">3</div> <div class="clearfloat"></div> <div class="key">4</div> <div class="key">5</div> <div class="key">6</div> <div class="clearfloat"></div> <div class="key">0</div> </div> how can make number center center within circle? can't padding or margin because responsive. you can try line-height .key { line-height:40px; width: 40px; height: 40px; background: red; float: left; border-radius: 50%; text-align: cen

mdx - Creating a measure by filtering out a set from an existing measure -

Image
i trying implement follows: with member measures.test2 sum ( { [date].[calendar].[calendar year].&[2006] ,[date].[calendar].[calendar year].&[2007] } ,[measures].[internet sales amount] ) select measures.test2 on columns [adventure works]; but want new measure test2 sliceable according calendar year dimension. want like select {measures.test2} on 0, {[date].[calendar].[calendar year].[calendar year].members} on 1 [adventure works]; this giving same value both years 2006 , 2007. in essence want create member taking subset of existing measure , using further calculations this script not valid mdx : select (measures.test2,[date].[calendar].[calendar year].[calendar year] on columns [adventure works]; you have single ( before measures. you're add tuple on columns not allowed. sets allowed on rows , columns: select {measures.test2} on 0, {[date].[calendar].[calendar year].[calendar year].members} on 1 [adventure works]; try fol

Excel formula or Vba to Sum of all lookup value from multiple excelsheet -

Image
i need below scenario, sheet1 a2 has date sheet2 , sheet3 has dates in column , numbers in column b example below, i want sum value sheet2 & sheet3 b column values in sheet1 a2 if finds in sheet2 & sheet3 a. below formula can sum sheet2 not able both sheet2 , sheet3. {=sum((sheet2!$b$2:$b$65500)*(sheet2!$a$2:$a$65500='sheet1'!a2))} please in formula or vba, thanks can't add two? in b2 of sheet 1 =sumif(sheet2!a:a,a2,sheet2!b:b)+sumif(sheet3!a:a,a2,sheet3!b:b)

javascript - How to check if the Selection object contains two sibling 'Div' or 'P' -

i want check condition in whether user selection has 2 or more div or paragraph sibling in it. breaking head on new dom stuffs. came across such situation before or can me algorithm or logic achieve . highly appreciated. whatever asked here, please share code snippet. here make example achieve that. since did't post code, i'm not sure example provided meet expectations. html <div id="a">click me <p></p> <div></div> <div></div> </div> js $('#a').on('click', function(){ var div = $(this).children('div').length; var p = $(this).children('p').length; if(div >= 2) { alert('div exists : ' + div); //do stuff here } else { alert('i have div below two'); //do stuff here if below 2 } //same goes p }); demo

python - how to extract index in factor vector in Rpy2 -

i have factor vector sv='ababbc' , integer vector fv=[1,1,1,1,1,1]. fv correspond sv. import rpy2.robjects robjects sv=robjects.strvector('ababbc') fac=robjects.factorvector(sv) fv=robjects.r['rep'](1,6) i want change value of element 2 in fv, of index correspond letter “a”. made fv=[2,1,2,1,1,1] how it? thank you. to index when true: in [54]: import numpy np np.argwhere(np.array(sv) == 'a') out[54]: array([[0], [2]]) the 1st , 3rd positions have letter 'a'. you can't fac , factorized , contains levels, 1, 2, 3..., not original 'a', 'b', 'c'... anymore. in [55]: np.argwhere(np.array(fac) == 'a') out[55]: array([], shape=(0, 1), dtype=int64) in [56]: np.array(fac) out[56]: array([1, 2, 1, 2, 2, 3], dtype=int32) or can done in r side: in [51]: robjects.reval('result1 <- which(sv %in% c("a"))') print robjects.r.result1 [1] 1 3 to systematically assig

java - How do i add the variables around a variable in a matrix -

i need sum of variables around 2,2 , print out. i have no idea on how this. please help! code far: import java.util.*; import java.io.*; public class matrixsumming { private int[][] m = {{5,6},{7,8},{3,4}}; //load in matrix values public int sum( int r, int c ) { return 0; } public string tostring() { return ""; } } here runner import java.io.file; import java.io.ioexception; import java.util.scanner; import static java.lang.system.*; public class matrixsummingrunner { public static void main( string args[] ) throws ioexception { //scanner file = new scanner (new file("matsum.dat")); int[][] mat = {{0, 0, 0, 0, 0, 0, 0}, {0, 1, 2, 3, 4, 5, 0}, {0, 6, 7, 8, 9, 0, 0}, {0, 6, 7, 1, 2, 5, 0}, {0, 6, 7, 8, 9, 0, 0}, {0, 5, 4, 3, 2, 1, 0}, {0, 0, 0, 0, 0, 0, 0}}; } } i tried finding couldn't find similar in matrix. do re

c# - Keyboard shortcut for wpf menu item -

i trying add keyboard shortcut menu item in xaml code using <menuitem x:name="options" header="_options" inputgesturetext="ctrl+o" click="options_click"/> with ctrl + o but not working - not calling click option. are there solutions this? inputgesturetext text. not bind key menuitem . this property not associate input gesture menu item; adds text menu item. application must handle user's input carry out action what can create routeduicommand in window assigned input gesture public partial class mainwindow : window { public static readonly routedcommand optionscommand = new routeduicommand("options", "optionscommand", typeof(mainwindow), new inputgesturecollection(new inputgesture[] { new keygesture(key.o, modifierkeys.control) })); //... } and in xaml bind command method set command against menuitem . in case both inputgesturetext , header pull

ios - How to make UIPickerView resignFirstResponder if user clicks in other place then UIPickerView -

i have created uipickerview following . want make resignfirstresponder if user clicks in other place uipickerview how achieve that. have created uipickerview following way.where else handle [pickerview removefromsuperview]; -(void)pickerview:(id)sender { _items =[[nsarray alloc]initwithobjects:@"hindi",@"english",@"in city born?", @"what childhood nickname?", @"type own question.",nil]; pickerview=[[uipickerview alloc] initwithframe:cgrectmake(10,350,300,300)]; pickerview.transform = cgaffinetransformmakescale(0.75f, 0.75f); pickerview.delegate = self; pickerview.datasource = self; pickerview.showsselectionindicator = yes; pickerview.backgroundcolor = [uicolor lightgraycolor]; [pickerview selectrow:1 incomponent:0 animated:yes]; // [self.view addsubview:pickerview]; [contentview addsubview:pickerview]; } - (nsinteger)numberofcomponentsinpickerview:(uipickervie

angularjs - How to remove sliding effect while moving one state to another in ionic? -

i trying move 1 view on button click> able move 1 one view second .but while moving start slide right left .i need stop sliding . mean need learn various type of way move 1 view using animation (left right or down or no animation or down up) . check code here http://goo.gl/q2k6mf click preview button .and type "abw" , select "abw" row .it download data server , after move second view sliding why ? need stop sliding . secondly downloading data in first controller .is there better way hit server or call webservice before moving second view ? $scope.rowclick=function(station){ $scope.search.stationcode=station.stationcode; $scope.search.selected = true; $ionicloading.show(); $http.get("http://caht.firstrail.com/fgrailapps/jservices/rest/a/departure?crscode="+ $scope.search.stationcode).then(function(data){ $ionicloading.hide(); $state.go('departuredashboard'

sbt - Conditional addSbtPlugin based on scalaVersion -

i'm using plugin (sbt-scapegoat) works scala 2.11. can have conditional addsbtplugin based on scalaversion? like: if (scalaversion.value.startswith("2.11")) addsbtplugin("com.sksamuel.scapegoat" %% "sbt-scapegoat" % "0.94.6") how can in sbt? jianshi tl;dr it's not possible given description of problem. there at least 2 build configurations involved in sbt project - real project (you want bet money on) , meta build build of project. yes, know sounds little weird, it's powerful concept imho. see sbt recursive : the project directory build inside build, knows how build build. distinguish builds, use term proper build refer build, , meta-build refer build in project. projects inside metabuild can other project can do. build definition sbt project. sbt runs atop scala , requires strict version of it. no way change unless fancy spending time on things should not touching in first place :) what can apply

javascript - PHP Output Not Appearing in HTML -

i have made code post output of php file showing music have been listening on spotify. the html, css , js (for spotify.php file) included in fiddle. the js within index.php file is: <script type="text/javascript"> function get_spotify() { $.ajax({ type: 'post', url: 'https://theobearman.com/cv/modules/spotify.php', data: { request: 'true' }, success: function(reply) { $('.now-playing').html("" + reply + ""); } }); } window.onload = get_spotify; </script> my issue output of .php file not showing under 'music' header on my website . this working few days ago, i'm not sure why not working now. thanks in advance help, theo. try $(document).ready(function() { get_spotify(); }); instead of window.onload = get_spotify , may run before element ren

javascript - Configure htaccess to directly access CSS and JS files but redirect all the other requests to index file -

this question exact duplicate of: configure htaccess bypass direct links css , javascript files 1 answer i developing system positively confused how supposed implement this. simplified file structure -.htaccess --/public --/public/index.php --/project --/project/template1/css --/project/template2/js --/project/all-other-files-and-folders-used my system redirects requests index.php, loads files in project folder other work want htaccess recognize css,img , js files in project folders , allow direct access them. this .htaccess file have now rewriteengine on rewriterule ^((?!public/).*)$ public/$1 [nc,l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php?cmd=$1 [pt,l] is possible? in advance you can use: rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewrite

swift - Cannot select UICollectionView Cell when Highlighting is set to false -

i've been battling while. core issue cells in uicollectionview disappearing when highlighted. have no need highlighting on app, selecting, i've set: func collectionview(collectionview: uicollectionview, shouldhighlightitematindexpath indexpath: nsindexpath) -> bool { return false } which means i'm not getting highlight callbacks, or undesired behaviour, i'm no longer able select items, when setting: func collectionview(collectionview: uicollectionview, shouldhighlightitematindexpath indexpath: nsindexpath) -> bool { return true } didselectitematindexpath not getting called. am missing flag or something? any appreciated!

xcode - Handler for Changing Texts in UIAlertView -

i need event handler uitextfields inside uialertview. specific, when text in being changed. -(void)textfielddidbeginediting:(uitextfield *)textfield{ nslog(@"text entry"); } is possible? thanks you should create uitextfield delegate class , set textfields delegate property. implementing method mentioned in question fire once textfield edited https://developer.apple.com/library/ios/documentation/uikit/reference/uitextfielddelegate_protocol/ good luck

qtreeview - Not able to see plus sign even if I pass true from hasChildren function in Qt -

i implementing tree view, have sub classed model , view. populating top level items , don't know how many child's there each top level items know top level items has child's, have re-implemented haschildren() function , pass true top level items, not able see + sign top level items pass true. please let me know problem thanks in advance.

javascript - AngularJS route syntax error illegal character -

i trying add new page website ( developed else ) , when add block route error like: error: [$injector:modulerr] failed instantiate module nameapp due to: [$injector:nomod] module 'nameapp' not available! either misspelled module name or forgot load it. if registering module ensure specify dependencies second argument. http://errors.angularjs.org/1.3.12/ $injector/nomod?p0=nameapp my routing config: .config( function($routeprovider, $locationprovider) { $routeprovider .when('/home', { templateurl: 'templates/home.html', title: 'home', controller: 'homecontroller', reloadonsearch: false }) .when('/about', { templateurl: 'templates/about.html', reloadonsearch: false }) .otherwise({ redirectto: '/404' });

No slots but QMetaObject::connectSlotsByName error using Qt and C++ -

i'm programming in c++ , qt creator , code works perfectly. nevertheless i've got problem warning when compile code. qmetaobject::connectslotsbyname: no matching signal on_but_printtab_clicked() there used slot named on_but_printtab_clicked() , no longer exists. how can rid of warning? there connect() call somewhere in call trying connect on_but_printtab_clicked . search "on_but_printtab_clicked" , remove connect() call.

ruby on rails 3 - NoMethod error in create action -

i error, when submiting form (views/users/show.html.erb) should create farms through farmscontroller , userscontroller: nomethoderror in farms#create showing /media/rok/local disc/users/koko/documents/kmetije/kmetije/app/views/users/show.html.erb line #42 raised: undefined method `farms' nil:nilclass extracted source (around line #42): 39: 40: <div id="show"> 41: <h2>seznam kmetij</h2> 42: <% unless @user.farms.empty? %> 43: <table id="farms"> 44: <tr> 45: <th>ime</th> app/views/users/show.html.erb:42:in _app_views_users_show_html_erb___3046909201139407898_28545460_3894795499615530291' app/controllers/farms_controller.rb:14:in create' here problematic create action in farmscontroller: class farmscontroller < applicationcontroller def new @farm = current_user.farms.build end

model checking - CTL fomula until contains implication -

Image
when use nusmv tools verify if ctl right, encounter problem make me confused. my model and here's nusmv code: module main var state : {root, a1, b1, c1, d1, f1, m1}; assign init(state) := root; next(state) := case state = root : a1; state = a1 : {b1, c1}; state = b1 : d1; state = d1 : f1; true : state; esac; ctlspec ag( state=a1 -> ax ( [ state=b1 u ( state=d1 -> ex state=f1 ) ] ) ); ctlspec ag( state=a1 -> ax ( [ state=b1 u ( state=f1 -> ex state=c1 ) ] ) ); ctlspec ag( state=a1 -> ax ( [ state=m1 u ( state=f1 -> ex state=c1 ) ] ) ); my ctl formula follows: "ag( a1 -> ax ( [ b1 u ( d1 -> ex ( f1) ) ] ) )" "ag( a1 -> ax ( [ b1 u ( f1 -> ex ( c1) ) ] ) )" "ag( a1 -> ax ( [ m1 u ( f1 -> ex ( c1) ) ] ) )" nusmv verified above 3 formulas of turns out true . so question why formula 2 , formula 3 turn out true? this question old, think it'

Android Animation when Scroll with images -

i having problem in creating animation have on box app in android. tried unable rotate image on next view. so if people can provide guide..... appreciated. this code class use swipe images public class customhorizontalscrollview extends horizontalscrollview implements ontouchlistener, ongesturelistener, android.view.gesturedetector.ongesturelistener { private static final int swipe_min_distance = 300; private static final int swipe_threshold_velocity = 300; private static final int swipe_page_on_factor=50; private gesturedetector gesturedetector; private int scrollto = 0; private int maxitem = 0; private int activeitem = 0; private float prevscrollx = 0; private boolean start = true; private int itemwidth = 0; private float currentscrollx; private boolean flingdisable = true; public customhorizontalscrollview(context context) { super(context); setlayoutparams(new layoutparams(layoutparams.fill_parent, layoutparams.fill_parent)); } public cu

bash - Folder restructure script -

i have directory has .txt, .csv,*.xml files. original folder structure : /servicer/*.txt,*.csv,*.xml the file naming convention below : 1. 6573547_billing_582524_1_00001.csv 2. 6573547_billing_582524_1_00001.txt 3. 6573547_billing_582524_1_00001.xml 4. 6573547_billing_582524_1_00002.csv 5. 6573547_billing_582524_1_00002.txt 6. 6573547_billing_582524_1_00002.xml 7. 6573545_billing_582524_1_00002.xml 8. 6573545_billing_582524_1_00002.csv my requirement create folder structure below , have files inside subfolders. required folder structure : /servicer/6573547/582524_1/*.txt,*.csv,*.xml /servicer/6573545/582524_1/*.txt,*.csv,*.xml the script should executable in windows linux environment. you can use script in bash: shopt -s extglob shopt -s nullglob f in *.@(csv|xml|txt); ifs=_ read -ra arr <<< "$f" p="/servicer/${arr[0]}/${arr[2]}_${arr[3]}" mkdir -p "$p" mv "$f" "$p/" done

SQLite count performance -

i'm experiencing (in opinion) weird performance issues when trying find total number of records in table. (boiled down) table looks this: create table "records" ( pk integer primary key autoincrement, other_table_fk integer, int_value integer, foreign key(other_table_fk) references other_table(pk) on delete cascade } create index int_value_idx on records(int_value); now when try query count of records takes long time: $ time sqlite3 db.sqlite "select count(rowid) records" 100000 real 0m2.962s user 0m0.162s sys 0m2.618s when indexed field used query way faster (but count same): $ time sqlite3 db.sqlite "select count(rowid) records records.int_value > 0" 100000 real 0m0.083s user 0m0.015s sys 0m0.057s my problem is, table schema dependant on users configuration, cannot have indexed field in table, still want have performance of indexed count . i know primary keys have index on own, in case n

cordova - phonegap run android not working and no error message -

i had worked phonegap period of time , workd yesterday got stuck in problem installing app on device using command line: \>>phonegap run android return [phonegap] executing 'cordova run android'... [phonegap] completed 'cordova run android' , no error message but nothing happened app not installed in device nor open emulator. i try create new project, update phonegap, update android platform, update sdk , uninstall phonegap , re-install nothing changed. i having exact same problem. adding line config.xml file solved me: <preference name="android-minsdkversion" value="10" /> i found solution after running cordova command cordova run android instead of phonegap command. cordova command gave error below error: manifest merger failed : uses-sdk:minsdkversion 7 cannot smaller version 10 declared in library c:\users\ecarriger\desktop\test\platforms\android\build\intermediates\exploded-aar\android\cordovalib\u

c# - using nuget package for android application ore unity to get sqlite worked -

is allowed tune android-game nuget package (sqlite, microsoft, in vs) develop android? ore there copieright on becouse should allowed develop rt. dont need trouble, , want learn c# in same way. , real great , reason why, have learn cs develop @ later time, rt-tablets. i see right now. 1- system.data.sqlite.core 2- system.data.sqlite.linq 3- entity framework (6.1) 4- system.data.sqlite.ef6 if allowed, , if working think, maybee show example here. else write me becouse dos'nt work. if works , allowed, turn stackoverflow , show commandline/logs/ ore quik komment how done. thank you. with unity seens answer this http://answers.unity3d.com/questions/743400/database-sqlite-setup-for-unity.html and allowed

php - Fatal error: Class not found in codeigniter -

i have created model admin_model under application\core directory of code igniter. put basic database operations under it. when try extend models under application\model directory, throws error. fatal error: class 'admin_model' not found in <path root>/application/models/new_model.php on line 3 should miss configuration? extending core class if need add functionality existing library - perhaps add function or 2 - it's overkill replace entire library version. in case it's better extend class. extending class identical replacing class couple exceptions: the class declaration must extend parent class. new class name , filename must prefixed my_ (this item configurable. see below.). example, extend native model class you'll create file named application/core/ my_model .php, , declare class with: class my_model extends ci_model { } note: if need use constructor in class make sure extend parent constructor: class my_model extends ci_m

Python: Replace 'one-line if's with ternary if, good idea or not -

in code i'm maintaining, see 'one-line if' construct such this: if self.verbose >= 1: print("starting...") i want replace with: print("starting...") if self.verbose >= 1 else none or even: self.verbose >= 1 , print("starting...") is idea or bad idea, in terms of performance and/or maintainability? edit: although allowed, not want make totally one-liner, e.g., if self.verbose >=1: print("starting...") i'm not sure why that. think alternatives proposed less readable. (but that's subjective of course) how removing condition in general? @ least remove repetition of if . def print_verbose(self, *args, **kwargs): if self.verbose>=1: print(*args, **kwargs) ... self.print_verbose("starting...") or migrate using logging module has support different logging levels. configured logging becomes: (provided logger created module via logging.getlogger() ) logger.

sql - Rolling average postgres -

i running postgres 9.2 , have large table like create table sensor_values ( ts timestamp time zone not null, value double precision not null default 'nan'::real, sensor_id integer not null ) i have values coming system ie many per minute. want maintain rolling standard deviation / average last 200 values can determine if new values entering system within 3 standard deviations of mean. need current standard deviation , mean updated last 200 values. table can hundreds of millions of rows not want last 200 rows sensor ordered time , vg(value), var_samp(value) every new value coming in. , assuming faster updated standard deviation , mean. i have started writing pl/pgsql function update rolling variance , mean on each new value entering system particular sensor. i can using code pseudo like newavg = oldavg + (new_value - old_value)/window_size new_variance += (new_value-old_value)*(new_value-newavg+old_value-oldavg)/(window_size-1) this based on http://jonisalo

matlab - how to find lowest vertical and horizontal DCT coefficient of an image block -

Image
i have image of size 256x256 , divided equal non overlapping blocks of size 8x8. have find lowest vertical , horizontal dct (discrete cosine transform)coefficients of each image block. there method available problem in matlab? the usual method create array of indices maps important least important have stored them. this pattern used in jpeg. don't know how have arranged coefficients cannot give ordering.

sorting - How to sort a cursor with variables in android? -

i have listview (in listframent ) cursoradapter shows different names of places. @ begining, list sorted names (using order_by in query). now, have added item_row.xml textview containing distance of place user's position latitude/longitude of each place , locationmanager . , sort list of places distance (from nearest farthest). the problem calculate distance outside "sql environment", , there no methods sort cursor / listview / adapter ... any ideas ? use collections.sort(list, comparator) custom comparator . example using class sorting sum of both integer fields: import java.util.arraylist; import java.util.collections; import java.util.comparator; import java.util.list; class { final string name; final int somenumber; final int someothernumber; a(final string name, final int a, final int b) { this.name = name; this.somenumber = a; this.someothernumber = b; } @override public string tostrin

java - Akka RoundRobinPool File counter -

i sum files in directory + size . use akka multithreaded ( router size 5 ) . unfortunately, i'm not. myuntypedactor: calculation of individual directories public class myuntypedactor extends untypedactor { private long length = 0; private int amountfiles = 0; public static props getprops() { return props.create(myuntypedactor.class); } @override public void onreceive(object msg) throws exception { if(msg instanceof dirstats) { this.amountfiles += ((dirstats) msg).filecount; this.length += ((dirstats) msg).totalsize; } else { unhandled(msg); } list<future<object>> results = new arraylist<future<object>>(); // prüfe ob die erhaltene nachricht vom korrekten typ if (msg instanceof file) { file dirpath = (file)msg; (file file : dirpath.listfiles()) { if (file.isfile()) { length += file.length(); amountfiles++; }

ios - How to make equal space between texts in the circular menu? -

Image
i creating circular slider menu, using coregraphics draw control ui, here trying draw words on circumference of circle. cant able make spaces equally. here code , output. please me give equal spaces between each word. in drawrect float anglestep = 2 * m_pi / [menuarray count]; float angle = degreestoradians(90); textradius = textradius - 12; (nsstring* text in`enter code here` titlearray) { [self drawstringatcontext:ctx string:text atangle:angle withradius:textradius]; angle -= anglestep; } ////////// - (void) drawstringatcontext:(cgcontextref) context string:(nsstring*) text atangle:(float)angle withradius:(float) radis { cgsize textsize = [text sizewithfont:[uifont systemfontofsize:11.0]]; float perimeter = 2 * m_pi * radis; float textangle = textsize.width / perimeter * 2 * m_pi; angle += textangle / 2; (int index = 0; index < [text length]; index++) { nsrange range = {index, 1}; nsstring* letter = [text substringwithrange:range]; char* c =

javascript - Measure WebGL texture load in ms -

how can measure webgl texture load in milliseconds? right have array of images renderd out map using game loop , im interested in capturing time takes webgl load every texture image in milliseconds. wonder how can done measure because javascript not synchronous webgl. the way measure timing in webgl figure out how work can in amount of time. pick target speed, 30fps, use requestanimationframe, keep increasing work until you're on target. var targetspeed = 1/30; var amountofwork = 1; var = 0; function test(time) { time *= 0.001; // because seconds var deltatime = time - then; = time; if (deltatime < targettime) { amountofwork += 1; } (var ii = 0; ii < amountofwork; ++ii) { dowork(); } requestanimationframe(test); } requestanimationframe(test); it's not quite simple because browsers, @ least in experience, don't seem give stable timing frames. caveats don't assume requestanimationframe @ 60fps. ther

sublimetext3 - Sublime text 3 git plugin PATH error - GIT Binary could not be found in PATH -

Image
this driving me crazy.. have found same issue elsewhere... cannot work on windows 8.1. added c:\git\bin path environment variable. also tried updating git_command var in sublime git plugin user settings... still appears!... ideas appreciated... thanks here attempt add bin dir git_command property. { // if present, use command instead of plain "git" // e.g. "/users/kemayo/bin/git" or "c:\bin\git.exe" "git_command": "c:/git/git.exe" } thanks looking i think adding incorrect path. should be: { // if present, use command instead of plain "git" // e.g. "/users/kemayo/bin/git" or "c:\bin\git.exe" "git_command": "c:/git/bin/git.exe" }

Android json parse and store into database -

i making app have database , trying store data using method , getting error javanullpointer, jsonparser jparser = new jsonparser(); jsonobject json = jparser.getjsonfromurl(url); // todo auto-generated method stub jsonarray erate= json.getjsonarray("erates"); if(erate!=null) { // looping through contacts for(int = 0; < erate.length(); i++){ jsonobject c = erate.getjsonobject(i); cursor cr = db.rawquery("select * `rates` `id`='"+c.getstring("id")+"'",null); string query= "insert rates(id,kondisi,condition,tenor,erate,eratedb)"+ "values("+ c.getstring("id")+",'