Posts

Showing posts from January, 2010

ios - Closures in Swift, blocks in Objective-C: their usefulness and when to use -

i've found objective-c socketio library , trying implement in first swift app. here's code i'm trying port: __weak typeof(self) weakself = self; self.socket.onconnect = ^() { weakself.socketisconnected = yes; [weakself mapview: weakself.mapview didupdateuserlocation: weakself.mapview.userlocation]; }; from limited understanding ^() {} block in objective c. i've looked , closures seem loose equivalent swift . first obvious question how same result in swift? i've tried following error fatal error: unexpectedly found nil while unwrapping optional value (lldb) : self.socket.onconnect = { () -> void in println("connected!") } also, behind scenes what's happening here? asynchronous callback function seem appropriate wasn't used , i'd understand why. update as pointed out @jtbandes, socket in fact nil code running outside of connection callback (i know, silly mistake). solution first question: siosocket.socketwith

ios - Objective C error [__NSCFNumber length]: unrecognized selector sent to instance -

i m writing tableview based application. works when use default cells in tableview. when try make customs cells have error : 2014-12-01 22:50:01.690 signaturegourmande[15701:624637] -[__nscfnumber length]: unrecognized selector sent instance 0xb0000000000000c3 2014-12-01 22:50:01.716 signaturegourmande[15701:624637] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nscfnumber length]: unrecognized selector sent instance 0xb0000000000000c3' the application works when have code : static nsstring *simpletableidentifier = @"simpletableitem"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:simpletableidentifier]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:simpletableidentifier]; } cell.textlabel.text = [nomdata objectatindex:indexpath.row]; return cell; i have error when replace code : static nsstring

node.js - IMAP APPEND with gmail, treat as new incoming email -

i have got nodejs app imap "append" new message gmail, custom date/time. works fine. but, how make gmail treat actual new incoming email? (which needs sorted based on existing filters, pushed spam if needed,etc). functions carried out on new incoming email gmail. there such event can raised on newly created email, maybe using uid? gmail support such functionality through imap? p.s: using "inbox" npm package. tried reading imap spec, couldn't understand much. (only got understand append command part). no. imap append means 'put directly in folder'. can use flags argument of append make sure don't mark \seen, it'll unread message. the way make new email steps , filtering send via smtp.

regex - R: how to find the first digit in a string -

string = "abc3jfd456" suppose have above string, , wish find first digit in string , store value. in case, want store value 3 (since it's first-occuring digit in string). grepl("\\d", string) returns logical value, not tell me or first digit is. regular expression should use find value of first digit? base r regmatches(string, regexpr("\\d", string)) ## [1] "3" or using stringi library(stringi) stri_extract_first(string, regex = "\\d") ## [1] "3" or using stringr library(stringr) str_extract(string, "\\d") ## [1] "3"

javascript - Lodash/Underscore : Check for a value within an array, in an array of objects -

confusing title, simple way explain show i'm after : var user = [ {foo:"test",bar:1}, {foo:"test2",bar:2} ]; var items = [{foo:"test",bar:1},{foo:"test4",bar:4},{foo:"test5",bar:5}] what want, pick one item items not in user , , add user . in case user object end looking : user = [ {foo:"test",bar:1}, {foo:"test2",bar:2}, {foo:"test4",bar:4} ]; i've tried sorts of _.filter, _.contains, etc... combinations, can't quite figure out. appreciated! the logic follows: want find first item not contained within user array. so can following: var item = _.find(items, function (item) { return !_.findwhere(user, item); }); jsfiddle demo

security - Add password-protected WYSIWYG editing to HTML page -

i'd able grant password protected html editing flat html website. of course install content management system, seems sledge hammer crack nut. is there library/framework lets me add <script>.. html file handle: a username , password facility wysiwyg editing ability save ckeditor looks promising, doesn't seem support (a) username/password (b) option save edit!

numpy - Python , check if a list follows a distribution -

i'm trying find short way check if list elements follow general distribution : list = [1,3,5,7,9,11] the difference between list[i] , list[i+1] 2 , function want needs take in consideration list[i+1] - list[i] >= 2 . one liners or lambdas welcome ! try this: >>> l = [1,3,5,6,8,10] >>> all(y - x >= 2 x, y in zip(l, l[1:])) false >>> l = [1,3,5,7,9,11] >>> all(y - x >= 2 x, y in zip(l, l[1:])) true as usual consider izip instead of zip if memory concern.

python - returning results from matplotlib widget -

ok general problem have number of datasets, good, bad. want plot them use checkbuttons widget choose datasets. average these datasets , returned processed further , next load of data called. essentially have 2 graphs callable g , f 1 2 axes (with data averaged) , second shows average of selected check boxes. need pause in code until happy data selection , have been trying use matplotlib button stop , return current average. struggling s1,s2=call.average() #return average of checked lines av1,=ax1.plot(x,s1) av2,=ax1.plot(x,s2) def func(label): if call.d[label]==1: #values d[label]==1 averaged, 0 ignored call.d[label]=0 elif call.d[label]==0: call.d[label]=1 # every time check box changed new average calculated , plotted s1,s2=call.average() av1.set_ydata(s1) av2.set_ydata(s2) f.canvas.draw() def end(event): return #from , outer function... ##code check button

user interface - PSD pixels to ios points -

i received design (photoshop) layout designer in pixels. how convert points required ios? i tried substituting pixles points thinking may 1:1 conversion on coding in app design looks weird (bigger expected). table header height example: tried converted 32px+40px of psd = 72 points in ios in comps table header little bigger navbar (which ofcourse 44 points). should designer providing layout in points rather pixels? if not how convert pixels points ios? converting pixels points depends on target ios device. on 1x device (ipad 1 & 2, iphone 3gs), 1 uikit point == 1 pixel. on retina devices (ipad 3 , up, iphone 4 , up), 1 uikit point == 2 pixels.

java - Painting array of constant size? -

i having trouble doing simple, painting array of elements. here have paint method in class array: ( xb , yb x , y values want increment make instances show in different locations). public void paint(graphics pane) { private box[] boxes = new box[num_box]; for(int = 0; i<num_box; i++){ if (xb == 290){ xb = 0; yb = yb + 20; } boxes[i].paint(pane, xb, yb); xb = xb + 20; } and here have in box class being painted: public class box { private final int width = 20; private final int height = 20; private boolean = true; public void paint(graphics pane, int x, int y) { pane.setcolor(color.black); pane.drawrect(x, y, width, height); pane.setcolor(color.gray); pane.fill3drect(x +2, y+2, width - 3, height - 3, up); } } every time run it, tells me there nullpointerexception @ boxes[i].paint(pane,xb,yb) line. doing wrong?

ios - iAd Banner Notification? -

i'm using following code setup vc can display banner ads [self setcandisplaybannerads:yes]; the problem i'm having display text @ bottom of application unless of course banner ad appears in case place text on top of banner. can't seem find delegate method called or other way make happen using setcandisplaybannerads. missing simple here? iad banner has 2 delegate methods notifies observer whether iad banner available display or not. these delegate methods are: #import <uikit/uikit.h> #import <iad/iad.h> @interface viewcontroller : uiviewcontroller<adbannerviewdelegate> - (void)bannerviewdidloadad:(adbannerview *)banner { if (!_bannerisvisible) { _bannerisvisible = yes; } } - (void)bannerview:(adbannerview *)banner didfailtoreceiveadwitherror:(nserror *)error { _bannerisvisible = no; } @end with _bannerisvisible bool variable can decide when show text there or not.

jasper reports - How to add email hyperlink in ireport -

This summary is not available. Please click here to view the post.

python - Appending leading zeroes to a given value -

this question has answer here: display number leading zeros 11 answers i have various inputs below,i need make given digit 4 letter , append leading zeroes make 4 digit , add "00.00" @ front,can suggest how this? input:- val = int(95) val = int(115) val = int(5) expected output:- 00.00.0095 00.00.0115 00.00.0005 you this, assuming 00.00 constant. print(["00.00.{:>04d}".format(v) v in [95, 115, 5]]) # ['00.00.0095', '00.00.0115', '00.00.0005']

Can I use 'where' inside a for-loop in swift? -

is there possibility use 'where' keyword in place switch? can use in in loop example? i have array bools, value, can this: var boolarray: [bool] = [] //(...) set values , stuff value value == true in boolarray { dosomething() } this lot nicer use if, wondering if there possibility use in combination for-loop. ty time. in swift 2, new where syntax added: for value in boolarray value == true { ... } in pre 2.0 1 solution call .filter on array before iterate it: for value in boolarray.filter({ $0 == true }) { dosomething() }

sql - SQLite conditional output -

i need output x in column in report created using sqlite. i need find patern, , if pattern exsists record output x, if not found output blank space. heres have. select `device_type` "device", substr(`model`, 1, 30) "model", `location` "location", (case when (`user_tag` "%decommissioned%" "x" else " " end) "decom", count(`id`) "count" `devices` group `device_type` order `device` asc; its reporting near "then": syntax error like said, can use sql putting report together. little limiting im allowed use this. thanks in advance help. i think right syntax: select `device_type` device, substr(`model`, 1, 30) model, `location` "location", (case when `user_tag` "%decommissioned%" "x" else " " end) "decom", count(`id`) "count" `devices` group device_type, substr(`model`, 1, 30), loc

javascript - Angularjs routing using $state gotten raw html tags -

i used below code , gotten raw html result. i'm seeing expression of {{welcome}} etc. guess i'd done wrong somewhere , caused failed render. didn't see error in console of chrome. my app.js app.config(function($stateprovider, $urlrouterprovider) { $stateprovider .state('threadlisting', { url: '/', templateurl: 'threadlisting.html', controller: 'appctrl' }) .state('threaddetail.php', { url: '/threaddetail', templateurl: 'threaddetail.html', controller: 'appctrl' }) $urlrouterprovider.otherwise("/"); }) my html this <ion-content> <script id="threadlisting.html" type="text/ng-template"> <ion-view> <h1>welcome {{name}}</h1> </ion-view> </script> <script id="threaddetail.html" type="text

php - Laravel 4 - MySQL User Configuration for Production -

i've been doing quite bit of research on laravel 4 framework , wanted know how people configure database user privileges production apps. in documentation i've read shows use root root privileges. production apps using mysql root login? , if not, privileges granted user? i tried create database user 'dev-app' schema privileges on database used app allowing object , ddl privileges. unfortunately i'm getting "access denied user ... " error message when run 'php artisan migrate'. before grant user , keep coding, wanted know how set these users in database. thanks i re-created user , added permissions available laravel database , seems work should. tips , comments.

Overload a form in symfony -

i overload form of bundle foscomment. know have create new bundle comment or if can working/main bundle ? sorry english. thank you, david namespace fos\commentbundle\form; use symfony\component\form\abstracttype; use symfony\component\form\formbuilderinterface; use symfony\component\optionsresolver\optionsresolverinterface; class commenttype extends abstracttype { private $commentclass; public function __construct($commentclass) { $this->commentclass = $commentclass; } /** * configures comment form. * * @param formbuilderinterface $builder * @param array $options */ public function buildform(formbuilderinterface $builder, array $options) { $builder->add('body', 'textarea') ->add('lien', 'text', array('required' => false, 'empty_data' => null)); } publi

How to write a javascript function that figures out the angle of two points? -

assuming straight line pointing north 0 degrees , goes 359. if given 2 points each x , y value, how find out "angle" makes between first point , second point? assuming (arctan2) function exists okay. i have following: var x = x2 - x1; var y = y2 - y1; var radian = arctan2(y, x); var degrees = radian * 180 / 3.14; i seem getting "0 degrees" on right arrow , 270 pointing north instead of 0 degrees looking towards north. if coordinate system have 0 degrees pointing up/north x comes first atan2 function: var x = x2 - x1; var y = y2 - y1; var angledegrees = math.atan2(x, y) * 180 / math.pi; if (angledegrees < 0) angledegrees += 360; // force positive value

c# - SelectedIndexChanged event not firing in child control -

i have asp.net control references user control(popup) when button pressed. when button pressed find drop down list in popup user control , set selected value of it. protected void btnmybutton_click(object sender, eventargs args) { pnlusercontrol_modalpopupextender.show(); if (ddparent.selectedindex > 0) { dropdownlist dd = ucmycontrol.findcontrolrecursive("ddchild") dropdownlist; dd.selectedvalue = ddparent.selectedvalue; } } in popup user control i'm expecting selectedindexchanged event fire. however, isn't. ideas why case? markup child control(only relevant code) below: <asp:formview id="myform" runat="server" datasourceid="dsmyds" defaultmode="insert"> <edititemtemplate> <asp:panel runat="server"> <table> <tr> <td> <asp:label text=&

activerecord - how to join named scopes in rails -

i want join named scopes generate them array. how wouldi , can't join named scopes, there better way this? scope :search, ->(attrs_for_search,params) if attrs_for_search.present? params_to_search_on = params.keys & attrs_for_search params_to_search_on.collect{|x| where("#{x} ilike ?", "%#{params[x]}%") } else none end end contact.search(%w[email],{'email => 'jason'}) i think can create scope , use 'send' method join scopes. scope :search, ->(field, value) where("#{field} ?", "%#{value}%") end def self.multi_search(params) result = nil params_to_search_on = params.keys params_to_search_on.each |k| if result.nil? result = message.send(:search, k, params[k]) else result = result.send(:search, k, params[k]) end end result end hopes you.

split - Convert matlab symbol to array of products -

can convert symbol product of products array of products? i tried this: syms b c d; d = a*b*c; factor(d); but doesn't factor out (mostly because isn't factor designed do). ans = a*b*c i need work if b or c replaced arbitrarily complicated parenthesized function, , nice without knowing variables in function. for example (all variables symbolic): d = x*(x-1)*(cos(z) + n); factoring_function(d); should be: [x, x-1, (cos(z) + n)] it seems string parsing problem, i'm not confident can convert symbolic variables afterwards (also, string parsing in matlab sounds tedious). thank you! use regexp on string split based on * : >> str = 'x*(x-1)*(cos(z) + n)'; >> factors_str = regexp(str, '\*', 'split') factors_str = 'x' '(x-1)' '(cos(z) + n)' the result factor_str cell array of strings. convert cell array of sym objects, use n = numel(factors_str); factors = cell(1,n); %//

how do you get <div> value using angularjs? example <div id="text">Text</div> -

how value using angular js? how can text content using angularjs? if got question right, mean ask how can set content in dom using angularjs. explaining simple example here. <div ng-app="" ng-controller="personcontroller"> first name: <input type="text" ng-model="firstname"><br> last name: <input type="text" ng-model="lastname"><br> <br> full name: <p>{{firstname + " " + lastname}}</p> </div> <script> function personcontroller($scope) { $scope.firstname= "john"; $scope.lastname= "doe"; } </script> in angularjs initialize application ng-app, ng-controller defines scope, here personcontroller. in personcontroller defination settting 2 variable firstname , last name. these 2 set value can using "{{ }}". there many other ways of setting value recommend go through angular basic tutorials can under

Laravel 4 timstamp -

i have field in mysql table type 'timestamp' , using calendar on view date in format dd/mm/yyyy. inserting data following code $billing = new billing; $billing->date = input::get('date'); $billing->save(); it filling data 0000-00-00 00:00:00 in field. how can correct value. tried convert timestamp followed. $billing = new billing; $billing->date = date("y-m-d h:i:s",strtotime(input::get('date'))); $billing->save(); but not working...can 1 help!!! if understand correctly, mysql timestamps have saved strings in yyyy-mm-dd hh:ii:ss format (ie, returned date('y-m-d h:i:s')). convert date('y-m-d h:i:s'), strtotime(input::get('date')))

pdf generation - What makes some pdf files much smaller than others? -

i have number of pdf textbooks, , of them upwards of 400 megabytes 1000 pages while others (which similar in quality) 10 megabytes 1500 pages!! thought might image quality, images similar in quality. next, took @ text when zoomed in, , saw larger books have rasterized text while smaller files looked had vector text. it? if so, how can start making pdf files in vector format? possible scan document / use ocr recognize text, , somehow convert rasterized text vector format? also, can convert rasterized texts vector format? cheers, evans check command on sample each 2 different pdf types: pdfimages -list -f 1 -l 10 the.pdf (your version of pdf images should recent one, poppler variant.) gives list of images first 10 pages. lists image dimensions (width, height) in pixels, image size (in bytes) , respective compression.) if can bear it, can run: pdfimages -list the.pdf this gives list of all images all pages. i bet larger 1 has more images listed. pdfs scan

android - Sencha application cost too much ram -

i'm develop android applications using sencha. problem apps using lot of ram when running, when press home button , see in settings, cost 150mb in cached processes , increase time time. cause app crashed lot , restart whenever press app's icon in menu. there anyway me decrease usage ram or prevent app automatically exit or crashed, please give me idea. thanks

c - How to use popen to input and output in the same time? -

this question has answer here: linux 3.0: executing child process piped stdin/stdout 3 answers i use psuedo-code express want do: file* fd = popen("/bin/cat", ...); write data stdin of `/bin/cat` using fd; read data stdout of `/bin/cat` using fd; is possible? popen() can read new process. if need read , write, create pipe connected new process using pipe() . fork new process using fork() redirect process's input , outputs pipes created earlier using dup2() call exec on child process (the new process) using exec family functions

android - Unable to execute dex:Multiple dex files define -

Image
when build android project , following error. want use jdbc driver connect sql server. [2014-12-02 10:17:40 - dex loader] unable execute dex: multiple dex files define lcom/microsoft/sqlserver/jdbc/activitycorrelator$1; [2014-12-02 10:17:40 - sql_wcf] conversion dalvik format failed: unable execute dex: multiple dex files define lcom/microsoft/sqlserver/jdbc/activitycorrelator$1; go order , export tab possibly should : make sure : jar in order , export checked. dont add multiple or duplicate lib.

hadoop - What is the best way to write a Scala object to Parquet? -

i have scala case class created json, case class person(age:int, name:string). know cannot write json parquet. can write case class directly parquet or need use format scrooge/thrift or avro? apis best use this? i think need implement parquetwritesupport class write custom class.

regex - Extract substring containing multiple double quote marks JAVA -

i want extract values between double quote marks in java sample string: i sample string. "name":"alfred","age":"95","boss":"batman" end of sample the end result should array of: [name,alfred,age,95,boss,batman] *actual string contain unknown number of values between "" declare array , store match results that. ([^\"]*) captures character not of " 0 or more times. () called capturing group used capture characters matched pattern present inside group. later refer captured characters through back-referencing. string s = "i sample string. \"name\":\"alfred\",\"age\":\"95\",\"boss\":\"batman\" end of sample"; pattern regex = pattern.compile("\"([^\"]*)\""); arraylist<string> allmatches = new arraylist<string>(); matcher matcher = regex.matcher(s); while(matcher.find()){ al

java - Entering numbers in program using while loop -

i beginner in java, can please explain me how total 11. question - user ready enter in these numbers 1 one until program stops: 4 7 5 8 9 3 4 1 5 3 5 what displayed total? int number; int total = 0; system.out.print("enter number"); number = input.nextint(); while (number != 1) { if (number < 5) total = total + number; system.out.print("enter number"); number = input.nextint(); } system.out.println(total); i'll explain step step. step - 1: you've declared 2 integer variables. 1 holding input, , holding total value after calculation. integer total initialized 0. following part of code doing this: int number; int total = 0; step - 2: now you're providing input values. input values entering while loop. while loop continue execute unless input value 1 . first input 4 , 4!=1, so, enters loop. system.out.print("enter number"); number = input.nextint(); while (number != 1) { step - 3: now, inside loop, you'r

java - the app force close after submitting the data into mysql -

i tried internet tutorial inserting data mysql android in activity_main.xml, there button register new user. put information such firstname, etc. when user clicks submit button, should redirect activity_main.xml. when click submit, app forced close, , data not inserted mysql database. my question is, wrong in code ? please give me advice. in code same had used android application. providing log traces here. appreciated... regactivity.java package com.example.estate; import java.util.arraylist; import java.util.list; import org.apache.http.namevaluepair; import org.apache.http.message.basicnamevaluepair; import org.json.jsonexception; import org.json.jsonobject; import android.app.activity; import android.app.progressdialog; import android.content.intent; import android.os.asynctask; import android.os.bundle; import android.util.log; import android.view.view; import android.widget.button; import android.widget.edittext; public class regactivity extends activity { // pro

Rails 4 - Unpermitted Paramaters - Deeply nested attributes form not saving -

i'm working on nested attributes , running unpermitted attributes error. log: started post "/videos/1/quizzes" processing quizzescontroller#create html parameters: {"utf8"=>"✓", "authenticity_token"=>"xdj5lpz7quvezivybphnv0t/npmmtkval2dcwrxhvqu=", "quiz"=>{"name"=>"test", "question"=>{"content"=>"test", "answer"=>{"content"=>"test"}}}, "commit"=>"submit", "video_id"=>"1"} video load (0.1ms) select "videos".* "videos" "videos"."id" = ? limit 1 [["id", 1]] unpermitted parameters: question so data being submitted. reading around looks nested question parameters supposed "question_attributes"=> in log shows "question"=>. don't know if has it? @ point it's idea. quizzes#

jquery - how to show data in bootstrap charts using c#? -

i have data below . need show data based on class total absentees , presentess.can give suggestion query.i'm using c#.net data getting. need dispaly data in bootstrap barchart classid classname presnt absent 18 nursery 20 0 19 lkg 47 0 20 ukg 15 0 21 first class 34 0

jquery - How to layout images in a grid? -

Image
i have 3 rows of images. each image made of: <span class="tribeimg"> <img src="images/tribes/img.jpg"> <p class="lt-tribe-name">tribe name</p> </span> with css.. .tribeimg { background-color: black; display: inline-block; position: relative; width: 140px; height: 140px; } .tribeimg img { opacity: 0.7; position: absolute; left: 0; top: 0; } .tribeimg img:hover, .tribeimg p:hover { cursor: pointer; } .tribeimg .lt-tribe-name { opacity: 0.7; z-index: 11; color: white; position: absolute; left: 32px; bottom: 50px; text-shadow: 1px 1px 8px black; } you can see layout here: http://128.199.58.229/landingpage/ the images aligning correctly until tried add text on image. broke layout. how fix it? or there better way lay them out? in second row have exception of div block no image.. it's not straight forward image grid exactly. thanks. add vertical-align: top .lt-block-tagline . .lt-block-tagline {

How to open image in full screen by clicking on listview in android tutorial app -

the following got till now. bug whenever click on listitem following error occurs unfortunately app has stopped working listviewadapter.class public class listviewadapter extends baseadapter { protected static long[] itemvie; // declare variables context context; layoutinflater inflater; arraylist<hashmap<string, string>> data; imageloader imageloader; hashmap<string, string> resulta = new hashmap<string, string>(); public listviewadapter(context context, arraylist<hashmap<string, string>> arraylist) { this.context = context; data = arraylist; imageloader = new imageloader(context); } @override public int getcount() { return data.size(); } @override public object getitem(int position) { return null; } @override public long getitemid(int position) { return 0; } @suppresslint("viewholder") public view getview(final int position, view convertvie

android - Is there a way to make AppCompat's ActionBar's "back/up" button act as the "back" system button -

i have app couple of activities. until had "hardcoded" hierarchy between them, had android:parentactivityname set explicitly in each (but launcher activity) of them. added settings menu of more 1 activity. is there way make "back" arrow in action bar function system's button (in bottom of screen)? in other words: if there's parentactivityname set, goes parent activity, if not, closes activity , "goes back" previous activity. this tried, doesn't work. if don't call actionbar.setdisplayhomeasupenabled(true), there's no "back" arrow in action bar, if call in activity doesn't have parentactivityname set in manifest, exception when click arrow. abstract public class baseactivity extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(getlayoutresourceid()); final actionbar actionbar = getsupportaction

c - Program halts after while loop fget() -

i've been trying solve on few days , it's still doing head in. had scrappy working program, , decided clean little, something's gone wrong in process. part of program puts csv data (from file rfile4) new file (tmp41) use later: file *report4=fopen(rfile4,"r"); file *tmp41=fopen(tmpfile41,"w+"); if(!tmp41||!report4) { fprintf(stderr, "failure - 'report' input file not found\n"); exit(exit_failure); } const char comma[2]=","; int nreports=0; while(fgets(line,size,report4)!=null) { char linestore[size]; char mcodecheck[size]; strncpy(linestore,line,size); char *tkndmp=linestore; int count1=0; while((tkndmp=strtok(tkndmp,comma))!=null) { count1++; if(count1==4) { sscanf(tkndmp,"%s",mcodecheck); if(strcmp(mcode,mcodecheck)==0

java - Error in SECKFMDefaultPromptHandler: func=18: Unknown security function code -

i tried set new windows 7 kvm lotus domino , java eclipse environment. installed lotus notes 9.0.1 fp2 (incl. domino designer) , eclipse luna ide. furthermore added c:\notes directory windows paths. when started java code working old kvm @ line session s = notesfactory.createsession((string)null, (string)null, config.getnsfpwd()); the program gives me error [0524:0002-0f44] 02.12.2014 09:10:35 error in seckfmdefaultprompthandler: func=18: unknown security function code. do have ideas how code running?

c# - Is JSON.Net guaranteed to always serialize the same way? -

i need generate 'string' key based on state of object. thought of serializing object json , use result key. works if json.net serializes same way. is json.net guaranteed serialize same way on same machine if object of same class same state if encountered? yes, otherwise unit tests fail. there order property on jsonpropertyattribute if want explicitly state order.

c# - Is Cyclomatic Complexity of '267' better? -

i have developed application in .net using c#. using 'calculate code metrics' option, got cyclomatic complexity score of '267' 2,348 lines of code , depth of inheritance = 7, class coupling = 150 , maintainability index = 80. i know lower cyclomatic complexity, better is. though unaware of rest of parameters, wish know if cyclomatic complexity of 267 better or not? cyclomatic complexity typically refers number of independent paths through code. measured following formula in visual studio: complexity = edges - nodes + 1 for given method, 25 considered dangerously high , causes visual studio throw error. ideally, want keep cyclomatic complexity low possible. try aiming 3-4 , maxing out @ around 10. for entire project, number not meaningful enough compare between separate projects. if refactoring code, can use metric identify whether having impact on reducing overall complexity. however, careful using these types of metrics sole indicator of projec

css - How to mimic PS Gradient Map effect with SVG feColorMatrix? -

Image
i've been struggling understand svg fecolormatrix equation. i'm more home photoshop svg scripting. in photoshop there " gradient map " adjustment layer applying gradient photo: some how think should achieved svg color matrix, how? here's simple codepen svg filter above , desired photoshop output below. i have made filter: <filter id="colored"> <fecolormatrix type="matrix" in="sourcegraphic" values="0.3334 0 0 0 0 0 0.8196 0 0 0 0 0 0.6471 0 0 0 0 0 1 0 "/> </filter> .. not job: all hints welcome! yeah, think came pretty close combining 2 filters: <filter id="colors"> <fecolormatrix result="a" in="sourcegraphic" type="matrix" values="0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0

java - How to wait in the same thread while file is being written to, to finish, so we can use it -

i have file open , write situation crashes eofexception once in 20-30 times, because file unavailable because other process writing it. can catch exception, somehow wait file write operation synchronously end, can recurse method? file productjson = getfilestreampath("product" + "_" + getid() + ".json"); if (!productjson.exists()) { productjson = getfilestreampath("product" + ".json"); } inputstream jsonstringsfileinputstream; try { jsonstringsfileinputstream = new fileinputstream(productjson); hashmap<string, map> = new jsontoproductparser().convertthistothat(jsonstringsfileinputstream); } catch (filenotfoundexception e) { e.printstacktrace(); } you can check file write access before opening it.this done canwrite() method. oracle docs - file # canwrite also check out solved question. deals synchronized attribute. solved question - synchronized

android - Share Intent: customize layout -

is there way can customize layout of share intent? default listview, if client wants same, show grid view! know how filter required apps using packagemanager. want change listview gridview else same. call below dialog per requirement: private void showalertdialog() { packagemanager pm = getpackagemanager(); alertdialog.builder builder = new alertdialog.builder(this); gridview gridview = new gridview(this); email.putextra(intent.extra_email, new string[] { "velmurugan@androidtoppers.com" }); email.putextra(intent.extra_subject, "hi"); email.putextra(intent.extra_text, "hi,this test"); email.settype("text/plain"); list<resolveinfo> launchables = pm.queryintentactivities(email, 0); collections .sort(launchables, new resolveinfo.displaynamecomparator(pm)); adapter = new appadapter(pm, launchables); gridview.s

How can I find out what different versions of Python installed on OSX? -

it looks there more 1 python installed on mac. modules installed not recognized python interpreter (2.7.6) until add them pythonpath. could show me how can locate pythons installed on mac? thank you as per python location on mac osx , running command user asking question should give locations python installed to. if command returns multiple locations, can follow steps in chosen answer versions.

python - How to find the source data of a series chart in Excel -

i have pretty strange data i'm working with, can seen in image . can't seem find source data numbers these graphs presenting. furthermore if search source points an empty cell each graph. ideally want able retrieve highlighted labels in each case using python, , seems finding source way this, if know of python module can i'd happy use it. otherwise if can me find source data perfecter :p so far i've tried xldr module python manually showing hidden cells, neither work. here's link file: here edit ended converting xlsx pdf using cloudconvert.com api using pdftotext convert data .txt analyses including numbers on edge of chart can searched using algorithm. if hopeless internet wanderer comes upon thread same problem, can pm me more details :p

sql - Query to fetch Structure of a table -

need sql query fetch table structure oracle database. i need following information output: table name field name field format field length mandatory field primary key foreign key if want column information db management system, have try find system tables one. every db management system has it's own system tables it's storing information tables , other things created users. all_tab_columns storing information columns oracle, can information field name , field format , field length , mandatory field . if want know keys have make query all_indexes . please this or this . your query this select column_name, .... all_tab_columns column_name="your_table_name" for getting if column part of index or not have join all_indexes , all_ind_columns .

MySQL SELECT from two tables with COUNT -

i have 2 tables below: table 1 "customer" fields "cust_id", "first_name", "last_name" (10 customers) table 2 "cust_order" fields "order_id", "cust_id", (26 orders) i need display "cust_id" "first_name" "last_name" "order_id" to need count of order_id group cust_id list total number of orders placed each customer. i running below query, however, counting 26 orders , applying 26 orders each of customer. select count(order_id), cus.cust_id, cus.first_name, cus.last_name cust_order, customer cus group cust_id; could please suggest/advice wrong in query? you try one: select count(cus_order.order_id), cus.cust_id, cus.first_name, cus.last_name cust_order cus_order, customer cus cus_order.cust_id = cus.cust_id group cust_id;

python - The images are different even though they are saved to the same quality -

i used function imwrite of opencv python in order convert set of images png jpeg format, without specifying quality (the default value 95), obtained first set of jpeg images . then used same function in order convert same set of images png jpeg format, specifying value 75 quality, obtained second set of jpeg images . finally, tried use same function in order convert first set of jpeg images, specifying value 75 quality, obtained third set of jpeg images . when perform binary comparison between second , third set of jpeg images, images different. why? target quality same (75), source images different. when first compression (quality 95) first set of jpegs not going identical input pngs when uncompressed. jpeg lossy. means input quality 75 compression not same. in first case original png images, , in second case jpeg distorted version of same files. since input images not same, output not same either.

javascript - redirect then jump somewhere inside another page -

i'm trying redirect page header("location: example.com/myotherpage/5#jumphere"); when if condition true jump somewhere inside page using <a name="jumphere"></a> # being url encoded %23 doesn't jump section of page.. is possible prevent # being encoded? or there way this? [update] tried doing $('html, body').animate({ scrolltop: $('#jumphere').offset().top }); instead.. jumps want scrolls again top page.. how prevent going top?

linux - bash: what to do when stdout does not exist -

in simplified scenario, have script looks this: mv test _test sleep 10 echo $1 mv _test test and if execute with: ssh localhost "test.sh foo" the test file have underscore in name long script running, , when script finished, send foo back. script should keep running, if terminate ssh command pressing ctrl+c or if lose connection the server, doesn't (the file not renamed "test"). so, tried following: nohup ssh localhost "test.sh foo" and makes ssh immune ctrl+c flaky connection server still causes trouble. after debugging, turns out script reach end if there no echo in it. , when think it, makes sense - when connection dropped, there no more stdout (ssh socket) echo to, fail, silently. i can, of course, echo file , file, prefer smarter, along lines of test tty && echo $1 (but tty invoked returns false ). suggestions appreciated. the following command want: ssh -t user@host 'nohup ~/test.sh foo > nohup.o

android - Blink Animation Count: how to blink a TextView only three times -

how blink textview 3 three times. i tried code,but doesn't work. guys have textview need blinking. anim.setduration(150); anim.setstartoffset(50); anim.setrepeatmode(animation.reverse); anim.setrepeatcount(3); mainscreenactivity.txtnext.startanimation(anim); blinking=true; here xml used blink view blink.xml <set xmlns:android="http://schemas.android.com/apk/res/android" android:shareinterpolator="false"> <alpha android:fromalpha="1" android:toalpha="0" android:repeatcount="3" android:repeatmode="reverse" android:interpolator="@android:interpolator/linear" android:duration="150" /> </set> you can call animation this: mainscreenactivity.txtnext.startanimation(animationutils.loadanimation(mainscreenactivity, r.anim.blink))

java - Running multiple threads from within a unit test -

below unit test uses scheduledexecutorservice execute scheduled runnable every second : import java.util.concurrent.executorservice; import java.util.concurrent.executors; import java.util.concurrent.scheduledexecutorservice; import java.util.concurrent.timeunit; import org.junit.test; public class concurrentrequestsimulator { private static final int number_requests = 4; @test public void testgettodolist() { try { scheduledexecutorservice scheduler = executors.newscheduledthreadpool(10); scheduler.scheduleatfixedrate(new requestthreadinvoker(), 0, 1, timeunit.seconds); } catch (exception e) { e.printstacktrace(); } } private final class requestthreadinvoker implements runnable { public void run() { executorservice es = executors.newcachedthreadpool(); (int = 1; <= number_requests; i++) { es.execute(new requestthread()); }

cant write file to hard disk in vb.net -

hi checked questions present here did not helped me asked ok here go i try copy file "resources" "c:\test" folder not work me here tried: firstly, put test.txt file in resources copy "c:\test" folder error imports system.io public class form1 private sub button1_click(sender object, e eventargs) handles button1.click io.file.writeallbytes("c:\test", my.resources.test) end sub end class i error cant debug error :- error 1 value of type 'string' cannot converted '1-dimensional array of byte' . so there way can copy .txt file "c:\test" folder if exist can copy replace ? now changed extension of test.txt test.bin it allows me start program in debug , no error code; imports system.io public class form1 private sub button1_click(sender object, e eventargs) handles button1.click io.file.writeallbytes("c:\test", my.resources.test) end sub end class now when c

scala - Why does scalac infer `Foo with Bar` not just `Foo` for match/case return type? -

in model class, have simple getter function so: def geoloc = { geoquant match { case "country" => country.find.byid(geolocid) case "provice" => province.find.byid(geolocid.tolong) case "city" => city.find.byid(geolocid.tolong) case "street" => street.find.byid(geolocid.tolong) } } the idea being geolocation of object – can of either of 4 types. see, function geoloc has return type super class of all: country , province , city & street – extend model class. instead function's return type model geoentity , geoentity trait each of these classes have along model . why happen? can make function return specific types pattern matching? scala infers specific type can. each of 4 instances both model , geoentity , that's inferred type: model geoentity . if want function return less specific type of model (all model geoentity s model s, not models model geoentity s), a

How to show Floating Window for Sign with Google Plus in android -

Image
i have implement signin facebook , google plus in android application.successfully implemented facebook below image. but when implement sign in google plus shows google plus image link please me implement same facebook login sign in google plus in android. user can enter whatever gmail account prefer sign in google. i'm using socialauth library, supports many social networks, including facebook , google+ . note: can provide code examples how login in corresponding social networks using library (facebook, google+) later, if needed. update: 1) client id's stored in oauth_consumer.properties file (put in assets folder) #facebook graph.facebook.com.consumer_key = your_key graph.facebook.com.consumer_secret = your_secret #google plus googleapis.com.consumer_key=your_key.apps.googleusercontent.com googleapis.com.consumer_secret=your_secret 2) google+ requires redirect url. specify redirect url in google console of project , add in socialadapter duri

jquery - Loading bar still running in Firefox if previous page is clicked -

i have progress 'bar' works fine in ie , chrome. when click on link or input button submit, progress 'bar' called via jquery. behaviour in firefox not expecting. this script: $("a, input[type=submit]").click( // http://heartcode.robertpataki.com/canvasloader/ function () { if ($(this).attr('target') == '_blank' || $(this).hasclass("noloadingbar")) { } else { var cl = new canvasloader('canvasloader-container'); cl.setdiameter(65); // default 40 cl.setdensity(50); // default 40 cl.setrange(0.8); // default 1.3 cl.setfps(29); // default 24 cl.show(); // hidden default // bit positioning - not necessary var loaderobj = document.getelementbyid("canvasloader"); loaderobj.style.position = "absolute"; loaderobj.style["top"] = cl.getdiameter() * -0.5 + "px"; loaderobj.style["left"] = cl.getdiameter(