Posts

Showing posts from January, 2011

measure - 3 points distance calculation strategy -

problem: have (lat-long) co-ordinates of lot of points a, b, c, d . . . in database. now, when choose point a, need calculate distances of point each of other points , closest 1 eg. math requires cos , tan calculations of points. seems quite expensive on db side. so thought of strategy simplify this. below explanation of strategy. i have 3 known points (x, y, z) distance between 1 point other known. example lets assume 10. i.e. distance x y = 10; y z = 10; z x = 10. (this forms equilateral triangle. real scenario might not case) now lets have 2 points , b. calculate distances of point x, y , z , store respectively , point b. (say application logic) so have: for point a: ax, ay , az for point b: bx, , bz as strategy, question how can calculate distance between point point b. as problem itself, if apply above strategy it, question simplifying or complicating situation? thanks in advance answer. you can calculate distance between 2 points using pythagore

string - contains() method without prefix and suffix in Java -

i'm stuck on (simple, think) string validation. use following method text edittext can have 420 chars , must contain specific word (whatever place): if(edittext.gettext().tostring().tolowercase().contains(stringtohave)) { } // stringtohave = specific string however, want improve condition. example, have this: string = "this not metastackoverflow question"; string b = "stackoverflow"; and want know if a contains b regardless case sensitive, then, follows: if(a.tolowercase().contains(b)) { } this condition true because indeed a contains stackoverflow . however, a doesn't contain exactly b , there prefix meta . , not same word.. tried find way on , on other java websites without result. how can improve contains() method find exact string without prefix or suffix? should use method (as containsonly() , tried seems undefined string, it's check if contains numeric/alphabetic/etc. chars) ? edit: add "two spa

How to handle in app purchase within a real-time multiplayer iOS game -

this question more design , ux rather programming. don't find enough real world examples of want do, need guidance. in game center supported, real time, multiplayer game want offer consumable purchases, @ random times. both players compete on following basis: there x assets available both of them start @ same time occupying each asset when x assets taken, player having max assets win. the number of players constant: 2 during time of gameplay, in app purchase offered user, through can speed asset acquisition process. the question - when 1 players busies himself purchasing in-app purchase, should other player do? should enforce him pause because player buying stuff? if purchase didn't go through? as 1 can see, can't punish purchasing user allowing non-purchasing player continue while purchasing in progress. what fair-game policy , how achieve it? p.s. raise question on game forum, afraid don't know enough keywords explain problem. maybe classic 1

java - Struts 2 Hello word -

i'm new in struts 2 when run hello word example error http status 404 - there no action mapped namespace / , action name login. put jsp pages in wepapp/pages folder,how can solve that? @resultpath(value="/") public class hellocontroller extends actionsupport{ /** * */ private static final long serialversionuid = 1l; private string name; public string getname() { return name; } public void setname(string name) { this.name = name; } @action(value="/login",results={@result(name="success",location="pages/login.jsp")}) public string execute()throws exception { return "success"; } } web.xml <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.filterdispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> and

bash - Run script on login gnome -

i installed cairo dock in gnome , hide/remove standard dash in gnome. followed instructions on cairo website ( here ). if run code in terminal works run on startup: dbus-send --session --type=method_call --dest=org.gnome.shell /org/gnome/shell org.gnome.shell.eval string:'main.overview._dash.actor.hide();' i created gedit file code in ~/desktop , set execute permissions. used startup application ( gnome-session-properties ) run on startup doesn't work. next thing tried add bash in front of path script in startup application gui. no succes either. tried write shell script nano ( as explained here ): #!/bin/bash #hide gnome dash dbus-send --session --type=method_call --dest=org.gnome.shell /org/gnome/shell org.gnome.shell.eval string:'main.overview._dash.actor.hide();' saved script in ~/desktop , add in startup application gui. didn't work. saved script in ~/.config/autostart failed well. on startup dash still there. i'm new ubuntu , trying

Rails server and console fails to start due to Authlogic for ruby 2.0 and rails 3.2 -

i have ruby version 2.0.0p451 , rails version 3.2.13 . ran bundle install , gems installed. when try rails s command following error: the issue seems authlogic. uninstalled , server starts fine. ideas? /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- scrypt (loaderror) /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require' /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency' /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require' /usr/local/lib/ruby/gems/2.0.0/bundler/gems/authlogic-f19ff3a9eb88/lib/authlogic/crypto_providers/scrypt.rb:1:in `<top (required)>' /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.r

Command line output as HTML to a Browser, watch for new changes and refresh the browser -

i have ruby command line application outputs results of sequential calculations based on commands entered on the terminal. command-line-application can output results html file. how can make browser detect changes html file , refresh display new changes ruby application? in effect, when run commands on terminal, output formatted using html , written html file. browser "watching" html file refreshes display new html file upon detecting html file has changed. this not ruby problem. want browser reload page on change. solution http://livereload.com/ .

c# - "Avoid allocations in compiler hot paths" Roslyn Coding Conventions -

i've been reading through contributing code section of .net compiler platform ("roslyn"), , came across guidelines coding conventions. understand of coding conventions , why ask it. don't understand mean this: avoid allocations in compiler hot paths: avoid linq. avoid using foreach on collections not have struct enumerator. what "compiler hot path"? , why should avoid using linq , avoid doing foreach on collections not have struct enumerator? compiler hot paths code execution paths in compiler in of execution time spent, , potentially executed often. the reason avoiding (heap) allocations in these code paths allocations may trigger garbage collection, may cause sudden, extreme performance deteriorations. these should avoided in commonly executed code paths. linq , foreach singled out because these implicitly allocate memory – unless getenumerator returns struct , not cause heap allocations.

I can't find the window builder in Eclipse indigo -

i installed windowbuilder given guidelines. installed. when i'm going window ==> show view ==> pallet i'm getting error: could not create view: plug-in org.eclipse.wb.core unable load class org.eclipse.wb.internal.core.views.paletteview. <br/> in details <br/> org.eclipse.core.runtime.internal.adaptor.eclipselazystarter$terminatingclassnotfoundexception: error occurred while automatically activating bundle org.eclipse.wb.core (763). @ org.eclipse.core.runtime.internal.adaptor.eclipselazystarter.postfindlocalclass(eclipselazystarter.java:122) @ org.eclipse.osgi.baseadaptor.loader.classpathmanager.findlocalclass(classpathmanager.java:463) @ org.eclipse.osgi.internal.baseadaptor.defaultclassloader.findlocalclass(defaultclassloader.java:216) @ org.eclipse.osgi.internal.loader.bundleloader.findlocalclass(bundleloader.java:400) @ org.eclipse.osgi.internal.loader.bundleloader.findclassinternal(bundleloader.java:476) @ org.eclipse.osgi.in

ruby on rails 4 - RSpec undefined method `full_name' for nil:NilClass -

i'm trying test following rspec , factorygirl: describe 'get #show' "assigns requested dish @dishes" dish = create(:dish) :show, id: dish expect(assigns(:dish)).to eq dish end end factorygirl.define factory :dish, :class => 'dish' |f| f.name "testdish" f.header "testheader" f.author_id "1" f.avatar { file.open("spec/support/sample_photo.jpg")} end factory :invalid_dish |f| f.name nil end end but getting following error: 1) dishescontroller #show assigns requested dish @dishes failure/error: :show, id: dish actionview::template::error: undefined method `full_name' nil:nilclass # ./app/views/dishes/show.html.erb:3:in `_app_views_dishes_show_html_erb___4424609358762382481_2199208220' # ./app/controllers/dishes_controller.rb:16:in `block (2 levels) in show' # ./app/controllers/dishes_controller.rb:1

scala - How to "extend" factory methods when extending class with companion object with factory methods -

say have class foo, abstraction on kind of text file, , companion object factory methods simplifies creation of foo: class foo(val lines : seq[string], filepath : string) { ... } object foo { def apply(file : file) : foo = { new foo(scala.io.source.fromfile(file, "iso-8859-1").mkstring.split("\n").tolist, file.getpath } def apply(file : string) : foo = { apply(new file(file) } } what happens when want extend foo bar , baz , if both subclasses need have same factory methods? don't want copy companion object foo companion object bar , companion object baz , right way of making factory methods "generic"? you following: trait foofactory[t <: foo] { def apply(file : file) : t = //to implement in baz , bar class def apply(file : string) : t = { apply(new file(file) } //shared method, no need implement in subclassing classes } //example bar implementation------------------------------ class bar extends foo { /

Rounding numbers in Crystal report -

i have database table want generate crystal report show numbers e.g have 11.7 want remain 11.7 while round 12. don't want rounding . please help! it simple, select field want show 2 decimal places. right click on field go format field-->go number tab -->click on customize-->then in decimal select "1.0". http://www.crystalreportsbook.com/forum/forum_posts.asp?tid=9338 second option in formula , can give format, take 1 decimal.(check in above link)

@Java/Android Socket failed to read message -

i have trouble java sockets. i need connect server , client through local network , there can more 2 devices connected router client must find out address of server. the way know solve problem 3 first numbers of clients ip(v4)-address , loop every of 254 other possible ips. (i know way slow , may cause many problems. if know alternative, glad) . actually client android smartphone can dhcp-info. the problem is, read command check if device server last forever. if need code, here is! code: oncreate: final wifimanager manager = (wifimanager) super.getsystemservice(wifi_service); final dhcpinfo dhcp = manager.getdhcpinfo(); final string address = inttoip(dhcp.ipaddress); string addresspart=address.substring(0, address.lastindexof('.')+1); arraylist<hashmap<string, string>> l = null; log.d("keyboard","initiating search"); try { l = new checkconnections().execute(addresspart).get(); } catch (

change a value in an excel sheet from c# -

i want change specific value in excel sheet c#. when print value of cell changed gives me new one, when re-run code or if checked real excel sheet old value still there. code following: console.writeline("now enter please new password:"); string newpass = console.readline(); currentworksheet.cells[2,1].value = newpass; console.writeline(currentworksheet.cells[2, 1].value.tostring()); am missing , why excel sheet isn't changing?? appreciated. you manipulate excel file using kind of excel library. modify value, not save file. check documentation of library, there should kind of save command save modified excel sheet disk.

c# - Unable to access User Control's child controls from code behind -

i trying access of user controls' child controls code behind. of them working while others not. faulty user controls don't have designer files. want know if reason? if can't create of controls scratch complex , designer sent them without designer file , can't give him code correct went outside town. moreover looking great without designer file in design view. when write this: button1.visible=false; it's showing button1 not exist in current context. please tell me how solve this? following markup of 1 of faulty user-control: <%@ control language="c#" autoeventwireup="true" codefile="commentui.ascx.cs" inherits="commentui" %> <asp:button id="button1" runat="server" text="button" /> code-behind file: using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; public partial class commentui :

java - How to combine 2 images to form hybrid image? -

i implementing hybrid image imagej , stuck @ merging low filter image , high filter image form hybrid image. this done.i have 2 images gaussian blur , laplician of gaussian filer. need merge these 2 images layer after that. idea how achieve it? import ij.*; import ij.process.*; import ij.gui.*; import java.awt.*; import ij.plugin.filter.*; import ij.plugin.*; import ij.io.*; import java.io.*; public class hybridimage_plugin implements pluginfilter{ int cfsize=3; string img_lowpass; string img_highpass; private double[][] filter; private double sigma; float w=2 ,delta=0 , thr=0; int mode=0; //dialogbox private boolean gui() { genericdialog gd = new genericdialog("enter values", ij.getinstance()); gd.addnumericfield("sigma (3,5,9,17,35)", cfsize, 0); gd.addstringfield("low-pass", "/home/atrx/imagej/plugins/hybridimage/l1.tif"); gd.addstringfield("high-pass", "/home/atrx/image

android facebook java get user name with Graph API -

i name user id graph api, have user id select query https://graph.facebook.com/"+id+"?fields=name i don't know how call http/url query , retrieve data? since using android sdk, can make graph api calls this- bundle params = new bundle(); params.putstring("fields", "name"); final string requestid = {actor-id}; request request = new request(session, requestid, params, httpmethod.get, new request.callback() { public void oncompleted(response response) { graphobject graphobject = response.getgraphobject(); facebookrequesterror error = response.geterror(); if (graphobject != null) { if (graphobject.getproperty("id") != null) { string name = (string)graphobject.getproperty("name"); } } } }); request.executeandwait(request);

java - (OpenGL) Clamping large content to smaller area -

Image
i'm using opengl wigh lwjgl in java, that's not important here. i'm not asking code, hint on how this. language independent. i have region (a rectangle simplicity), and, let's say, big tiled map want show in area. area not whole screen, want render around it. i know few approaches , either huge pain or unsuitable. render whole tiled map , else, including background , frame, on top - leaving window. yes, works, it'd pain. render visible tiles , visible portions of border tiles. again, doable hard, , ie. when use external font drawing library, can't tell "hey, stop @ line, there's border." not approach, i'd say. some opengl magic i'm not aware of. guide me. when area guaranteed axis-aligned rectangle, can use glviewport and/or glscissor (the latter glenable(gl_scissor_test) ) prevent opengl rendering outside rectangle. in case of modifying viewport, image resulting scaled fit viewport rectangle. using scissor

regex - python regular expression $[a-zA-Z ][0-9a-zA-Z ]* with forbidding -

i looking regular expression in python, in string finds me: $[a-za-z_][0-9a-za-z_]* there can more of , can seperated whitespaces (\s) this quite easy, need forbid whole string if there did not match pattern. (+ empty string ok) i'll give examples: $x$y0123 => ok, gives me [$x, $y0123] $ => bad (only $) "" or " \t" => ok, gives me [] $x @hi => bad, cause @hi, not match pattern it can more regular expressions, doesn't have one. regex = re.compile("(\$[a-za-z_][0-9a-za-z_]*)") regex.findall(string) this ok, if don't have check things also. hmm, i'm not entirely sure you're trying do, maybe need 2 regex: first check validity of format, , second retrieve matches. import re stuff = ["$x$y0123", "$", "", " \t", "$x @hi"] p1 = re.compile(r'(?:\$[a-z_]\w*|\s)*$', re.ignorecase) p2 = re.compile(r'\$[a-z_]\w*|\s+', re.igno

c++ - 3D / FPS Camera Issues - SDL2 -

i got problem code, i'm trying make first person 3d camera. use sdl_getkeyboardstate(null) pressed keys. when press 1 of defined keys nothing happens, why? camera (controll): void control(float movevel, float mousevel, bool mi, sdl_window* window) { if (mi) //if mouse in screen { int midx = 640 / 2; //middle of screen int midy = 480 / 2; sdl_showcursor(sdl_disable); //we don't show cursor int tmpx, tmpy; sdl_getmousestate(&tmpx, &tmpy); //get current position of cursor camyaw += mousevel*(midx - tmpx); //get rotation, example, if mouse current position 315, 5*0.2, y campitch += mousevel*(midy - tmpy); //this x lockcamera(); //sdl_warpmouse(midx, midy); //move cursor center of screen sdl_warpmouseinwindow(window, midx, midy); const uint8* kstate = sdl_getkeyboardstate(null); if (kstate[sdlk_w]) { if (campitch != 90 && campitch != -90) { //if facing directly or down

c - First function call assigning a variable. Implicit declaration? -

consider, #include<stdio.h> int main() { int y = facto(6); printf("%d",y); return 0; } int facto(int x) { if(x==1) return 1; else return x*facto(x-1); } i read in posts said calling function before defined implicit declaration. how statement overhere ("y = facto(6)"), implicit declaration ? using gcc 4.8.1 on ubuntu 64 bit. y=facto(6) implicit declaration because you're telling compiler "i want call function , pass single int, somewhere down road there function single int parameter." if compiler ran int facto(int x) first, that's explicit declaration. implicit declarations dangerous because compiler won't "hey, doesn't match i've found function."

symfony - No default option is configured for constraint -

i writing own constraint (silly simple) following documentation symfony 2. after run have error: no default option configured constraint cgboard\signupbundle\validator\constraints\passwordnotmatching i saw in post in stackoverflow solution using service, i'm not sure if solution best, in documentation doesn't appear service regarding simple example. debugging little saw buildform() method never called. why? my validation.yml cgboard\signupbundle\entity\signupdata: properties: email: - notblank: ~ nickname: - notblank: ~ password: - notblank: ~ password_repeat: - notblank: ~ - cgboard\signupbundle\validator\constraints\passwordnotmatching: ~; my validator: <?php namespace cgboard\signupbundle\validator\constraints; use symfony\component\validator\constraint; use symfony\component\validator\constraintvalidator; class passwordnotmatchingvalidator extends constraintvalidator { public function validate($dataf

php - user_id condition on all models -

this question has answer here: setting default model conditions 1 answer i trying develop app multiple users. each users have example own clients, invoices, settings, profile etc. by default cakephp generated controllers/models/views show clients, invoices etc beloning users. so have edit add,view,index,edit , delete actions users can view,edit,add,delete own clients,invoices,settings,profile etc. i wondering if there easier more general way this. doing in appcontroller.php or appmodel.php not needed each controller/model/view. or if cakephp automatically can since hasmany, belongsto etc properties correctly set. the same question has been asked , answered me in detail here: setting default model conditions it includes behavior example well.

css - Footer width and position queries -

for reason can't footer stick bottom of page edit: trying keep @ bottom of page , not bottom of window and though have set width:100% seems 100% of width of previous div rather 100% of page. here jsfiddle of entire page : http://jsfiddle.net/eehsa/1/ the css code using footer is: #footer {height:50px; width:100%; background-color:red; position:absolute; bottom:0px;} set position:absolute position:fixed footer edit: apply css reset *{padding:0;margin:0;} change position of footer relative , remove top container. demo: http://fiddle.jshell.net/nw7ej/show/

how to set asp.net hidden field in javascript and access the value in c# code behind -

i'm trying set hidden field value in js think works fine approachl <asp:hiddenfield id="hflatsw" runat="server" /> var latsw = bounds.getsouthwest().lat(); $('#<%=hflatsw.clientid %>').value = latsw; trying access value on asp.net button click in code behind gives me null value, idea happening in postback , why i'm not able access value set javascript? in advance, laziale .value isn't jquery property. use .val() : $('#<%=hflatsw.clientid %>').val(latsw); or without jquery: document.getelementbyid('<%=hflatsw.clientid %>').value = latsw;

python - File Upload in Mezzanine -

i unable upload file upload program. created small project in django upload , download files. project was/is working fine. trying in mezzanine have created following models: from django.db import models django.contrib.auth.models import user mezzanine.pages.models import page time import time def get_upload_file_name(instance, filename): return "galleries/%s_%s" %(str(time()).replace('.','_'), filename) gender = (('----','please select ...'),('male','male'), ('female','female')) class allusers(models.model): fullname = models.charfield(max_length=300) dob = models.datefield() gender = models.charfield(max_length=7, choices = gender) homeaddress = models.textfield() contact = models.charfield(max_length=300) email = models.emailfield() cv = models.filefield(upload_to = get_upload_file_name) forms : class userform(forms.modelform): class meta: model = alluser

php - MySQLI Prepared Statement: num_rows & fetch_assoc -

below poorly written , heavily misunderstood php code no error checking. honest, i'm struggling little getting head around maze of php->mysqli functions! please provide example of how 1 use prepared statements collect results in associative array whilst getting row count $stmt? code below i'm playing around with. think bit that's throwing me off using $stmt values after store_result , trying collect assoc array, , i'm not sure why... $mysqli = mysqli_connect($config['host'], $config['user'], $config['pass'], $config['db']); $stmt = $mysqli->prepare("select * licences generated = ?"); $stmt->bind_param('i', $core['id']); $result = $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows >= "1") { while($data = $result->fetch_assoc()){ //loop through results here $data[] } }else{ echo "0 records found"; } i feel little cheeky askin

regex - JavaScript Regular Expressions Special Characters -

why regular expression /^[^-_]*([a-za-z0-9]{3,})+[-_]?[^-_]*$/i match on string? ,abc,,. it says string should contain of minimum 3 letters followed optional - or _ sequence of number 1 , 2 can repeated infinite times no - or _ @ beginning or end of string the regex should not allow other characters a-z , 0-9 , - or _ , yet, allows them. thanks in advance erm, actually, says: from start, any number of characters not - or _ (matches , ) catastrophically backtrack find @ least 3 alphanumerics (matches abc ) optionally match - or _ (matches nothing) any number of characters not - or _ (matches ,,. ) to end. did mean: /^[a-z0-9]{3,}(?:[-_][12]+)?$/i correction, misunderstood "point 3". /^[a-z0-9]{3,}(?:[-_][a-z0-9]{3,})*$/i

imageview - How and where to save image after user selects an image in app: Android -

i have tab let user select image gallery or taking new photo. once uri, display image in respective tab. but, want make sure image still there when user comes app. 1 option save uri , when app loaded again, display image based on uri, done when user selected photo. issue approach have uri in app image. if user deletes photo gallery have nothing show. so there way store image in app? thanks. you can use 1 of storing ways android provides: http://developer.android.com/guide/topics/data/data-storage.html saving in external storage or sd card 1 of best options.

java - How to get a value from an @Around declared method using AspectJ? -

this code snippet: @around("execution(* de.my.package.path.controller.recommendationcontroller.recommenditems*(..))") public object measuretimewithoverhead(proceedingjoinpoint joinpoint) throws throwable { long startnanotime = system.nanotime(); object proceed = joinpoint.proceed(); long endnanotime = system.nanotime(); long diff = endnanotime - startnanotime; system.out.println("elapsed time: " + (diff)); return proceed; } i want use value of "diff" variable in further program. how can retrieve value? possible @ all? (btw, working on spring 4.0.2 mvc application) currently, no. diff variable local variable , therefore accessible within body of method, after it's been declared (and initialized). aop advice meant add additional behavior (by executing code) @ point in execution of program. it's self contained component. can know code it's intercepting, not vice-versa.

osx - Quitting Java program renders Mac OS X window switching non-functional -

on mac programming, have app installed called bettertouchtool allows me bind keyboard shortcuts 'gestures' on trackpad. have bound gesture (that doesn't have apple default) shortcut command + q , quits active program. have found convenient quitting programs testing, can writing code. however graphical game programming, action makes can't use 3 finger swipe switch between windows (several other gestures disabled). happen if go menu , click quit or if click red x close button. fix either restart computer or (and weird) click in-game close button calls system.exit(0); . know players using still want figure out why happening. in addition games minecraft on computer don't this. i using jframe setdefaultcloseoperation(jframe.exit_on_close); in code. in attempt fix issue have tried registering com.apple.eawt.quithandler calls system.exit(0); in handler. i have no idea considered relevant code here, whatever see, let me know. i figured out. there 1 r

svg - Includes in ERB for Rails -

i trying follow guide: http://css-tricks.com/svg-sprites-use-better-icon-fonts chris states inject svg after opening body tag. in php simple i'm using rails have .html.erb file. how include file using this? have tried asset helpers, evaluate, render. nothing seems work? this belongs ruby racer. inline_svg_helper.rb def inline_svg(path) file.open("app/assets/images/#{path}", "rb") |file| raw file.read end end

saving a 2D array to a file c++ -

i trying save 2d array file, showing "^l". if user enters y or y, program supposed end, printing 2d array instead. //allow user quit cout << "would quit game? enter y or n: " << endl; cin >> choice; if (choice == 'y' || choice == 'y') { ofstream outfile("map.txt"); (int row = 0; row < rows; row++) { (int col = 0; col < cols; col++) outfile << "here map! " << map[rows][cols] << endl; } outfile.close(); } if (choice == 'n' || choice == 'n') { // add code play game playturn(treasurer, treasurec, row, col, nummoves); } // print map true printmap(map,true, treasurer, treasurec, startr, startc, row, col); //end game cout << "you finished game in " << nummoves <<" moves.\n"; can serialize map stream. stream can specified you. std::cout or std::fstream can work.. #include <iostream

jquery - Having trouble with javascript sort() order -

this html code put in array sort. trying numbers sort in order lowest highest (in ids). code seems resort top bottom while maintaining current order. having looked around , trying few different methods, have not found solution of yet. suggestions? <a href="#" class="link-sort-list asc">a-z</a> <a href="#" class="link-sort-list desc">z-a</a> <ul id="sortable"> <li id="220" class="p_box"></li> <li id="221" class="p_box"></li> <li id="217" class="p_box"></li> <li id="215" class="p_box"></li> <li id="219" class="p_box"></li> <li id="216" class="p_box"></li> <li id="218" class="p_box"></li> <li id="214" class="p_box"></li> <li id="208" cla

java - Search through HashMap with user input string -

i creating dictionary application small assignment, these were, unfortunately, given out random , have pulled 1 have no idea how implement. i hear suggestions taking user input , using through hashmap (is possible?) provide definition. additionally (sorry), has bilingual, have words in both languages in 1 hashmap , have way search through both? i out of league here, appreciated. import java.util.hashmap; import java.util.map; import java.io.*; public class dictionary { public static void main(string[] args) { map<string, string> map = new hashmap<string, string>(); string s1 = getinput("enter word define: "); map.put ("abduction","a carrying away of person against or illegally."); map.put ("ache","to in pain or distress."); map.put ("befriend","to friend to, when in need."); map.put ("bilingual","speaking 2 language

android - How to make a Horizontal ScrollView -

i want scroll horizontally when run code of buttons in first relativelayout out of screen , not scroll see them. google store have blocks , each block can scrolled horizontally see more my xml : <scrollview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:scrollbars="horizontal|vertical" tools:context=".mainactivity" > <tablelayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizon

java - How to add background image to jframe confused -

this question has answer here: background image in jframe 3 answers how can can add background image jframe , should u add code? import java.awt.*; import java.awt.event.*; import javax.swing.imageicon.*; import javax.swing.*; //import java swing use jframe etc public class mathquiz extends jframe implements actionlistener { jcheckbox answer1 = new jcheckbox(); //checkbozx answer 1 jcheckbox answer2 = new jcheckbox(); //checkbozx answer 2 jcheckbox answer3 = new jcheckbox(); //checkbozx answer 3 jtextarea textarea = new jtextarea();//text area question jbutton exit = new jbutton(); // button exit quiz jbutton calculator = new jbutton(); // button open calculator jlabel image = new jlabel(); //adds background image // names associated numbers. int answer; int questionnumber; /** * bit of code starts process of showing window. **/ public mathquiz() { // d

ruby on rails - Error when running cap deploy:cold -

my configiration centos 6.5 postgras93 ruby 1.9.3 ruby on rails 3 i have error when tring run cap deploy:cold i have ran bundle command , know pg 0.15.1 installed i have ran command well bundle config build.pg --with-pg-config=/usr/pgsql-9.3/bin/pg_config here error servers: ["www.loadmax.com", "workers.loadmax.com"] [www.loadmax.com] executing command [workers.loadmax.com] executing command ** [out :: www.loadmax.com] gem::installer::extensionbuilderror: error: failed build gem native extension. ** [out :: www.loadmax.com] ** [out :: www.loadmax.com] /usr/local/rvm/rubies/ruby-1.9.3-head/bin/ruby extc onf.rb ** [out :: www.loadmax.com] checking pg_config... no ** [out :: www.loadmax.com] no pg_config... trying anyway. if building fails, p lease try again ** [out :: www.loadmax.com] --with-pg-config=/path/to/pg_config ** [out :: www.loadmax.com] checking libpq-fe.h... no ** [out :: www.loadmax.com] can't find 'libpq-fe.h