Posts

Showing posts from July, 2010

java - OnItemClickListener doesn't work but OnLongItemClickListener works in Custom Listview -

i have custom listview custom adapter. want click on items of listview , something. onitemclicklistener not works. implemented onlongitemclicklistener and works perfectly. mainactivity public class mainactivity extends activity { arraylist<product> products = new arraylist<product>(); adapter listviewadapter; //custom adapter object listview listview; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); listview = (listview) findviewbyid(r.id.lvmain); listview.setlongclickable(true); listviewadapter = new adapter(this, products); listview.setadapter(listviewadapter); listview.setonitemlongclicklistener(new onitemlongclicklistener() { @override public boolean onitemlongclick(adapterview<?> arg0, view arg1, int arg2, long arg3) { //this works toast.maketext(getapplicationcontext(), "long pressed", toast.lengt

apache - Positive SSL trusted in Chrome for desktop but not for Android -

i have bought positive ssl certificate not work in chrome android, net::err_cert_authority_invalid . however, ok chrome desktop. this how configure apache2 server: # file /etc/apache2/sites-available/000-default.conf <virtualhost *:80> servername example.com redirect permanent / https://example.com/ </virtualhost> <virtualhost *:443> serveradmin webmaster@localhost documentroot /var/www/html servername example.com sslengine on sslcertificatefile /root/ssl/certificate/example.com.crt sslcertificatekeyfile /root/ssl/example.com.key sslcertificatechainfile /root/ssl/certificate/intermediates.crt # in version 2.4.8 or newer #sslcacertificatefile /root/ssl/certificate/intermediates.crt errorlog ${apache_log_dir}/error.log customlog ${apache_log_dir}/access.log combined </virtualhost> and here it's how created intermediates.crt : cat comodorsadomainvali

java - Regex replace with increment -

i use mystring.replaceall("(chapter.*?)br","chapter **increment**"); i want paste **increment** instead of increment , don't have idea how can it. i have next text: chapter br texttexttexta chapter b345 br texttexttextb345 chapter ab br texttexttextab it has like: chapter 1 br texttexttexta chapter 2 br texttexttextb345 chapter 3 br texttexttextab i have chapters different index. example, chapter , chapter b. i'm grabbing chapters regex , change unique chapter chapter + increment. found solution: int n = 0; pattern r = pattern.compile("(chapter.*?)<br />"); matcher m = r.matcher(filetoshow); while (m.find()) { system.out.println("found value: " + m.group(0)); filetoshow = filetoshow.replaceall(m.group(0),"<chapter "+ ++n +">"); }

bash - unix shell scripting for moving files sequentially with file names as fixed increment into directories -

i have large number of directories increments of time step 0.00125. want copy time directories 8 directories sequentially i.e algorithm can think of is delta_time = 0.00125 if directory_name = 0.00125 mv 0.00125/ main_dir1 if directory_name = 0.0025 mv 0.00250/ main_dir2 if directory_name = 0.00375 mv 0.00375/ main_dir3 . . . if directory_name = 0.01 mv 0.01/ main_dir8 if directory_name = 0.01125 mv 0.01125/ main_dir1 (again) if directory_name = 0.0125 mv 0.0125/ main_dir2 . . . . if directory_name = 0.02 mv 0.02/ main_dir8 . . on the time directories large in number (around 200 directories) im thinking of writing bash script. im relatively new bash scripting still cant think of logic this! you want modular arithmetic on directory names, exception multiples of 8 want use 8 instead of 0. so: #!/bin/sh increment="0.00125" maxdir=8 directory_name in 0.* if [ -d "$dir

java - Too many open files even after setting kern.maxfiles -

i have set kern.maxfiles=65536 kern.maxfilesperproc=65536 after this, put following command in .zshrc file ulimit -n 30000 however, if try run netty based application eclipse, 10k sockets open , java io exception "too many open files" occurs. folowing stacktrace. java.io.ioexception: many open files @ sun.nio.ch.serversocketchannelimpl.accept0(native method) @ sun.nio.ch.serversocketchannelimpl.accept(serversocketchannelimpl.java:422) @ sun.nio.ch.serversocketchannelimpl.accept(serversocketchannelimpl.java:250) @ io.netty.channel.socket.nio.nioserversocketchannel.doreadmessages(nioserversocketchannel.java:135) @ io.netty.channel.nio.abstractniomessagechannel$niomessageunsafe.read(abstractniomessagechannel.java:68) @ io.netty.channel.nio.nioeventloop.processselectedkey(nioeventloop.java:510) @ io.netty.channel.nio.nioeventloop.processselectedkeysoptimized(nioeventloop.java:467) @ io.netty.channel.nio.nioeventloop.processselectedk

How to remove the Javascript script added to webdriver using JavascriptExecutor -

i have executed javascript in webdriver using javascriptexecutor , script remains in document until refresh page. wonder there way remove script or disable after executing once , without refreshing page? js = (javascriptexecutor) driver; js.executescript();

python - Can't get forms in Django to create a POST request (and save to database) -

i'd point out first django project , don't have other programming experience, error might simple. still, spent few days trying fix no progress. it's first question here, hope i'm doing right. the following template of form page. form displaying alright. it's not causing page reload when "submit" button clicked , it's not submitting post request. <form role="form" action="." method="post"> {% csrf_token %} {% bootstrap_form form %} {% buttons submit='add new book' reset="cancel" %}{% endbuttons %} </form> models.py: class book(models.model): title = models.charfield(max_length=80) photo = models.imagefield(upload_to='book_images', blank=true) author = models.charfield(max_length=150) category = models.charfield(max_length=50) product_url = models.charfield(max_length=200) num_of_chapters = models.integerfield() forms.py: class addbookform(forms.mo

How to add multiple css rules at once through Dev-Tools or Firebug -

Image
i have 300 lines of css, consisting of many rules need test on page. i preferably paste rules in 1 go @ bottom of main.css page using - or add pseudo "extra-main.css" sheet page rules. i don't have access source of page have work on live page. not perfect know. what best way this? firebug, devtools (chrome), else... within chrome devtools' elements panel click source of element, paste in css test , hit ctrl + s see updates. can click element on page want test long css source file effects it.

Does jwplayer supports RTSP Streaming? -

i newbie in video streaming . using jwplayer video need. supports rtsp streaming . if so, how can play streaming video via rtsp on jwplayer. in advance . rtsp not supported. here support - http://support.jwplayer.com/customer/portal/articles/1403635-media-format-support

python - Detect if method is decorated before invoking it -

i wrote python flow control framework works unittest.testcase : user creates class derived framework class, , writes custom task_*(self) methods. framework discovers them , runs them: ################### # framework library ################### import functools class skiptask(baseexception): pass def skip_if(condition): def decorator(task): @functools.wraps(task) def wrapper(self, *args, **kargs): if condition(self): raise skiptask() return task(self, *args, **kargs) return wrapper return decorator class myframework(object): def run(self): print "starting task" try: self.task() except skiptask: print "skipped task" except exception: print "failed task" raise else: print "finished task" ############# # user script ############# class myuserclass(myframework):

F# less than operator in pattern matching -

for reason less operator in pattern match not work. it's error have , it's driving me insane. i'm missing obvious appreciated. let checkaccount account = match account | {balance < 10.00} -> console.writeline("balance low") | {balance >= 10.00 , <= 100.00} -> console.writeline("balance ok") | {balance > 100.00} -> console.writeline("balance high") this type: type account = {accountnumber:string mutable balance:float} member this.withdraw(amnt:float) = if amnt > this.balance console.writeline("unable withdraw. amount wish withdraw greater current balance.") else this.balance <- this.balance - amnt console.writeline("you have withdrawn £" + amnt.tostring() + ". balance now: £" + this.balance.tostring()) member this.deposit(amnt:float) =

c# - Handling a dependancy from different project in a console application -

i have following project structure in solution: project.repository (class library) project.core (class library) project.web (mvc5 web front end) project.scheduler (console application) i using unity handle di. my problem i have method sits in core layer, method has dependency on iprocessdataservice interface being handled in unity config. //service container.registertype<iprocessdataservice, processdataservice>(new perrequestlifetimemanager()); i have created console application project invoke said method , run on windows schedule. how go accessing method console application's static main method considering have dependency core interface? public class program { public static void main(string[] args) { console.writeline("begin automation process"); //run method core layer has dependency on iprocessdataservice } } your console app's main method composi

newsletter - Detect useragent before sending mail -

can tell me if possible send different kinds of templates newsletter according receiver's browser(mobile or web)? can test on navigator before sending? @thanx i guess concern compatibility different clients. best can keep newsletter template simple , table based. you can use newsletter frameworks zurb ink http://zurb.com/ink/ and testing tools litmus https://litmus.com/

java - error in google login fragment, W/IInputConnectionWrapper(20367): showStatusIcon on inactive InputConnection -

i have error when click google login button: w/iinputconnectionwrapper(20367): showstatusicon on inactive inputconnection don't know how have problem, read error due connection not closed earlier not understand what. please me `*package com.amuse.facebooktutorial; public class googleloginfragment extends fragment implements onclicklistener, connectioncallbacks, onconnectionfailedlistener { private static final int rc_sign_in = 0; private static final int result_ok = 0; // logcat tag private static final string tag = "mainactivity"; // google client interact google api private googleapiclient mgoogleapiclient; private static final int req_sign_in_required = 55664; /** * flag indicating pendingintent in progress , prevents * starting further intents. */ private boolean mintentinprogress; private boolean msigninclicked; private connectionresult mconnectionresult; private signinbutton btnsignin;

Product with digit in name not searched in Magento -

Image
in magento, have product named "99volts magnetix - dashboard basic" ,but when search 99volts in catalog search,the result "your search returns no results." comes output. if search 99volts magnetix,then product gets searched. please suggest how can resolve problem. i got solution. go admin->config->catalog->catalog , in catalog search tab,set "search type" "like". earlier set fulltext,that's why 99volts not searchable 99volts magnetix was.

c# - Windows Phone 8.1 how to display Progress Ring when Navigating to another Page? -

completely new winphone8.1: my winphone8.1 app seems navigate quite between pages - each page question , have previous/next buttons: private void btnnextquestion_click(object sender, routedeventargs e) { progressring1.isactive = true; frame.navigate(typeof(question), _survey.id.tostring() + "|" + _nextfield.id.tostring()); } as can see tried set progressring1.isactive = true; didn't expect work, tried anyway. tried clever , use task (which new me - maybe i've done wrong) start progressring didn't have effect either: private async void btnnextquestion_click(object sender, routedeventargs e) { await task.run(() => startprogrssring()); frame.navigate(typeof(question), _survey.id.tostring() + "|" + _nextfield.id.tostring()); } private void startprogrssring() { progressring1.isactive = true; } so explain how can achieve aim - let user know button press has been recognised ,

android - How to flash ROM from app? -

i trying make updater custom rom. can recovery app by: process p = runtime.getruntime().exec("su"); outputstream os = p.getoutputstream(); os.write("mkdir -p /cache/recovery/\n".getbytes()); os.write("echo 'boot-recovery' >/cache/recovery/command\n".getbytes()); os.write("reboot recovery\n".getbytes()); os.flush(); if add next lines, device load recovery, clear cache , boot system. os.write("echo '--whipe-cache' >>/cache/recovery/command\n".getbytes()); os.write("echo 'reboot' >> /cache/recovery/command\n".getbytes()); is there command execute flashing? you can add line: os.write("echo '--update_package=/sdcard/update.zip' >>/cache/recovery/command\n".getbytes()); before os.write("reboot recovery\n".getbytes()); os.flush();

php - MySql getting sum: one table contains values, in other tables is rest of data -

i have 3 tables. first table(items) has: item_id, item_name, , item_value. second table(handouts) contains: handout_id, handout_item_id, month, vol_id, receiver_name. third table(volunteer) contains volunteer_id, volunteer_name i need output monthly sum of items value, per volunteer selected month. here have far(what stuck :-s): function mesec_svi(){ global $konekcija; $mes=$_get['mes']; $query= "select distinct vol_id handouts mes = {$mes} "; $mesec_svi = mysqli_query($konekcija, $query); potvrda_query($mesec_svi); while($mesec_svi_lista=mysqli_fetch_assoc($mesec_svi)){ $volid= $mesec_svi_lista["vol_id"]; echo $volid.' '; $query1= "select handout_item_id handouts vol_id = {$volid} , mes = {$mes}"; $mesec_svi_o = mysqli_query($konekcija, $query1); potvrda_query($mesec_svi_o); while($mesec_svi_olista=mysqli_fetch_assoc($mesec_svi_o)){ $itemid= $mesec_svi_olista["handout_item_id&q

rewrite - Google Cloud Storage - SocketTimeoutException when rewriting a big object to "nearline" bucket -

environment: java client ("google-api-services-storage", "v1-rev33-1.20.0") using json api (com.google.api.services.storage.storage class). goal: move large object "standard" "nearline" bucket using java client (file size 512 mb). steps: use "rewrite" api method. problem: i'm getting sockettimeoutexception in 20 seconds. investigation: same code works fine when use rewrite "standard" bucket "standard" bucket same object. i've tried apis explorer , created request rewrite object "standard" "nearline" bucket. server responded in 27 seconds , "totalbytesrewritten" property in response half of file size. how , handle such response? documentation says: "if source , destination different locations and/or storage classes, rewrite method might require multiple calls." my code (java): final storage.objects.rewrite rewriterequest = storage.objects().re

Bootstrap causing problems with CSS column property -

i'm using bootstrap 3 , have set content display in 2 columns using css column property. know done bootstrap, in case, better use css columns. but at least in ios (chrome or safari) content not visible @ all. if comment bootstrap tags, content visible , css columns work fine. any ideas? edit (added examples, christina ;) ) in document works fine in desktop browsers if check ios chrome or safari, text in css columns not visible. http://aatosmedia.fi/tmp/column.html in second document commented bootstrap 3 css -file , columns visible in ios. http://aatosmedia.fi/tmp/column2.html it's caused min-height: 1px; property .sisalto css class. div it's visible on both pages on column.html height it's equals 1px. fix adding height div .

javascript - D3 Elastic easing transition of circle radius causes negative radius to be set -

Image
i have weird problem whilst using ease("elastic", a, p) function in d3js. transitioning radius of circles , i'm getting flood of errors in console, slowing down webpage. errors state i'm setting negative radius — after debugging (from console logging diffs previous code) found out that's caused elastic easing. here's code: function redraw() { var day = d3.select('input[name="day"]:checked').node().value; var time = d3.select('input[type="range"]').node().value.tostring(); var direction = d3.select('input[name="direction"]:checked').node().value; // fix bug in data single digit hours not displayed if (time.length == 1) {time = "0" + time;} if (circles !== undefined) { circles.transition().duration(900).ease('elastic', 1, 0.75).attr({ fill: function(d) { return shadecolor("#ff0000", (-1 * getcirclesize(d.data, da

mysql - Query Optimization (Function Vs SubQuery) -

in mysql better use function(included subquery) in store procedure instead of direct writing subquery, make difference or code reuse? the answer quite simple: give try , measure results; preferably on test-set realistic. (you might not see difference when there 2 records in table, effect on 2 million records gigantic) you can test in way: $starttime = microtime(true); // codes $endtime = microtime(true); echo $duration = $endtime - $starttime; imho, subquery (a lot) faster same functionality stored in function. i'm mssql-biased , can't quite tell if mysql different; doubt it.

sql - Create a trigger -

create trigger called newentry, not allow result inserted student exam table if less zero. in query display suitable message if result less 0 , supply code test trigger. this have done, keep getting warning : trrigger created compilation errors. this code, please help! create or replace trigger newentry after insert or update on assignment2.student_exam each row declare results number; begin if(:new.results < '0') raise_application_error (-20700,'student's result cannot less-than zero..enter valid results':); endif; end; / end if, not endif. jeremy c mentions above need create trigger before insert or update

javascript - Make multiple canvas or overlay drawings on the same canvas html5 -

i need advice, have html canvas, in html can add circles , link these make figure, want insert search can find different figures , focussed on it, don't know if it'll better : overlay figures or use different canvas each figure. (i'm not implement search function yet.) think? here functions makes de draws //this function puts circles on <table> , , other function takes img coordinates , link making figure. function position(year, mon) { $('#' + year + ' .' + mon).prepend('<img class="black_point" src="./images/circle.png"/>'); } var table = document.getelementbyid("tabla"); var images = table.getelementsbytagname("img"); var canvas = document.getelementbyid("micanvas"); var ctx = canvas.getcontext("2d"); var x,y; // remember coordinates canvas.width = table.offsetwidth; canvas.height = table.offsetheight;

css - Enable scroll bar on fixed window border div -

i'm trying enable browser scroll bar in website didn't work. this site online : http://guillaumeruiz.com all projects in "gallery" hidden , visible hide id function. used left-right-top-bottom fixed divs red window border. and, every div project have fixed position cover main gallery. if can me please... thank you

ios - cell properties returned nil -

i created custom uitableviewcell named gatecell , inside placed 1 label , 1 text field. in gatecell.h @property (weak, nonatomic) iboutlet uilabel *gatelabel; @property (weak, nonatomic) iboutlet uitextfield *gatetextfield; in gatetableviewcontroller - (void)viewdidload { [self.tableview registerclass:[gatecell class] forcellreuseidentifier:@"cellidentifier"]; } finally @ cellforrowatindexpath method, used this - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { gatecell *cell = (gatecell *)[tableview dequeuereusablecellwithidentifier:@"cellidentifier"]; cell.gatelabel.text = @"gate"; cell.gatetextfield.text = @"open gate" return cell; } when print description of cell, getting following.. <`gatecell`: 0x7b6bd790; baseclass = `uitableviewcell`; frame = (0 0; 320 44); layer = <calayer: 0x7b6c2e60>> <br> printing description of cell->_

php - Filter Limit in opencart -

i have 266 filters in 1 group in opencart. trying add 267th , error: notice: undefined index: filter_description in /home/eshop/public_html/admin/controller/catalog/filter.php on line 386 warning: invalid argument supplied foreach() in /home/eshop/public_html/admin/controller/catalog/filter.php on line 386 notice: undefined index: sort_order in /home/eshop/public_html/vqmod/vqcache/vq2-admin_model_catalog_filter.php on line 48 notice: undefined index: filter_description in /home/eshop/public_html/vqmod/vqcache/vq2-admin_model_catalog_filter.php on line 53 warning: invalid argument supplied foreach() in /home/eshop/public_html/vqmod/vqcache/vq2-admin_model_catalog_filter.php on line 53 warning: cannot modify header information - headers sent (output started @ /home/eshop/public_html/admin/index.php:85) in /home/eshop/public_html/vqmod/vqcache/vq2-system_engine_controller.php on line 28 warning: cannot modify header information - headers sent (output started @ /home/eshop/pu

javascript - Angular JS isolated scope not working on directives with service calls -

i developing directive content changes based on attribute. if having more 1 directive in page, isolated scope not working, 2 directives having same values. happening when there service calls in directives , isolated scope works when there no services , promises. directive .directive('ex', function() { return { restrict: 'e', scope: {}, template: '<div>test{{test}}</dic>', link: function(scope, elem, attr) { if(attr.label == 'dir1') { scope.test = 'directive 1'; } if(attr.label == 'dir2') { scope.test = 'directive 2'; } } } }) and html <ex label="directive1"></ex> <ex label="directive2"></ex> output directive 1 directive 2 this works perfectly, when having http service call in directive , if scope value depends on it, getting wrong output like directive 1 directive 1 please me fi

php - Yii2 Loading Page/Image when Bootstrap Modal is still Loading -

i have modal: <?php echo html::button( 'create new staff', [ 'value' => url::to(['create-new-staff']), 'class' => 'btn btn-success btn-create', 'id' => 'modalbutton' ]); modal::begin(['id' => 'modal']); echo "<div id='modalcontent'></div>"; modal::end(); ?> here's sample loading indicator image: <img src="http://dkclasses.com/images/loading.gif" id="loading-indicator" style="display:none" /> when click modal button, want display loading screen or image when modal still loading instead of plainly waiting modal load. tried this: <script type="text/javascript"> $("modalbutton").click(function(event) { $.post( "/echo/json/", { delay: 2 } ); $(document).bind("ajaxsend", fu

android - The API (Calendar API) is not enabled for your project. Please use the Google Developers Console to update your configuration -

i error of release version of application: com.google.api.client.googleapis.json.googlejsonresponseexception: 403 forbidden { "code":403, "errors":[ { "domain":"usagelimits", "message":"access not configured. api (calendar api) not enabled project. please use google developers console update configuration.", "reason":"accessnotconfigured", "extendedhelp":"https://console.developers.google.com" } ], "message":"access not configured. api (calendar api) not enabled project. please use google developers console update configuration." } my test version work on test account, , in google develeper console enabled google calendar api - work fine. but, when generate apk, error appeared. can enabled google calendar api? can use ssh1 repeatedly create access release version in account? you nee

symfony - Query builder mongodb index datetime -

i'm looking execute custome query doctrine odm in fulltext search , datetime range indexes generated on mongodb here code : $search = $dm->createquerybuilder('videobundle:video'); if (isset($_post['date'])) { $from = new \datetime($_post['date']); $to = new \datetime('today'); $search->field('published')->range($from, $to); } $search->expr()->operator('$text', array( '$search' => $_post['searchvideo'], )); $search->limit(50); $query = $search->getquery(); $search = $query->execute(); query returned , executed doctrine mongodb in symfony profiler : db.video.find().limit(50); any help?

javascript - Angularjs promise this references window -

i've made basemodel load function, defined below: basemodel.prototype.load = function(id) { var deferred = $q.defer(); var self = this; db.getbyid(this.gettablename(), id).then(function(data) { deferred.resolve(new basemodel(data)); //self has reference window here }, function(err) { deferred.reject(null); }); return deferred.promise; }; in child class derives basemodel im calling with: return basemodel.prototype.load.call(this, id); but in 'success' part of promise 'var' self has reference window... possible keep reference object , if so, how? can't find example this. thanks in advance! return basemodel.prototype.load.call(this, id); <-- line problem. not sure doing there, seeing, you setting this value using call , @ point of code, points window object

c++ - Passing QString variables between QDialog forms -

Image
the problem have encountered bit trickier , not similar other problems / solutions on net. provide brief idea of application, work-flow shown below; i have done till fetching data in dialog2 , saved data in qstring variables. , want pass dialog1 which open . using these values settext set values qlabel , qlineedit widgets in dialog1. the technique have used not reflecting changes on dialog1. maybe because open , has not been updated. relevant code snippets shown below - dialog1.h private slots: void on_pushbutton_2_clicked(); //this slot pushbutton open dialog2 public: void setlabeltext(qstring str); //for setting text of label dialog1.cpp void dialog1::on_pushbutton_2_clicked() { dialog2 dialog2; dialog2.setmodal(true); dialog2.setwindowflags(qt::framelesswindowhint); dialog2.exec(); } void dialog1::setlabeltext(qstring str) { ui->lineedit->settext(str); qdebug()<<"value arrived "<<str; } dialo

javascript - How do I catch exceptions when a task triggered by gulp-watch fails? -

i use following gulp task transform less css. start once , upon less-file changes updates css. gulp.task('watch-less', function () { gulp.watch('app/styles/*.less', function (event) { try { var filename = event.path; gulp.src(filename) .pipe(sourcemaps.init()) .pipe(less()) .pipe(sourcemaps.write()) .pipe(gulp.dest('app/styles/')); } catch (e) { console.log(e); } }); }); the problem: sometimes, less fails , stops error message like events.js:72 throw er; // unhandled 'error' event ^ error: unrecognised input in file obviously try catch mechanism wrong, think protects pipe-building step not pipe-running time. q: how can write gulp-watch task, continues working when less fails? either go events gulp.src(filename) .pipe(sourcemaps.init()) .pipe(less()) .on('error', console.log) .pipe(sourcemaps.write()) .pipe(gulp.dest(

Will upgrading matlab from 2009b to 2015 improve performance of mex Functions? -

i using matlab 2009b run optimizations based on mex code. time spent in numerous calls mex function more 95%. using cygwin64 compiler on windows machine, setup using gnumex. i want know if there noticeable decrease in optimization time if upgrade matlab 2015. the release notes @ matlab ( http://in.mathworks.com/help/matlab/release-notes.html ) mentions several performance improvements on course of various release if can quantify it, can useful make decision. tested 2015a , difference in performance less 2 seconds in 90 minute test. appears mex performance not depend on matlab version.

Jquery and PHP. Seems not working to trigger some of the elements -

i have jquery , in case want process click of user display right content them through $.post method of jquery. want want access appended html tags on put-content through jquery too. sorry bad english., $(document).ready(function(){ var j = jquery.noconflict(); j('.menus ul li a').on('click', function(){ var val = j(this).attr('id'); if (val != undefined) { j.post('content_process.php', { id_attrib: val }, function(response) { if (val == 'job-application') { j('#put-content').empty(); j('#put-content').append(response); j('#put-content #time-container').click(function() { alert('naa'); }); } else if (val == 'profile') { j('#put-content').empty(); j('#put-content'

database - What is the best way to load a massive amount of data into PostgreSQL? -

Image
i want load massive amount of data postgresql. know other "tricks" apart ones mentioned in postgresql's documentation? what have done now? 1) set following parameters in postgresql.conf (for 64 gb of ram): shared_buffers = 26gb work_mem=40gb maintenance_work_mem = 10gb # min 1mb default: 16 mb effective_cache_size = 48gb max_wal_senders = 0 # max number of walsender processes wal_level = minimal # minimal, archive, or hot_standby synchronous_commit = off # apply when system load data (if there other updates clients can result in data loss!) archive_mode = off # allows archiving done autovacuum = off # enable autovacuum subprocess? 'on' checkpoint_segments = 256 # in logfile segments, min 1, 16mb each; default = 3; 256 = write every 4 gb checkpoint_timeout = 30min # range 30s-1h, default = 5min checkpoint_completion_target = 0.9 # checkpoint target duration

c# - Trying to populate textbox and listview from txt file -

i'm able save textbox text , listview items txt file using: private void savetoolstripmenuitem_click(object sender, eventargs e) { if (savefiledialog1.showdialog(this) == system.windows.forms.dialogresult.ok) { using (streamwriter writer = new streamwriter(savefiledialog1.filename)) { //writer.writeline(accounttext.text); writer.writeline(accounttext.text); if (transactionlist.items.count > 0) { foreach (listviewitem item in transactionlist.items) { stringbuilder newstring = new stringbuilder(); foreach (listviewitem.listviewsubitem listsub in item.subitems) { newstring.append(string.format("{0}\t", listsub.text)); } writer.writeline(newstring.tostring());

ruby on rails - Could not find 'sprockets' (~> 2.2.1) among 166 total gem(s) (Gem::LoadError) -

gemfile gem 'sprockets', git: 'https://github.com/tessi/sprockets.git', branch: '2_2_2_backport2' gem 'sprockets-rails', git: 'https://github.com/finnlabs/sprockets-rails.git', branch: 'backport' when stating server, facing issue error: /home/kannan/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs': not find 'sprockets' (~> 2.2.1) among 166 total gem(s) (gem::loaderror) /home/kannan/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/specification.rb:1295:in `block in activate_dependencies' /home/kannan/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/specification.rb:1284:in `each' so that, unable start application. please us ref project https://github.com/opf/openproject

android - Websocket.disconnect() method throws java.net.SocketException: Socket closed -

i using android-websockets library codebutler in project. ran problem when execute disconnect() method. following code: public void disconnectserver() { if(client != null) { try { if(client.isconnected()) { client.disconnect(); } } catch (exception e) { e.printstacktrace(); } } } i following exception: 05-11 17:58:19.873: w/system.err(29443): java.net.socketexception: socket closed 05-11 17:58:19.873: w/system.err(29443): @ libcore.io.posix.recvfrombytes(native method) 05-11 17:58:19.873: w/system.err(29443): @ libcore.io.posix.recvfrom(posix.java:161) 05-11 17:58:19.873: w/system.err(29443): @ libcore.io.blockguardos.recvfrom(blockguardos.java:250) 05-11 17:58:19.878: w/system.err(29443): @ libcore.io.iobridge.recvfrom(iobridge.java:553) 05-11 17:58:19.878: w/system.err(29443): @ java.net.plainsocketimpl.read(plainsocketimpl.j

php - How to set different index pages depending on logged in users role in yii -

i working on 1 yii project. have used rbac module in user management. user roles admin , superadmin , sales , authenticated , customer . i want redirect users per roles after logging in. example, admin , superadmin should see page1 index page (default action) after login , customer should see page2 index page (default action) after login. have set menu depending upon user roles i.e. menu tabs should visible whom. also aware setting default action in yii. i.e. in main.php file, have set default controller action. don't understand how can solve problem. please me this. thanx in advance. one possibility check if request_uri / , redirect appropriate controller , action based on role.

ios - Swift: Cannot get correct height of header cell's label after sizetofit -

i have add sizetofit() uilabel, cannot correct height cannot show text. show " academic, administrative, teaching and " testing target: iphone 6 coding: class eventsviewcontroller: uitableviewcontroller { var headername: array<string> = ["academic, administrative, teaching , learning support units"] override func viewdidload() { self.tableview = uitableview(frame: self.tableview.frame, style: .grouped) self.view.backgroundcolor = uicolor(white: 0.9, alpha: 1.0) self.tableview.estimatedrowheight = 102 } override func tableview(tableview: uitableview, viewforheaderinsection section: int) -> uiview? { var headercell = tableview.dequeuereusablecellwithidentifier("eventsheadercell") as! uitableviewcell! if headercell == nil { headercell = uitableviewcell(style: uitableviewcellstyle.default, reuseidentifier: "eventsheadercell") } headercell!.backgroundcolor = uicolor(wh

c# - How to restrict user to select only current month dates in datetimepicker control? -

i want user select dates of current month don't know should put in min , max date property. is there property of ' current month '? since both mindate , maxdate property takes datetime , can set them like; datetimepicker1.mindate = new datetime(datetime.now.year, datetime.now.month, 1); datetimepicker1.maxdate = (new datetime(datetime.now.year, datetime.now.month, 1)) .addmonths(1).adddays(-1);

c++ - read binary file into the address of vector element -

i have binary file contains doubles of size of 8 bytes. want read doubles vector<double> , see below ifstream infile("x.dat", ios::binary); vector<double>data(filesize/8, 0.0); for(int i=0; i< (filesize/8); ++i) { infile.read( (char *) (&data[i]), sizeof(double) ); } i know work if data c array, not sure if work vector , since vector contains more stuff c array( vector has methods), address &data[i] mean address of data member of ith element? yes, each vector element double object, , &data[i] points object. in fact, double objects in contiguous array, can read them @ once: infile.read((char*)data.data(), filesize); of course, noted below, requires file have been written in format compatible program's binary representation of double values, otherwise values garbage.

r - structural holes and adjacency matrix -

i working on problem find measures related structure holes in r. problem when apply code below save adjacency matrix variable called "x" (copied source) adjacency matrix in r gives me error like: "error in as.data.frame.default(d) : cannot coerce class ""igraph"" data.frame" my code , data set looks data frame s1 uid1 uid2 1 1 2 2 1 3 3 1 4 4 1 5 5 2 3 6 2 4 7 2 5 8 3 4 9 3 5 10 4 5 11 6 7 12 6 8 13 6 9 14 7 8 15 7 9 16 8 9 17 1 6 18 1 7 19 6 7 when apply code error becomes on here x <- get.adjacency(graph.data.frame(graph.edgelist(as.matrix(s1), directed=f))) error in as.data.frame.default(d) : cannot coerce class ""igraph"" data.frame so use code structure holes measure y <-

android - Setting up search interface in fragment -

i have read how setup search interface on google dev guide here http://developer.android.com/training/search/setup.html i able replicate activities. but, application uses navigation drawer , fragments. 1 of fragments need implement actionbar search shows suggestions user type. able setup search view particular fragment. but, still not sure how implement onnewintent() , how set searchable configuration on manifest file. @ possible implement search interface fragments. if so, can please provide code samples or links reference? thanks onnewintent() called singletop/task activities except first time when activity created. @ time oncreate called. you can invoke onnewintent putting oncreate method like @override public void oncreate(bundle savedstate) { super.oncreate(savedstate); onnewintent(getintent()); } @override protected void onnewintent(intent intent) { super.onnewintent(intent); //code }

android - Is it recommended to call onDetach() & onAttach() method of the FragmentTransaction manually -

i want change font size of entire application. have used 3 styles(small, medium,large), keeping app theme parent. whenever user selects the font change button, based on selected style, i'm changing font size of entire application. since, fragment, theme has applied inside oncreateview(), before inflating layout,theme not applied fragment on click of font size change button. need refresh fragment, it's view recreated. i'm manually detaching fragment , attaching again activity. destroys fragment view , recreates , fragment ui updated. query is, recomended call ondetach() & onattach() manually? how i'm refreshing fragment: private void reloadfragment() { android.support.v4.app.fragmentmanager mngr = getsupportfragmentmanager(); fragment fragment = mngr.findfragmentbyid(r.id.container); if (fragment instanceof homefragment) { try { sectionpageradapter adapter = ((homefragment) fragment).getadapter();

python - Django Polls App: OperationalError: attempt to write a read only database -

i going through tutorial on django website. got error while trying create choice object. >>> q.choice_set.create(choice_text='not much', votes=0) traceback (most recent call last): file "<console>", line 1, in <module> file "/library/python/2.7/site-packages/django-1.7.8-py2.7.egg/django/db/models/fields/related.py", line 714, in create return super(relatedmanager, self.db_manager(db)).create(**kwargs) file "/library/python/2.7/site-packages/django-1.7.8-py2.7.egg/django/db/models/manager.py", line 92, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) file "/library/python/2.7/site-packages/django-1.7.8-py2.7.egg/django/db/models/query.py", line 372, in create obj.save(force_insert=true, using=self.db) file "/library/python/2.7/site-packages/django-1.7.8-py2.7.egg/django/db/models/base.py", line 589, in save force_update=force_update, update_fields=

regex - Extract multiple instances of a pattern from a string in R -

i have character vector t follows. t <- c("gid456 spk711", "gid456 gid667 vink", "gid45345 dnp990 gid2345", "gid895 gid895 k350") i extract strings starting gid , followed sequence of digits. this works, not retrieve multiple instances. gsub(".*(gid\\d+).*", "\\1", t) [1] "gid456" "gid667" "gid2345" "gid895" how extract strings in case? desired output follows out <- c("gid456", "gid456", "gid667", "gid45345", "gid2345", "gid895", "gid895") here's approach using package maintain qdapregex (i prefer or stringi/stringr) base consistency , ease of use. show base approach. in event i'd @ more "extraction" problem subbing problem. y <- c("gid456 spk711", "gid456 gid667 vink", "gid45345 dnp990 gid2345", "gid895 gid8

xml - Magento - disable pagination ( not hide ) -

i'm using magento 1.9, , need disable pagination specific category template. i'm using custom product_list.phtml , product_list_toolbar.phtml, can't find anyway disable pagination. want dump products on page. i not want hide toolbars , want prevent pagination functionality specific category. thanks in advance!! if else having problem. couldn't find official way stop pagination, found work around. in themes local.xml file defined new range(100) pagination, , set default. hide toolbars via list.phtml file. let me show product on single page. example: targeting category3 <category_3> <reference name="product_list_toolbar"> <action method="addpagerlimit"><mode>grid</mode><limit>100</limit></action> <action method="addpagerlimit"><mode>list</mode><limit>100</limit></action> <action method="setdefault

compiler construction - Creating a grammar for function prototypes and declaration bison -

i'm build compiler school project. works fine having difficulty defining grammar functions. have detect if there 0 or more parameters , if function either prototype or definition. keep getting shift/reduce and/or reduce/reduce errors. have tried many variations no avail. here have, looking pointers in direction or ideas on how fix this. function : parameters ';' {free_ast($2); $$ = $1;} | parameters block {$$ = adopt1($1, $2)} ; parameters : paramlist ')' {free_ast($2); $$ = $1;} | '(' identdecl ')' {free_ast($3); $$ = adopt_func2($1, $2);} ; paramlist : paramlist ',' identdecl {free_ast($2); $$ = adopt1($1, $2);} | '(' identdecl {$$ = adopt_func2($1, $2);} identdecl : basetype tok_array tok_ident {$$ = adopt2($1, $2, change_symbol(

java - Why am I getting a false value at if (users.contains(user))? -

Image
i think user.contains not reading every line , checking first line. had working right earlier(i testing duplicate user portion of code), program skipping : { joptionpane.showmessagedialog(null, "duplicate user found."); goahead=false; dispose(); } i not sure did, or how managed break own program. skipping way to: else { if (hs.contains(new string(un+" "+pw))) { joptionpane.showmessagedialog(null,"user, found access granted!"); dispose(); } where did go wrong? private void submitactionperformed(java.awt.event.actionevent evt) { string un = username.gettext().trim(); string pw = password.gettext().trim(); hashset hs= new hashset(); hashset users = new hashset(); boolean goahead=true; try { scanner scan = new scanner(new file("login.txt&qu