Posts

Showing posts from January, 2015

html - Menu pushing content down -

this website i'm doing: @ first, looks alright when resize window, menu pushes banner down. thoughts on ? thank you this style killing logo float, making things sad: @media screen , (max-width: 766px) .logo { float: none; } if omit style, should solve problem.

android - Activity is destroyed after coming back from camera app -

i have activity dialog. in dialog when click on imageview default camera app launches , when create photo , click tick icon (at least it's tick icon on phone) previous activity recreated, destroyed , recreated again. happens 1 in 10 times. this happens 1. intent opens camera 2. onpause() 3. onsaveinstancestate runs 4. onstop() 5. ondestroy() 6. camera app opens, picture taken , click tick 7. onstart﹕() 8. onrestoreinstancestate runs 9. onresume() 10. onpause() 11. onsaveinstancestate 12. onstop() 13. ondestroy() 14. onstart﹕() 15. onrestoreinstancestate so if save data need in onsaveinstancestate (step 3) , retrieved in onrestoreinstancestate (step 8), it's lost when activity destroyed (i use flag decide if want save data , flag becomes null when activity recreated second time). save in sharedpreferences, still, undesired function want correct. if matters, here's code: intent btn_camera.setonclicklistener(new view.onclicklistener() { @override public ...

javascript - Adding an SVG element to Highcharts canvas -

i add, example, rect highcharts canvas. see there's svg element inside highcharts div, doesn't have id don't know how reference. in post explains how add rectangles svg canvas dynamically using javascript, add these highcharts canvas, ideas?

amazon ec2 - Flask- Cannot read or write to file -

i using aws ec2 host flask application , trying read , write text file when user submits form using open() function. when form submitted getting error: internal server error server encountered internal error , unable complete request. either server overloaded or there error in application. i not sure why error happening. the code is: @app.route("/submit", methods=["post"]) def submit(): file = open("settingsfile.txt", "w") file.close()

dart - AngularDart View is not properly routing -

i'm new dart , i'm having issues views/router. the router in lib/routing/booking_service_router.dart: void bookingservicerouteinitializer(router router, routeviewfactory views) { views.configure({ 'reservations': ngroute( path: '/reservations', view: 'view/homereservation.html') }); } the main module bookingservice.dart: class bookingservicemodule extends module { bookingservicemodule() { bind(reservationhome); bind(tabmenu); bind(routeinitializerfn, tovalue: bookingservicerouteinitializer); bind(ngroutingusepushstate, tovalue: new ngroutingusepushstate.value(false)); } } void main() { logger.root.level = level.finest; logger.root.onrecord.listen((logrecord r) { print(r.message); }); applicationfactory().addmodule(new bookingservicemodule()).run(); } the main html bookingservice.html: <html> <head> <meta charset="utf-8"> <meta name=...

java - How to create public array accessible by all methods, but have user input determine the size of it? -

i have multiple arrays sizes need determined user input. these arrays should accessible in main method steptwo() method. however, stuck. user input doesn't come until main method, if declare arrays in main method, can't access arrays in steptwo() method. prefer not pass arrays parameters steptwo() tried before came multiple errors. suggestions? see below complete code: public class assignmentiii { public static int numprocesses; // represents number of processes public static int numresources; // represents number of different types of resources public static int[] available = new int[numresources]; // create emptry matrix available processes public static int[][] allocation = new int[numprocesses][numresources]; // create empty allocation matrix nxm public static int[][] request = new int[numprocesses][numresources]; // create empty request matrix nxm public static int[] work = new int[numresources]; // create empty work matrix ...

winforms - AutoScroll property in C# Windows Form only allowing Vertical Scroll Bar to work -

i trying enable scroll bars windows form application. when set autoscroll property true, vertical scroll bar appearing , working. horizontal scroll bar not showing @ all. have panels within form, i'm not sure if/how causing problem. how can make both scroll bars work? if controls inside panel, , panel has dock style set, can affect behavior of autoscroll functionality. to have autoscroll work both vertical , horizontal scrollbars, have set panel's dock property dockstyle.none.

Ruby on Rails - nested associations - creating new records -

i'm learning rails (4.2 installed) , working on social network simulation application. have setup 1 many relation between users , posts , i'm trying add comments posts. after multiple tries , following documentation on rubyonrails.org ended following setup: user model has_many :posts, dependent: :destroy has_many :comments, through: :posts post model belongs_to :user has_many :comments comment model belongs_to :user the comment initiated post show page, post controller has: def show @comment = comment.new end now question is: in comments controller , correct way create new record. tried below , many others, without success. def create @comment = current_user.posts.comment.new(comment_params) @comment.save redirect_to users_path end (current_user devise) also, afterwards, how can select post corresponding comment? thank you you'll want create relation on post , letting each comment know "which...

java - Hibernate select lowest value greater than -

i trying hibernate return object has lowest id number greater value. the code have returning integer though, instead of object. code criteria criteria = session.createcriteria(story.class); criterion storyid = restrictions.ge("id", 2); projectionlist projlist = projections.projectionlist(); projlist.add(projections.min("id")); criteria.add(storyid); criteria.setprojection(projlist); list<?> storyresult = criteria.list(); session.close(); story story = (story) storyresult.get(0); right returning "3" integer. 3 next available id, why hibernate giving me integer instead of object? thanks by adding projection, asking hibernate change query select * table select min(id) table query. that's 1 of features of projection. to achieve want achieve, need use projection id , use query retrieve object. criteria idquery = session.createcriteria(story.class); idquery.add(restrictions.ge("id", 2)); idquery.setpro...

javascript - Preload images without names of images -

i'm looking script or way preload images before page become full load. found script have write name , root of images, need load like: load img of page, after show page, during loading of images show preload image ( loading or ). it's possible? i have alrady tried script on web, found script have put name of images in array... don't need it! i want javascript load before tag ( without set name of images ) of page , show page! jquery has plugin called imageready. https://github.com/weblinc/jquery-imageready ive used many times, should work expect

php - CodeIgniter insert two rows instead one -

i have issue codeigniter. reason insert 2 rows in database instead one. below code model : /** * add new fuel */ public function addnewfuel($id = null, $data) { if ($id) { var_dump('test'); $data = array( 'price' => '333' , 'fuel' => 'dizelka' , 'petrol_id' => '66' ); echo '<pre>'; print_r($data); echo '</pre>'; $this->db->insert('prices', $data); echo $this->db->last_query(); $this->db->insert('prices_archive',$data); return; } } and here output: string(4) "test" array ( [price] => 333 [fuel] => dizelka [petrol_id] => 66 ) edit: this code controller calls model's function: function addnewfuel() { if ($this->session->userdata('logged_in')) { $this->load->...

How to call a PHP function with javascript for star-rating bootstrap -

Image
i strugling on couple of day's getting script run. maybe problem simple solve, please me. idea user can rate song artist using bootstrap en star-rating plugin http://plugins.krajee.com . javascript requested use: <script type="text/javascript"> jquery(document).ready(function() { $('#input-id').on('rating.change', function(event, value, caption) { console.log(value); console.log(caption); }); ();}); </script> the html input on page is: <input id="input-id" type="number" class="rating" min=1 max=5 step=1 data-size="xs" data-rtl="false"> php function rating database $rate = $oartists->savesongrating($_post["song_id"],$_post["rate"],$userid); my question: how can combine javascript php function? thanks. use ajax call: $.ajax({ url: '/myscript.php', data: { song...

excel - How to make selection move through variable data in VBA -

i trying continue process until end of cells, selection needs change in set order. here's code: ' c_p macro ' copies worksheet & pastes in new sheet ' keyboard shortcut: ctrl+shift+l dim rng1 range dim string dim irow integer windows("audubon-crest-rent-roll-201502-1.xlsx").activate set rng1 = range("a:a") activecell = range("a228") windows("audubon-crest-rent-roll-201502-1.xlsx").activate range("a228:a239").select selection.copy windows("audubon crest rent roll 20150219-altered.xlsm").activate range("b17").select selection.pastespecial paste:=xlpasteall, operation:=xlnone, skipblanks:= _ false, transpose:=true windows("audubon-crest-rent-roll-201502-1.xlsx").activate application.cutcopymode = false range("a228:a239").offset(13, 0).select selection.copy windows("audubon crest rent roll 20150219-a...

css - Jquery fade in images one by one, in reverse -

i using below code fade in each image 1 1. how in revers images load in opposite order? img {display:none;} $('img').each(function(i) { $(this).delay(i * 100).fadein(); }); you use normal loop , decrement for(var count = $('img').length-1; count >= 0; count--) { $('img:eq('+count+')').fadein(); } hope helps.

php - Passbook - Hardcoding locations in JSON works but not passing variable -

Image
i using pre-built structure found here create apple passbook passes. i'm using starbucks example different parameters. background: apple allows 10 locations saved pass. purpose of saving locations triggers phone notification when near. the flow of system is: user inputs home address google retrieves exact coordinates lat/lng lat , lng set form's hidden inputs , posted pass creation php. server queries 10 nearest locations , adds positions pass json. pass creates , downloads problem it's possible it's problem php or passbook. posted variables query in mysql fine. in testing json, json matches target pattern given in documentation exampled below. 10 nearest stores indeed insert in correct syntax. however, passes had locations hardcoded in json 'locations' => array( array( 'longitude' => 123456, 'latitude' => 123456, 'relevanttext' => 'you near st...

php - Check if cookie is set -

to let users logged in, have : the user logs in if ok, create $_session , set cookie : setcookie ('test', sha1($_post['username']), time()+604800); then insert in cookie table : hashed username, ip address , browser version. but, in order check if user logged in (and keep him logged), have query on each page : i check if $_session['id'] exists (it variable user logged in) if exists, nothing happens. if doesn't, check if $_cookie['cookie'] exists if does, user's ip address , browser version with select query, check if actual ip address , browser same in table. if same, reset $_session (so logged in) now, here's code : form : <form method="post" action="http://localhost/test/login.php"> <label for="user">username :</label> <input type="text" name="username" id="user" maxlength="20" placeholder="u...

c# - How to change DevExpress GridControl default theme in WPF control which is used in MFC -

i using wpf control (which using devexpress gridcontrol) inside mfc application. need know way change it's default blue theme. i tried: devexpress.xpf.core.thememanager.applicationthemename = "office2007black"; and works fine, lon using control within wpf application. when put control inside mfc application, stops working. got working magic line: thememanager.setthemename(this, “office2007blue”);

java - How to read my words.txt into a array? -

this question has answer here: java.io.filenotfoundexception: system cannot find file specified 7 answers import java.util.*; import java.io.*; public class hangman { public static void main (string [] args) throws ioexception{ // importing file wordbank // file wordbank = new file("words.txt"); scanner scan = new scanner( new file ("words.txt")); string [] wordbank = new string [20]; while ( scan.hasnext() ){ for(int x = 0; x < 10; x++){ string line = scan.nextline(); wordbank[x] = line; } } system.out.println( wordbank[1]); } } my error below. im not sure means. exception in thread "main" java.io.filenotfoundexception: words.txt (the system cannot find file specified) @ java.io.fileinputstream.open(native ...

php - Best way to parse this string and create an array from it -

i have follow string: {item1:test},{item2:hi},{another:please work} what want turn array looks this: [item1] => test [item2] => hi [another] => please work here code using (which works): $vf = '{item1:test},{item2:hi},{another:please work}'; $vf = ltrim($vf, '{'); $vf = rtrim($vf, '}'); $vf = explode('},{', $vf); foreach ($vf $vk => $vv) { $ve = explode(':', $vv); $vx[$ve[0]] = $ve[1]; } my concern is; if value has colon in it? example, lets value item1 you:break . colon going make me lose break entirely. better way of coding in case value has colon in it? why not set limit on explode function. this: $ve = explode(':', $vv, 2); this way string split @ first occurrence of colon.

How do I sign the final .apk file with Android++? -

i'm using android++ develop android apps. does know how sign final release version apk? tried find options sign apk on project settings, there no such options available; not familiar eclipse. at least vs 2013 , android++ 0.4.0 1 can following: - go property manager , add new property sheet required configuration. - in new property sheet go android apk signing tool - jarsigner , specify keystore, keystore password,...

navigation - WordPress Page Walker class descendants of parent with thumbnail and custom classes -

please, help! i'm @ wits end , have finish tomorrow, really appreciate adjusting page walker class. (please!) the ultimate goal display list in format: animals //not shown + cats - dogs - bulldogs - boxers - poodles + horses + sheep depth requirement(s) on cats, dogs, horses, sheep pages, (animals) bulldogs, boxers, poodles shouldn't display. however, on dogs page, bulldogs, boxers, poodles in addition cats, horses , sheep page should display. markup requirements i need following markup in final output: <ul class="list"> <li class="list__items"><a href="#link">cats</li> <li class="list__items"><a href="#link">dogs</a> <ul class="sub-tier__list"> <li class="sub-tier__group"><a href="#link">bulldogs</a></li> <li class="sub-tier__gro...

Length of a right Triangle (Java Eclipse): User input chart -

import java.util.scanner; public class triangledriver { public static void main(string[] args) { system.out.println("please enter value of n: "); scanner scan = new scanner(system.in); int num = scan.nextint(); (int = 1; <= num; i++) { system.out.printf("%d\t", i); } system.out.println(""); system.out.println("---- ----"); (int = 0; < num; i++) { system.out.print((i + 1) + " "); (int j = 1; j <= num; j++) { system.out.printf("%7.2f", math.sqrt(i * + j * j)); } system.out.println(); } } } this useful others new coding. need on though. when input number, 8, -it not spaced properly -the first actual row of data should not include 1.00, 2.00, 3.00 -personal preference: include ---- on top after numbers , | on side j numbers what guys think? this close how code should look public class triangledriver ...

Iterating over a list of lists and ignoring strings if they appear inside a larger string - Python -

i want iterate on list of lists, , check if of strings in second position in of other strings in second position. if are, skipped over. want return strings first position larger string. needs work strings in list. this description horrific, here example. record = [['436', 'university'], ['123', 'university hospital'], ['956', 'school']] the output want here is: '123 956' this because "university" in "university hospital", not need number associated it. i have had no luck coming solution, , best do: final_string = '' inst in record: if inst[1] not in record: final_string = final_string + inst[0] + ' ' this returns strings in first position, i.e. '436 123 956 ' this work. for i, inst in enumerate(record): append = true rec in (x[1] x in record[i + 1:]): if inst[1] in rec: append = false break if appen...

Retrieve specific version of document using Alfresco REST API -

i'm using alfresco community 5.0b, when try list of versions, using get /alfresco/service/api/node/{store_type}/{store_id}/{id}/versions , http 404 error. according https://wiki.alfresco.com/wiki/repository_restful_api_reference#retrieve_all_versions_.28getallversions.29 , recommended way list of versions. the content , metadata queries both work fine when try get /alfresco/service/api/node/{store_type}/{store_id}/{id}/content , get /alfresco/service/api/node/{store_type}/{store_id}/{id}/metadata . missing? give try this, /alfresco/service/api/version?noderef={noderef}

Are Java Socket shutdownOutput and shutdownInput responsible for "Duplicate ACK #: 1" -

at first, sorry long explanation of below issue. i have simple tcp client. here code snippet: ...... ouputstream = socket.getoutputstream(); . ..... bufferedoutputstream.flush(); socket.shutdownoutput(); ...... inputstream = socket.getinputstream(); ..... while(r=bufferedreader.read()!-1){ reading response } socket.shutdowninput(); ....... socket.close(); my tcp client works multiple tcp servers except 1 particular tcp server. tcp client not response server in morning , afternoon (server pick hour time) response without problem in evening, night , morning. therefore, have used wireshark inspect packet of network during server pick hour time. the inspection snippet of wireshark in pick hour: 4 0.072547 ccc.ccc.ccc.ccc sss.sss.sss.sss tcp 66 clientport > serverport [fin, ack] seq=2008 ack=1 win=14720 len=0 tsval=99...

sql - delete duplicate rows but keep preferred row -

i have simple database table create table demo ( id integer primary key, fv integer, sv text, rel_id integer, foreign key (rel_id) references demo(id)); and want delete duplicate rows grouped fv , sv . fairly popular question great answers. need twist on scenario. in cases rel_id null want keep row. in other case goes. so using following values insert demo (id,fv,sv,rel_id) values (1,1,'somestring',null), (2,2,'somemorestring',1), (3,1,'anotherstring',null), (4,2,'somemorestring',3), (5,1,'somestring',3) either id | fv | sv | rel_id ---+----+------------------+------- 1 | 1 | 'somestring' | null 2 | 2 | 'somemorestring' | 1 3 | 1 | 'anotherstring' | null or id | fv | sv | rel_id ---+----+------------------+------- 1 | 1 | 'somestring' | null 3 | 1 | 'anotherstring' | null 4 | 2 | ...

random - Enciphering and Deciphering by Shuffling in Python -

i writing program enciphers (and decipher) given string. the encipher function takes 2 arguments: string , seed value. here have far: def random_encipher(string,seed): random.seed(seed) alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] #shuffle alphabet random.shuffle(alphabet) #assign index each letter in alphabet letter in alphabet: letter = ord(letter)-97 to sum up, i'm shuffling alphabet , assigning each letter number value ("a" = 0, "b" = 1, . . .) here's need with: i need string[0] printed alphabet[0] (which shuffled alphabet, therefore current seed value, alphabet[0] = "e"). ...

templates - C++ Custom List Iterator Errors -

i have started writing own library common data structures, educational purposes (ie: personal practice). however, encountered few problems cannot seem resolve myself on singly linked list. not c++ expert , code may have problems, please don't harsh on me :) i have tried implement list_node class declares , defines node list, list_iterator class acts forward iterator singly linked list requires, list class supposed give make use of mentioned classes , provide functionality list. i attach code , errors under visual studio. list_node.h /** * list_node.h * * @author raul butuc. * @version 1.0.0 16/03/2015 */ #pragma once #include "list.h" #include "list_iterator.h" namespace my_library { template <class _tp> class list_node { friend class list<_tp>; friend class list_iterator<_tp>; private: _tp m_node; list_node<_tp> *m_pnext; list_node(const _tp&, list_node<_tp>*); ...

performance - Why get data from references slower then calculate in c#? -

i test 2 type data behind loop of 65,000,000 . different 0.5-0.6 seconds. test 1: ushort e = myfunction(a, b, c); ushort d = (ushort)(e + (f << 13)); private static ushort myfunction(ushort a, int b, int c) { if (a < (ushort)b) return 0; if (a > (ushort)c) return (ushort)(c - b); return (ushort)(a - b); test 2: ushort d = arr2dimension[i, j].data; data public data member of class type of arr2dimension . i checked time each 1 of test (separately) 3 times, first test faster around 0.5-0.6 seconds. why that? (why data reference slower?) hard give accurate answer when don't post code can try run ourselves. yes, there pattern code this, discovered accessing memory 1 of slowest things processor can do. it problem related distance , further electronic circuit physically removed, slower signal must ensure doesn't corrupted. basic principle of "there no free lunch" in electronic engineering. , why new processors us...

video - ffmpeg decode example using vda acceleration? -

i'm testing vda hw accelerated decoder of ffmpeg, have no luck far. the command line use this: ./ffmpeg -hwaccel vda -i ~/downloads/big_buck_bunny_720p_surround.avi -c:v rawvideo -pix_fmt yuv420p out.yuv (the input video can downloaded here: http://mirrorblender.top-ix.org/peach/bigbuckbunny_movies/big_buck_bunny_720p_surround.avi ) but uses sw decoder, instead of requested vda hw decoder. i debugged ffmpeg.c, , found out in function get_format: if (!(desc->flags & av_pix_fmt_flag_hwaccel)) break; the desc->flag isn't set av_pix_fmt_flag_hwaccel, skips hw acceleration initialization. the reason because pix_fmt set av_pix_fmt_none reason, instead of yuv420p specified command. i changed command this: ./ffmpeg -hwaccel vda -i ~/downloads/big_buck_bunny_720p_surround.avi -c:v rawvideo -pix_fmt vda_vld out.yuv but got was: impossible convert between formats supported filter 'format' , filter 'auto-inserted scaler 0' error o...

javascript - Append image to td element with no id or value -

i have array of image elements, use function randomize array , append them html table in randomized order. trying avoid giving each td element it's own id because there quite few...i wondering if it's possible append image td element not having id. the html table has 12 rows this: <table class="piecetray"> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> etc... js function randomizepieces(myarray) { (var = myarray.length - 1; > 0; i--) { var j = math.floor(math.random() * (i + 1)); var temp = myarray[i]; myarray[i] = myarray[j]; myarray[j] = temp; } return array; } assuming table built , want iterate through each td , update it's background plain js. // lets start getting `...

python - having trouble adding multiple prices to a receipt -

im having trouble making receipt. supposed able take in multiple prices(as little 1 , many infinite(if u wanted go high)) , able subtotal of them, put tax on , total. cant figure out how add them multiple numbers up. keep getting (i had remove (<,>) , put these (",") show giving me. when finished enter -1 enter price of item: 5.22 enter price of item: 6.35 enter price of item: -1 subtotal is: "function subtotal @ 0x0314c9c0" tax is: "function tax @ 0x0314c978" total is: "function total @ 0x0314ca08" have bought 2 items thank shopping @ qmart and coding have far print("qmart receipt".center(78, "-")) print("when finished enter -1") def price(subtotal, items, price): counter = 0 while counter <= items: subtotal = (items + items) def subtotal(): subtotal = sum(input) def tax(): tax = subtotal * .065 def total(): total = subtotal + tax counter = 0 price = input(...

java - Android WebSocket Services making multiple connections -

i have created web socket service. keeping making multiple connection i want app make 1 connection, unless network connection drops make another. right now, makes 1 connection, if press home button on phone. , go on app, make connection. thanks guys . oncreate... of mainactivity intent startserviceintent = new intent(this, websocketservices.class); startservice(startserviceintent); manifest <!-- websocket --> <receiver android:name="com.example.basicplayerapp.core.networkreceiver"> <intent-filter > <action android:name="android.net.conn.connectivity_change" /> <action android:name="android.intent.action.boot_completed" /> </intent-filter> </receiver> <service android:name="com.example.basicplayerapp.core.websocketservices"></service> networkreceiver public class networkreceiver extends broadcastreceiver { public static final string tag...

java - Android Broadcast Receiver not working (with two receiver) -

i have 2 broadcastreceiver , 1 working now. manifest <receiver android:name="com.example.basicplayerapp.core.audiojackreceiver" android:enabled="true" android:exported="true" > <intent-filter> <action android:name="android.intent.action.headset_plug" /> </intent-filter> </receiver> <!-- websocket --> <receiver android:name="com.example.basicplayerapp.core.networkreceiver"> <intent-filter > <action android:name="android.net.conn.connectivity_change" /> </intent-filter> </receiver> <service android:name="com.example.basicplayerapp.core.websocketservices"></service> when have audiojackreceiver works prefect. added networkreceiver audiojackreceiver stopped work. advice please. thanks. oncreate of video activity if (headset_only) { myaudiojackreceiver = new audiojackreceiver(); } ...

sql - If I KILL(SPID), what happen the running transaction? -

i have procedure, running @ 1 spid. now, found query running slow. in proc update/insert going on. if kill session, happen? sql server stop executing query , rollback open transactions. rollback undo changes haven't been committed. since sql server adheres acid principle, shouldn't able leave database in bad state, killing spids. isn't couldn't leave data in bad state, i.e. not wrapping multiple operations in transaction enforce consistency upon failure. https://msdn.microsoft.com/en-us/library/ms173730.aspx

syntax - How do I check if a var is a Tuple in Swift? -

reading type casting section of swift guide see use is keyword type check variables. func isstring(test: anyobject?) -> bool { return test string } it seems when try similar check tuple containing 3 nsnumber objects, receive 'tuple not conform protocol anyobject '. there way check if variable contains tuple? func istuple(test: anyobject?) -> bool { return test (nsnumber, nsnumber, nsnumber) // error } you can't use anyobject here because tuple not instance of class type. anyobject can represent instance of class type. any can represent instance of type @ all, including function types. from the swift programming guide - type casting instead, try using more general any type: func istuple(test: any?) -> bool { return test (nsnumber, nsnumber, nsnumber) } istuple("test") // false let tuple: (nsnumber, nsnumber, nsnumber) = (int(), int(), int()) istuple(tuple) // true

mongodb - Creating UI for Mongo DB in Meteor App -

i wish create ui meteor application able extract , display information mongodb on separate machine. going through houston , trying customize it. going in right direction or there other ways same? new meteor, appreciated.thanks

ruby - Stack level too deep in recursive method -

when run code: def binarysearch(key, arr, min, max) if max < min return -1 else midpoint = arr[(arr.length-1)/2] if midpoint < key binarysearch(key, arr, midpoint, max) elsif midpoint > key binarysearch(key,arr, min, midpoint) else return midpoint end end end arr = [0,1,2,3,6,77,23,1133,44,144,232,112] arr.sort! binarysearch(144, arr, arr.min, arr.max) i stack level deep error: tree.rb:15:in `binarysearch': stack level deep (systemstackerror) tree.rb:15:in `binarysearch' ... is there reason why cannot find return statement when right block reached? suggested define initialize default of nil , activate first run. 1) ruby not need return statement - recursive algorithm does. however, not problem 2) midpoint = arr[(arr.length-1)/2] this value never changes - every time call binarysearch, same value midpoint... on , on , over... forever.... why getting stack overflow. because no matter how d...