Posts

Showing posts from July, 2013

c# - Find all combinations in a string separated -

i'm trying combinations in string in c# idea in mind: given string foo want list<string> values: f o o fo o foo f oo as can see it's not easy substring chars in string separated spaces. i've tried doing like: list<string> result = new list<string>(); string text = "foo"; (int = 1; < foo.lenght; i++) { //i'm stucked --> think stupid , don't know how procede or not fast enough. i'm stuck. } edit: there correct answers it's clear of them won't since strings working have between 55 , 85 chars each 1 means best function in answers give me between 2^54 , 2^84 possible combinations , bit much. it clear find combinations , afterwards them won't do. i'll have drop it. first things first: if string length n , 2^n strings output. so, if want treat strings of length 70, have problem. you can use counter, enumerating 0 2^n , , treat bitwise mask: if first bit 1, put space between first ,

javascript - Random Service Worker Response Error -

i'm using service worker , cache api cache static resources randomly http request rest api endpoint (which not being cached in sw) fails , message have xhr.statustext text service worker response error , response code 500. i can't tell if error happens urls not being cached or not. there not enough evidence either. happens in chrome (50.0.2661.75 - 64b) , works in firefox 45 i wasn't able reproduce manually happens in selenium tests , appears random. happens on localhost (where sw should work despite plain http) in domain https has self-signed certificate , such sw should not work there ... selenium tests refreshing pages , closing browser window have no idea if matters. any ideas why happening or how more information? update: service worker code: var version = "sdlkhdfsdfu89q3473lja"; var cache_name = "cache" + version; var cache_pattern = /\.(js|html|css|png|gif|woff|ico)\?v=\s+?$/; function fetchedfromnetwork(response, event) {

mysql - left join - trying to find missing records in 2nd table when there is still similar record fitting match condition -

i have 2 tables table 1 message type id table 2 message type id i want find missing records in table 2 when: request logged in table 1 , 2 as: table 1 : message type: request send id: 1 table 2 : message type: request received id: 1 then response send , logged in table 1. table 1 : message type: response send id: 1 table 2 : nothing now join find missing responses in table 2: select t1.id table1 t1 left join table2 t2 on t1.id=t2.id t2.id null , t2.messagetype<>'request received' unfortunately 0 rows. guess because there t2 record matching id filer out messagetype condition. how can solve this? a simple not exists clause should sufficient: select * table1 t1 not exists (select null table2 t2 t2.id = t1.id)

php - How can I access an array/object? -

i have following array , when print_r(array_values($get_user)); , get: array ( [0] => 10499478683521864 [1] => 07/22/1983 [2] => email@saya.com [3] => alan [4] => male [5] => malmsteen [6] => https://www.facebook.com app_scoped_user_id/1049213468352864/ [7] => stdclass object ( [id] => 102173722491792 [name] => jakarta, indonesia ) [8] => id_id [9] => el-nino [10] => alan el-nino malmsteen [11] => 7 [12] => 2015-05-28t04:09:50+0000 [13] => 1 ) i tried access array followed: echo $get_user[0]; but displays me: undefined 0 note: i array facebook sdk 4 , don't know original array strucutre. how can access example value email@saya.com array? to access array or object how use 2 different operators. arrays to access

Transforming a vector in a one of predetermined length in Matlab -

i asking write following piece of matlab code in faster way. code doing following (1) consider natural number n , column vector a of dimension mx1 . (2) if m>n keep first n elements of a (3) otherwise add final zeros a nx1 vector my attempt this: n=4; a=[1 2 3 4 5]' if size(a,1)>n a=a(1:n); %keep first n elements else a=[a; zeros(size(n-size(a,1)),1)]; %add zeros n elements end do know faster ways? you may try following alternative, @ best speed-up barely noticeable (and results vary slightly, depending on m , n ). hard imagine being bottleneck - improving other part of code produce more significant benefit. b = zeros(n,1); b(1:min(n,length(a))) = a(1:min(n,length(a)));

c# - UWP, Content Dialog for Login -

how use content dialog simple login screen. when try use this: contentdialog d = new contentdialog(); d.content = contentgrid; d.primarybuttontext = "aaa"; d.primarybuttonclick += async delegate { }; await dlg.showasync(); on button click can run logic, hide entiredialog. want show processing animation, , show "check" results. possible? yeah, possible. key point here using contentdialogbuttonclickeventargs.getdeferral method contentdialogbuttonclickdeferral before performe async operations , complete deferral when async operation complete. example: contentdialog contentdialog = new contentdialog(); contentdialog.content = "login test"; contentdialog.primarybuttontext = "login"; contentdialog.primarybuttonclick += async (s, args) => { contentdialogbuttonclickdeferral deferral = args.getdeferral(); //do async sign in operation await task.delay(3000); //here wait 3 second

winapi - ExpandEnvironmentStringsForUser variable list -

where can full list of variables, replaced winapi function? msdn contains single example: %userprofile% . is list full , correct? http://www.rapidee.com/en/environment-variables call getenvironmentstrings find out environment process, @ point when make call. need parse double null-terminated string returned find name/value pairs. note there no single definitive list of environment variables. each process maintains own private environment. environment specified when process created. typically inherits environment of parent process. not always. possible, , normal, parent process specify environment child process differs own. note environment can change during lifetime of process. calls made setenvironmentvariable modify environment of calling process. you should able deduce list of variables in link may or may not found in environment. environment contain of variables, or none of them. contain variables not found in list. contain no variables @ all. learn more

How to call a method without knowing it's name in C#? -

this question has answer here: storing method member variable of class in c# 4 answers is possible call method without knowing it's name? imagine being method stored variable so: public static method example; private static void dosomething() { //something } private static void main() { example = dosomething(); } public static void executesomething() { example(); } is there this, or of similar function? i've looked @ delegates , i'm not sure if understand them correctly, or if it's i'm looking for. what describing called delegate . can used in variable/field/property/eventhandler declarations. c# comes handy generics can use describe function expect. examples: action // void function action<t> // void function accepts parameter of type t action<tin1, tin2, ...> //

Turn off Firebase logcat logging -

now have integrated firebase, don't want see logcat spam this d/firebasecrashapiimpl: firebasecrash reporting api initialized i/firebasecrash: firebasecrash reporting initialized com.google.firebase.crash.internal.zzg@e9c7537 d/firebaseapp: initialized class com.google.firebase.crash.firebasecrash. i/fa: app measurement starting up, version: 9080 i/fa: enable debug logging run: adb shell setprop log.tag.fa verbose i tried running adb shell setprop log.tag.fa error , still keeps logging everything. how turn off in sdk (or setprop)? filtering out of logcat not solution looking for. try this: firebasedatabase.getinstance().setloglevel(logger.level.none);

angularjs - How do I access and update ng-model in controller? -

so have angular directive defined: angular.module('photosynthesysapp') .directive('taglist', function(){ return { template: '<div class="tag-form"> <label> labels </label>'+ '<button class="btn-xsmall" ng-click="clicked = !clicked">+</button>' + '<div ng-show="clicked">'+ '<input type="text" ng-model="newtag"> '+ '<button ng-click="vm.addtag()"> add </button>' + '</div>'+ '<ul>'+ '<div ng-repeat="tag in vm.taglistfromdatabase">' + '<li>{{tag}}</li>' + '</div>'+ '</ul>'+ '</div>', controller: taggercontroller, controlleras: "vm", restrict: "e" } }); function taggercontroller() { this.taglistfromdatabase = ["bridges","arches",&

sql server - create sql view from comma separated values -

t-sql question : need build join 2 tables, on 1 of tables have aggregated data (comma separated values). i have table - users have 3 columns: userid, defaultlanguage , otherlanguages. the table looks this: userid | defaultlanguage | otherlanguages --------------------------------------------- 1 | en | null 2 | en | it, fr 3 | fr | en, 4 | en | sp and on. i have table have association between language code (en, fr, ro, it, sp) , language name: langcode | languagename ------------------------- en | english fr | french | italian sp | spanish and on. i want create view this: userid | defaultlanguage | otherlanguages --------------------------------------------- 1 | english | null 2 | english | italian, french 3 | french | english, italian 4 | english | sp

How to make a static array in main method in java? -

i reading arrays in java , made code calculating number of appearances of numbers in array . public class example { static int b[] = new int[13]; // can not static int b[] = new int[a.length] because a[] in not static array static int count = 0; public static void main(string[] args) { int[] = { 2, 3, 4, 3, 3, 5, 4, 10, 9, 1, 9, 11, 15 }; counting(a); printcount(); } private static void printcount() { int k = 0; (int = 0; < b.length; i++) { system.out.print("number" + " " + a[k] + " " + "is found" + " "); // here error in a[k] because not static , eclipse says : cannot resolved variable system.out.println(b[i] + " " + "times"); k++; } system.out.println(); } private static void counting(int[] a) { (int = 0; < a.length; i++) { (int k = 0; k < a.length; k++) {

java - Not able to display entire table in hibernate 5.1.x -

i trying create simple hostel management system using hibernate 5.1 , mysql database. not able display entire table (all rows ) table hostelhome of following piece of code. able display single row entire table not want. public static void display(){ sessionfactory sessionfactory = new configuration().configure().buildsessionfactory(); session session = sessionfactory.opensession(); try{ hostelhome h1 = (hostelhome)session.get(hostelhome.class, new integer(1)); system.out.print("room number: "+h1.getroom_no()+" "); system.out.print("vacancy: "+h1.getvacancy()+" "); session.close(); }catch(exception e){ e.printstacktrace(); } } my hibernate config file <?xml version="1.0"?> <!doctype hibernate-configuration public "-//hibernate/hibernate configuration dtd 3.0//e

Why does SQL Server query works differently on different servers? -

i have query behaving differently when run against 2 databases. i have copied staging database locally , using debug code. here's query : select distinct ........, acs.lastname bs.name branchname, ..... ...... ...... ) left join companytrove bs on ......................... ............................ order acs.lastname,bs.branchname, ..... asc companytrove table has no column called branchname. so, fails on local copy of database. when run same query against actual database runs fine though companytrove table on database not have branchname column (it same table of course). any ideas on missing ? see behaviour changes database engine features in sql server 2005 specifically order clause section. the sql server 2000 behaviour column names in order clause resolved columns listed in select list, regardless if qualified. example, following query executes without error: use pubs select au_fname 'fname', au_lname 'lname' authors

ios - Query objects newer then 24 hours -

so way snapchat has, show in story images/videos newer 24 hours old. how can same using query code: func querystory(){ let query = pfquery(classname: "myclass") query.wherekey("ispending", equalto: false) query.limit = 1000 query.orderbydescending("createdat") query.findobjectsinbackgroundwithblock { (posts: [pfobject]?, error: nserror?) -> void in if (error == nil){ // success fetching objects post in posts! { if let imagefile = post["userfile"] as? pffile { self.userfile.append(post["userfile"] as! pffile) self.objid.append(post.objectid!) self.createdat.append(post.createdat!) } } } else{ print(error) } } } } i tried adding: var date: nsdate = nsd

fonts - Unicode range for Vietnamese -

the google fonts' source sans pro implementation contains vietnamese subsetting, however, contains various missing glyphs, discussed in issue #90 of source sans pro github account, closed maintainers. the problem visible in following snippet. /* fall serif missing glyphs more visible */ body { font-family: "source sans pro", serif; font-size: 25px; } p { margin: .1em 0 1em; } small { margin: 0; font-weight: 400; font-size: 12px; color: #999; border-bottom: 1px solid #ccc; } .w200 { font-weight: 200; } .w300 { font-weight: 300; } .w400 { font-weight: 400; } .w600 { font-weight: 600; } .w700 { font-weight: 700; } .w900 { font-weight: 900; } <link type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/css?family=source+sans+pro:200,300,400,600,700,900&amp;subset=vietnamese" media="all"> <small>source sans pro vietnamese 200</small> <p c

excel - Can a cell value trigger a userform? -

i'm creating small billing system in excel dental office (just mentioning in case has tips/tricks/suggestions on cool ideas not related issue i'm facing). have small template creating invoices in 1 of cells have data validation selecting patient, wondering if in list name selected "new patient" userform can pop input new patient information? eg: put in worksheet module , adjust references appropriate private sub worksheet_change(byval target range) const new_pat string = "new patient" const rng_new_pat string = "b3" dim c range set c = target.cells(1) 'in case multiple cells changed... if c.address = me.range(rng_new_pat).address if c.value = new_pat 'show userform end if end if end sub

jquery - Javascript hide DIV, Button clicked -

hi there stackers, i'm problem. it's javascript (again). i've been creating "alerts" on webpage. contain button, , want close them when click on button. however, doesn't seem work. i've logged clicks in console, , click logged. click happen. the alerts hide after few seconds. when change style "devtools" of chrome make visible again, , click button then, div dissapear. why click not hide div? javascript var messageid = 0; var alerty = function(type, title, content) { messageid++; var html = ' <div class="alert" id="a-' + messageid + '"><div class="topview ' + type + '"></div><div class="title">' + title +'</div> <div class="text">' + content +'</div> <input type="button" id="close-'+ messageid + '" class="inputbutton-empty ' + type + '2 button clo

php - Split Multidimensional Array -

i have array looks : array ( [search_query] => [booklist_id] => 2 [isbn] => array ( [0] => 6748305869 [1] => 5749284905 [2] => 3029586930 )) i need know how can divide array 3 separate arrays. have been trying figure out hours, not having luck. if can point me in right direction appreciated. this array not in correct format!!. array([ search_query ]=>[ booklist_id ]=>2[ isbn ]=>array([ 0 ]=>6748305869[ 1 ]=>5749284905[ 2 ]=>3029586930)) lets start inside, 1st array can be, [isbn ]=>array([ 0 ]=>6748305869[ 1 ]=>5749284905[ 2 ]=>3029586930) 2nd array: [ booklist_id ]=>**array(**[ isbn ]=>array([ 0 ]=>6748305869[ 1 ]=>5749284905[ 2 ]=>3029586930)) and third array whole array

Ruby: incompatible library version -

i learning ruby on rails, i've created first project , got error: /users/anton/.rvm/gems/ruby-2.3.0/gems/debug_inspector-0.0.2/lib/debug_inspector.rb:6:in `require': incompatible library version - /users/anton/.rvm/gems/ruby-2.3.0/gems/debug_inspector-0.0.2/lib/debug_inspector.bundle (fatal) /users/anton/.rvm/gems/ruby-2.3.0/gems/debug_inspector-0.0.2/lib/debug_inspector.rb:6:in `<top (required)>' /users/anton/.rvm/gems/ruby-2.3.0/gems/binding_of_caller-0.7.2/lib/binding_of_caller/mri2.rb:1:in `require' /users/anton/.rvm/gems/ruby-2.3.0/gems/binding_of_caller-0.7.2/lib/binding_of_caller/mri2.rb:1:in `<top (required)>' /users/anton/.rvm/gems/ruby-2.3.0/gems/binding_of_caller-0.7.2/lib/binding_of_caller.rb:9:in `require' /users/anton/.rvm/gems/ruby-2.3.0/gems/binding_of_caller-0.7.2/lib/binding_of_caller.rb:9:in `<top (required)>' /users/anton/.rvm/gems/ruby-2.3.0/gems/web-console-2.3.0/lib/web_console.rb:1:in `require' /users/anton

ios - How to access file included in app bundle in Swift? -

i know there few questions pertaining this, they're in objective-c. how can access .txt file included in app using swift on actual iphone ? want able read , write it. here project files if want take look. i'm happy add details if necessary. simply searching in app bundle resource var filepath = nsbundle.mainbundle().urlforresource("file", withextension: "txt") however can't write because in app resources directory , have create in document directory write it var documentsdirectory: nsurl? var fileurl: nsurl? documentsdirectory = nsfilemanager.defaultmanager().urlsfordirectory(.documentdirectory, indomains: .userdomainmask).last! fileurl = documentsdirectory!.urlbyappendingpathcomponent("file.txt") if (fileurl!.checkresourceisreachableandreturnerror(nil)) { print("file exist") }else{ print("file doesnt exist") nsdata().writetourl(fileurl!,atomically:true) } now can access fileurl

excel - #value error in sum array with substitutes -

my formula have works fine long cells contain value. issue i'm running #value! error if have letter in cell. i'm trying accomplish sum of cells. image posted sample cell. {=sum(value(substitute(substitute(a3:b21,"c",""),"s","")))+0} sample cell =sum(--(0&trim(substitute(substitute($a$3:$b$21),"c",""),"s",""))) -- way of taking value. another possibility wrap formula in iferror function return given value when error occurs. see below formula: =iferror(sum(value(substitute(substitute(a3:b21,"c",""),"s","")))+0,"custom message") remember use cse either formula.

OutputCache exclude Layout in Mvc 4 -

could figure out how exclude layout outputcaching of whole page. working on existing project. in home/index, going use output cache in index.cshtml there layout="~/views/shared/_layout.cshtml". in _layout.cshtml, handles member information. question is, how disable cache of _layout.cshtml. have done lots of research donut, childaction, ..., still confused. please help. many thanks. donut caching , donut hole similar thing, try example http://www.dotnet-tricks.com/tutorial/mvc/odja210113-donut-caching-and-donut-hole-caching-with-asp.net-mvc-4.html

c# - How to use special characters in Wikipedia API? -

if query wikipedia api c# url such as: https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=jsonfm&titles=c%23 the response removes %23 / # , turns c , , displays results c itself. the response has node in json: "normalized": [ { "from": "c#", "to": "c" } how stop normalization of special characters mediawiki api? you can't stop normalisation of search queries wikipedia prohibits characters article titles. from wikipedia docs : due clashes wiki markup , html syntax, following characters not allowed part of page titles (nor supported displaytitle): # < > [ ] | { }

php - Using include() instead of get_footer() -

simple question. in wordpress template, there reason shouldn't use include() , use get_footer() ? let's want have sub folder in template directory components included. seems work okay maybe i'm missing something. you shouldn't use include() in wordpress theme @ all. the reason wordpress' architecture pluggable - throughout core, plugins , themes, components can interact other components through actions , filters . while get_footer() might seem simple, functions runs allow parts of theme overridden. in case, locate_template() allows child theme ship footer.php file in order override 1 set main theme. in addition, get_footer() allows flexibility of including multiple footer files in wordpress theme can call different footer on particular template if need (by way of eg. get_footer('alternative') call footer-alternative.php - overridable child theme). it's worth noting should ensure footer template has call wp_footer() in

python - computing cost of np.random.uniform vs np.random.beta -

i have algorithm uses np.random.uniform switch np.random.beta and/or np.random.gamma improve efficiency of approximation. since algorithm quite time consuming (~8hours) , memory intensive (5 gb per thread) wanted check if there information on how cost me before tried run. since called inside loop, should assume not going change memory requirements? what difference in run time? just test using ipython: in [1]: import numpy np in [2]: %timeit np.random.random(1000) 100000 loops, best of 3: 9.25 µs per loop in [3]: %timeit np.random.beta(0.5, 0.5, 1000) 10000 loops, best of 3: 45.3 µs per loop this imply factor of 5, appears depend on parameters of beta. nevertheless, before drawing conclusions, should sure random number generation time-limiting factor algorithm. run profiler find out real bottlenecks are.

javascript - Programmatically keypress on a focused drop-down element without Jquery -

i'm trying press enter (programmatically) on drop down element. cannot use jquery. drop down in focus, want click enter open it. ideas how can achieved? here's html: <select class="test"> <option value="1">item1</option> <option value="2">item2</option> <option value="3">item3</option> <option value="4">item4</option> <option value="5">item5</option> <option value="6">item6</option> </select> and js got element focused: document.getelementsbyclassname('test')[0].focus(); var element = document.getelementsbyclassname('test'); element.onclick.apply(element);

android - twitter4J i dont know if i need acount -

i want implement twitter4j on app.. i've seen in tutorials need have account on twitter, see in tutorial send tweet , see profile. what want find tweets hashtag , list them. need acount?? sorry english yes. signup account @ twitter developers . then, create application. bunch of information including 4 unique fields: consumer key consumer secret access token access token secret you need unique information download tweets. there bunch of different ways it, depending on operating system, number of tweets needed , want them (i.e. sentiment mining, count of retweets etc). google friend here , can give hundreds of examples.

java - How to disable ant to output warning info in iterm2? -

i use ant build , deploy java web project in iterm2, , have problem. when compile project, there many full screen warnings can not read errors reported ant. here ant javac task def: <echo message="begin compile..." /> <javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" nowarn="on" source="1.7" target="1.7" deprecation="true" debug="true" encoding="utf-8" classpathref="project.classpath"> <compilerarg line="-xlint:unchecked" /> </javac> <copy todir="${build.dir}"> <fileset dir="${src.dir}"> <include name="**/*.xml" /> <include name="**/*.properties" /> <include name="**/*.sql" /> </fileset> </copy> <echo message="end compile..." />

ios - Terminating with uncaught exception of type NSException on my NSArray -

i've been trying add object in array. here's i've done far: nsmutablearray *mutablemenuarray = [nsmutablearray arraywitharray:dictionary[mjfeeddatakey]]; [mutablemenuarray removeobjectatindex:1]; [mutablemenuarray removeobjectatindex:1]; nsmutablearray *menuarray = [[nsmutablearray alloc] init]; [menuarray addobjectsfromarray:mutablemenuarray]; [menuarray addobject:@"check"]; mjmenuentities *menus = [mjmenuentities sharedinstance]; [menus setwitharray:menuarray]; self.modelarray = [nsmutablearray arraywitharray:menus.menuitems]; but once i've set menus menuarray comes error: "terminating uncaught exception of type nsexception on nsarray". but if menus set mutablemenuarray there no error. nsarray immutable. seems modify first parameter of method:- setwitharray. can paste details of method:- setwitharray.

reactjs - How to autofocus react textarea? -

i try autofocus or focus(), seems not work. <textarea autofocus /> or <textarea ref="textarea" /> componentdidmount() { finddomnode(this.refs.textarea).focus(); } edit autofocus seems work in chrome. both autofocus foucs() not work in ios. calling focus() in componentdidmount seems work in desktop chrome , firefox. demo . it seems mobile safari intentionally suppresses auto-focussing of elements.

C++ Find object member value in Vector -

i have struct of person contains 2 values - first initial , first name. there vector of these person structs. i need search through vector find first person matching first initial , retrieve first name struct. my research highlights need use overloaded operator person struct require guidance. note: can use vector , find() algorithm. can't use boost. #include <stdio.h> #include <iostream> #include <stdexcept> #include <vector> #include <algorithm> #include <string> using namespace std; struct person { char firstinitial; string firstname; person(const char fi, const string fn) { firstinitial = fi; firstname = fn; }; char getinitial() { return firstinitial; }; string getname() { return firstname; }; bool operator==(const person& l, const person& r) const { return l.firstinitial == r.firstinitial;

qbxml - Adding values to custom (DataExt) fields when adding line items to existing quickbooks Estimates -

i'm trying find best way add value dataext field when adding line item existing quickbooks transaction (in particular case estimate). can add value dataext field when adding line items new estimate since iestimatelineadd object includes idatalistext. however, iestimatelinemod not appear include idataextlist. there not appear support defmacro/usemacro either. avoid having go , dig out line items (using combination of data values) response data, txnlineids each 1 , use dataexmod add custom data field after fact. however, iestimatelinemod not appear include idataextlist. correct. there not appear support defmacro/usemacro either. also correct. i avoid having go , dig out line items (using combination of data values) response data, txnlineids each 1 , use dataexmod add custom data field after fact. that need do.

amazon vpc - How to config the api gateway for the service deployed in private subnet? -

i deployed web service in private subnet without elb in public subnet. now want expose public. can use api gateway http proxy to make public? anyone knows how that? the service has public api gateway able connect it. can use ssl client certs restrict access api gateway. otherwise, api gateway not solution issue.

java - How can I make the content of a Label change after one second using JavaFX? -

i'm trying make splash screen, need words stays appearing. used o thread, don't know how can make loop label appear , after 1 second changes. package br.com.codeking.zarsystem.splash; import javafx.concurrent.task; import javafx.concurrent.workerstateevent; import javafx.event.eventhandler; import javafx.fxml.fxml; import javafx.scene.control.label; public class controllersplash { @fxml label lblloading; @fxml private void initialize() { system.out.println("app start"); lblloading.setstyle("-fx-font-size: 16px;" + "-fx-font-family: ubuntu;" + " -fx-text-fill: white;"); here i've tried repeat step 10 times, don't works while (i <= 10) { task<void> sleeper = new task<void>() { @override protected void call() throws exception { try { thread.sleep(1500

java - Fibonacci sequence long[] array throws negative numbers after index 92 -

i'm testing code insert fibonacci sequence in long[] array: public class test { public static void fibonacci(int n){ long[] array = new long[n]; array[0]=1; (int = 1; < n; i++) { if (i==1) { array[i]=i; } else { array[i] = array[i-2] + array[i-1]; } } system.out.println(array[n-3]+" "+array[n-2]); // verify sum system.out.println(array[n-1]); } public static void main(string[] args) { scanner scan = new scanner(system.in); system.out.print("insert fibonacci sequence index: "); int n = scan.nextint(); fibonacci(n); } } however, after position 92, starts throwing wrong or negative numbers. i'm using fibonacci calculator verify numbers , until 92 it's correct. i've seen questions here problem , answers integer overflow, , should use long, using. is 93th number

c - Is closing a pipe necessary when followed by execlp()? -

before stating question, have read several related questions on stack overflow, such pipe & dup functions in unix , , several others,but didn't clarify confusion. first, code, example code 'beginning linux programming', 4th edition, chapter 13: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main() { int data_processed; int file_pipes[2]; const char some_data[] = "123"; pid_t fork_result; if (pipe(file_pipes) == 0) { fork_result = fork(); if (fork_result == (pid_t)-1) { fprintf(stderr, "fork failure"); exit(exit_failure); } if (fork_result == (pid_t)0) // child process { close(0); dup(file_pipes[0]); close(file_pipes[0]); // line close(file_pipes[1]); // line b execlp("od", "od", "-c", (char *)0); exit(exit_failure); } else // parent

python - GAE NDB Datastore new feature: Access Datastore entities from other GAE app -

reading new documentation of gae ndb datastore: https://cloud.google.com/appengine/docs/python/ndb/modelclass#class_methods get_by_id(id, parent=none, app=none, namespace=none, **ctx_options) returns entity id. shorthand key(cls, id).get() . arguments id string or integer key id. parent parent key of model get. app (keyword arg) id of app. if not specified, gets data current app. namespace (keyword arg) namespace. if not specified, gets data default namespace. **ctx_options context options returns model instance or none if not found. i discover new app parameter. needed since long time ago!!!!! tried access datastore of app "xxxxxdev" app "xxxxxglobal" error: file "/applications/googleappenginelauncher.app/contents/resources/googleappengine-default.bundle/contents/resources/google_appengine/google/appengine/datastore/datastore_rpc.py", line 1373, in check_rpc_success raise _todatastoreerror(er

indexing - SQL Server - When to use Clustered vs non-Clustered Index? -

i know primary differences between clustered , non clustered indexes , have understanding of how work. understand how clustered , non-clustered indexes improve read performance. 1 thing not sure reasons choose 1 on other. for example: if table not have clustered index, should 1 create non-clustered index , whats benefit of doing i want put in word of warning: please very carefully pick clustered index! every "regular" data table ought have clustered index, since having clustered index indeed speed lot of operations - yes, speed up , inserts , deletes! if pick good clustered index. it's most replicated data structure in sql server database. clustering key part of each , every non-clustered index on table, too. you should use extreme care when picking clustering key - should be: narrow (4 bytes ideal) unique (it's "row pointer" after all. if don't make unique sql server in background, costing couple of bytes each entry times num

c++ - What is Security Development Lifecycle Checks option in Visual Studio? -

i using visual studio 2013 preview, although i'm sure i've seen in earlier versions. when creating new project using wizard, select c++, win32 console application, , there option enable security development lifecycle checks on project. explain option code/project? the /sdl switch described here . turns warnings errors, not affect code. furthermore, applies /gs check more aggresively. don't expect it. microsoft sdl workaround 1980's style c programming. use 20th century c++, don't need it. e.g. operator+(std::string, std::string) both safe , portable. microsoft's sdl solution here in contrast not portable, nor safe - idea behind /gs find errors c string handling @ runtime , abort program, limiting consequences not making safe.

jquery - What is an alternative way to open a modal window instead of window.open? -

my rails 3.2 application needs authorized against each user's account on 3rd party website. using window.open this, different settings available in internet explorer, hit , miss , causing user frustration. i googled jquery modal window , came embarrassment of riches. yet haven't found way quite want. here requirements: open modal child window , give focus. prevent user returning application until child window closed. the closest thing i've found zebra dialog , appears have different types of messages can show. need set href of window user can authenticate , authorize application 3rd party app user account. any or pointers appreciated. you use window.open create modal window, can pretty messy. better off using modal plugin requirements have. i suggest using bootstrap, use modals. easy implement , style. http://getbootstrap.com/2.3.2/javascript.html#modals to open url in modal, use iframe in modal open url need, this. http://bootply.com/61

Will throwing an exception for bad pointer access ever be standard behavior in C++? -

i did quick search on google , wasn't able find relevant exact topic. as c++ continues move toward being more modern language, including lambdas, range based loops, etc, seems question may come up, if hasn't already. i don't see how thing, , provide same benefits have been proven useful in c++/cli, c#, java, etc. , if didn't want behavior, made optional, , turned off compiler setting, same way 1 disable standard exceptions or rtti. also, has been suggested, discouraged 1 create signal handler sigsegv , throw exception there, simulate suggested behavior. now, although bit of hack, , not guaranteed work on platforms, how hard implement null reference exceptions in c++ if same basic behavior can simulated(non-standardly) around 10 lines of code? so, there reason technical, or otherwise, throwing exception bad pointer access couldn't become part of standard in future? edit: answer question, 1 needs able see future accuracy. pretty easy short periods

ANDROID -PHP-JSON not getting data from server -

hi new android json...here m sending id php server getting data database not getting value.plz here when click button go next activity , taking id next activity... main activity... package com.example.mydata; import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.textview; public class mainactivity extends activity implements onclicklistener { button tab1,tab2,tab3,tab4; private static final string tag_bid = "id"; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); tab1=(button)findviewbyid(r.id.tab1); tab1.setonclicklistener(this); tab2=(button)findviewbyid(r.id.tab2); tab2.setonclicklistener(this); tab3=(button)findviewbyid(r.id.