Posts

Showing posts from April, 2010

powerpc - What would be the C equivalent of rlwinm (PPC Instruction) -

i wondering if of know c equivelent of powerpc instruction below. rlwinm r31, r0, 0,13,13 thanks. rotate left register immediate, and mask. rotate left 0 here, can ignore this. mask bits set 13 13, bit 13 (0x2000 bitmask; command chosen on and document bit 13 selected). so in case, need build mask bit 13 , apply bitwise and source. r31 = r0 & (1 << 13); << shift left operation in c, use here create mask bit 13. & , operation in c. documentation source: http://sametwice.com/rlwinm

javascript - "this.parentNode.parentNode" is undefined in firefox but works in other browsers -

in code below, alert shows correct data-table value in google chrome undefined in mozilla firefox - there missing? <td> <a onclick="add_data_event(this.parentnode.parentnode, '<?=$result['g_id'];?>')" class="btn btn-primary" data-toggle="modal" data-target="#addremindermodel-editclick"> <i class="fa fa-edit"></i> </a> </td> <script> function add_data_event(index, ser) { alert('i in script'); alert(index.cells[1].innertext); } </script>

android - Uncheck Checkbox depend on another activity -

in main activity add icon . there checkbox list dialog appear. when click on checkbox user can check desire url link. when checkbox checked, 2 edittext saved db. 2 edittext invisible. it's list in activity. if user don't added url. can delete popup dialog call delete. problems when user delete url, want uncheck in list of checkbox on dialog. note* checkbox list manually added. thanks. if have additional question pls ask me. there 2 approaches: pass state of checkbox 1 activity through intent . based on state of checkbox received through intent in second activity, make changes in ui. boolean state = [getstateofcheckbox]; intent.putextra("key", state); startactivity(intent); //get state in receiver activity's oncreate() intent receiveintent = getintent(); boolean checkboxstate = receiverintrent.getbooleanextra("key"); save state of checkbox in sharedpreferences in first activity , retrieve value in second activity.

Microsoft Web Deploy v3 or higher is recommended. When Deploying a ASP.NET website to amazon ec2 -

Image
i followed this tutorial i installed web deploy 3.5,and added website in iis on ec2 instance im still getting error . im using public dns service url thanks in advance edit: im using visual studio 2012 , website in .net 4.5 install web deploy 3.5 on local machine using wpi

c++ - Enter two integer and display the largest number using predefined function -

i type function can't output. can me. must use predefined function. program running have errors please me. #include <iostream> using namespace std; float largenum (float a, float b) { float largenum; if(a>b) cout<<"a larger"; if(b>a) cout<<"b larger"; return (largenum); } int main() { float num1, num2; cout<<"enter number"; cin>>num1; cout<<"enter number"; cin>>num2; cout<<largenum<< "is larger"<<endl; return 0; } #include <iostream> using namespace std; float largenum (float a, float b) { if(a>b) return a; return b; } int main() { float num1, num2; cout<<"enter number"; cin>>num1; cout<<"enter number"; cin>>num2; cout<<largenum(num1, num2)<< "is larger"<<endl; return

permissions - Connecting play framework to mysql -

i have 2 databases in mysql: mysql> show databases; +--------------------+ | database | +--------------------+ | information_schema | | mysql | | performance_schema | | app | | app_dev | +--------------------+ i have 2 play framework servers running, 1 using app , 1 using app_dev. server connecting app local machine running mysql. server connecting app_dev remote. think i've setup permissions correctly: mysql> show grants 'app_dev'; +------------------------------------------------------------------+ | grants app_dev@% | +------------------------------------------------------------------+ | grant usage on *.* 'app_dev'@'%' identified password 'pwd' | | grant privileges on `app_dev`.* 'app_dev'@'%' | +------------------------------------------------------------------+ mysql> show grants 'app'@'localho

powershell - Find XML attributes at random -

how can find 2 attributes $_.completename , $_.channel @ random? + $channel | ? {$liste} | get-random <<<< -min 0 -max $liste.list.groupe.count + categoryinfo : invalidargument: (position:psobject) [get-random ], parameterbindingexception + fullyqualifiederrorid : inputobjectnotbound,microsoft.powershell.command s.getrandomcommand sample data $xliste = [xml]@" <list> <groupe> <position type="general"> <completename>folder-1</completename> <dateyy>2014</dateyy> <datemm>jaenner</datemm> <datedd>mittwoch</datedd> <overall_mode>cbr</overall_mode> <duration>00:1:27</duration> <overall_rate>96.0kbps</overall_rate> </position> <position type="version"> <channel>channel2</channe

c# - Run vs. Content vs. Text in WPF -

in wpf (or windows 8 application) have 3 possible ways add text in control. run element inside textblock element <textblock> <run>my text</run> </textblock> text property attribute of textblock element <textblock text="my text" /> text property element inside textblock element <textblock> <textblock.text>my text</textblock.text> </textblock>` what differences between these 3 approaches? , why must use text textblock , content comboboxitem ? a control text property can accept string , rendered in specific way handled control. examples of such controls textblock , textbox . controls content property can have literally object set property. these controls forward value content property on contentpresenter . contentpresenter class documentation has relevant block: the contentpresenter uses following logic display content: if contenttemplate property on contentpre

datetime - Age calculation leap year issue in php -

i using following function calculate age given date of birth, not showing correct difference if leap year day i.e 29 used. please me fix code. <?php function getabsage($birthday) { list($year,$month,$day) = explode("-", $birthday); $year_diff = date("y") - $year; $month_diff = date("m") - $month; $day_diff = date("d") - $day; if ($day_diff < 0 || $month_diff < 0) { $year_diff--; } if ($year_diff == 0) { $interval = date_diff(date_create(), date_create($birthday)); $months = $interval->format("%m"); $days = $interval->format("%d"); if ($months > 0) { return $interval->format("%m months %d days"); } else if ($months == 0 && $days > 1) { return $interval->format

visual studio 2012 - update records in file (c++) -

i wanted ask how can append strings end of fixed number of lines (fixed position). trying , searching books , websites answer couldn't find doing wrong. my structure : const int numberofdays=150 ; const int numberofstudents=2; struct students { char attendance[numberofdays]; int rollno; char fullname[50],fathersname[50]; } creating text file ofstream datafile("data.txt", ios::out ); then take input user , save file. how save data text files : datafile <<attendance <<endl<< rollno <<endl<< fullname <<endl<< fathersname <<endl ; how looks in text files : p // p present - 1st line 1 // roll number monte cristo // full name black michael // fathers name // absent - 5th line 2 // roll number johnson // full name nikolas // fathers name how try update file. ( updatin

c# - How to generete charts according to the user selection using Modern UI (Metro) Charts? -

i'm using modern ui (metro) charts in projects. can find library here http://modernuicharts.codeplex.com/ i have combobox in gui , contains types of charts. need when user selects chart type, want generate chart. can manually editing xaml code generates graph. how can according user selection? need possible.. here have working exemple : mainwindow xaml : <window> <stackpanel> <combobox width="100" itemssource="{binding charttypes, mode=twoway}" selecteditem="{binding simplestringproperty, mode=twoway}" text="select option"></combobox> <frame navigationuivisibility="hidden" x:name="frametest" source="{binding selectedpagechart, mode=twoway}"> </frame> </stackpanel> </window> mainwindow viewmodel: public class mainviewmodel : inotifypropertychanged { public observablecollection<string&g

Spring JDBC throws java.lang.NoSuchMethodError: org.hibernate.Session.connection()Ljava/sql/Connection; -

my problem same 1 - java.lang.nosuchmethoderror: org.hibernate.sessionfactory.opensession()lorg/hibernate/classic/session i following exception while using spring jdbctemplate. java.lang.nosuchmethoderror: org.hibernate.session.connection()ljava/sql/connection; the accepted answer in link above, recommends downgrading hibernate version supported spring. this not acceptable me need latest version of hibernate use new features (and benefit bug fixes). is there way work without downgrading hibernate? the transaction manager being used jpa transaction manager. left on days when using jpa via spring. no longer that, not expecting spring break on hibernate version update. on searching bean definition, found incorrect reference jpa/hibernate , removed it. application runs fine now. changed this: <bean id="transactionmanager" class="org.springframework.orm.jpa.jpatransactionmanager"> <property name="entitymanagerfactory" r

Matlab Cell Array Import via R fails -

i facing following problem. try import cell of strings readmat function in r. matlab code: names = {'a', 'b', 'c', 'd'}; save('rdatain.mat', 'names'); now want use set of strings in r. run following r script r code: library('r.matlab') names <- readmat("rdatain.mat") readmat can apparently not handle cell type .mat data, creates strange list. solution problem? thanks. yeah.... it's pretty weird that. wouldn't "fails", it's in format requires work. when save above cell array , load r: > library("r.matlab") > names <- readmat("rdatain.mat") > names $names $names[[1]] $names[[1]][[1]] [,1] [1,] "a" $names[[2]] $names[[2]][[1]] [,1] [1,] "b" $names[[3]] $names[[3]][[1]] [,1] [1,] "c" $names[[4]] $names[[4]][[1]] [,1] [1,] "d" attr(,"header") attr(,"heade

C# How to Print 2 arrays together -

ok, lets have 2 arrays these; int[] wow = new int[50]; (int j = 0; j < wow.length; j++) { wow[j] = j + 1; } int[] wew = new int[50]; (int = 0; < wew.length; i++) { wew[i] = + 10; } and want print them like; 1 , 11 2 , 12 3 , 13 for (int j = 0; j < wow.length; j++) { wow1[j] = j + 1; wow2[j] = j + 10; //print wow1 & wow2 here. console.writeline("{0},{1}", wow1[j], wow2[j]); } note in 2 loops, no different j, same!

java - Guide to use Restlet Swagger extension for GAE -

i tried similar approach: public restlet createinboundroot() { router apirouter = createapirouter(); attachswaggerspecificationrestlet(apirouter, "/api-docs"); return apirouter; } when /api-docs access restlet throws error 404, messing. idea apirouter have working @ state, when acess resource /stuff etc. what missing in code? or there specific notes take consideration when using restlet swagger extension gae? i tested usecase , can make work swagger extension following maven configuration ( restlet-version = 2.3.1)ae dev server: <dependencies> <dependency> <groupid>org.restlet.gae</groupid> <artifactid>org.restlet</artifactid> <version>${restlet-version}</version> </dependency> <dependency> <groupid>org.restlet.gae</groupid> <artifactid>org.restlet.ext.servlet</artifactid> <version&g

c - Number and its logarithm as compile constants without manually changing both? -

i have constant width power of 2, e.g. #define width 1024 . i have associated #define width_binary_log 10 must change every time modify width , binary logarithm of width . undesirable forget so, , things consequently go haywire. unfortunately pow() not available in macros. usage *z = zx >> width_binary_log . my plan fix this, given maximum possible value of width_binary_log 16 , following usage: *z = zx >> binary_log(width) with following defines: #define binary_log_1 0 #define binary_log_2 1 #define binary_log_4 2 #define binary_log_8 3 #define binary_log_16 4 #define binary_log_32 5 #define binary_log_64 6 #define binary_log_128 7 #define binary_log_256 8 #define binary_log_512 9 #define binary_log_1024 10 #define binary_log_2048 11 #define binary_log_4096 12 #define binary_log_8192 13 #define binary_log_16384 14 #define binary_log_32768 15 #define binary_log_65536

android - How to add startActivity into OnClickListener in Adapter? -

here adapter. public class myadapter extends recyclerview.adapter<myadapter.viewholder> { private static final int type_header = 0; // declaring variable understand view being worked on // if viaew under inflation , population header or item private static final int type_item = 1; private string mnavtitles[]; // string array store passed titles value mainactivity.java private int micons[]; // int array store passed icons resource value mainactivity.java private string name; //string resource header view name private int profile; //int resource header view profile picture private string email; //string resource header view email static context context; // creating viewholder extends recyclerview view holder // viewholder used to store inflated views in order recycle them public static class viewholder extends recyclerview.viewholder { int holderid; textview textview; imageview imageview; imageview profile; textview name;

java - ARRAY ITEMS WITH INCREASING INDEX It's simple and I don't know how -

i have code in eclipse developing , android application need have items display in spinner. manage have items displayed in spinner code below bulky , let's have 100 items need have 100 of (item_food[n] +" "+ item_kcal[n] + "kcal")...this can basic logic or iq, don't know how. there function can use replace code within {} in code below? please help. thank in advance. string[] item_food = res.getstringarray(r.array.items_food); string[] item_kcal = res.getstringarray(r.array.items_kcal); display = new string[] { (item_food[0]+" " + item_kcal[0] + "kcal"), (item_food[1] +" "+ item_kcal[1] + "kcal"), (item_food[2] +" "+ item_kcal[2] + "kcal"), (item_food[3] +" "+ item_kcal[3] + "kcal"), (item_food[4] +" "+ item_kcal[4] + "kcal"), (item_food[5] +" "+ item_kcal[5] + "kcal"

error when building android sample games in android studio -

i downloaded android sample games , imported them in android studio, keep getting following errors: error: com.android.ide.common.process.processexception: org.gradle.process.internal.execexception: process 'command 'c:\users\soko\appdata\local\android\android-sdk\build-tools\20.0.0\aapt.exe'' finished non-zero exit value 42 error:execution failed task ':skeletontbmp:mergedebugresources'. c:\users\soko\downloads\compressed\android-basic-samples-master\android-basic-samples-master\basicsamples\skeletontbmp\build\intermediates\exploded-aar\com.android.support\appcompat-v7\20.0.0\res\drawable-xhdpi\abc_textfield_search_right_selected_holo_light.9.png: error: com.android.ide.common.process.processexception: org.gradle.process.internal.execexception: process 'command 'c:\users\soko\appdata\local\android\android-sdk\build-tools\20.0.0\aapt.exe'' finished non-zero exit value 42 check compilesdkversion , buildtoolsversion mat

ios - How to draw a route between two locations using MapKit in Swift? -

how can draw route between user's current location specific location using mapkit in swift? i searched lot, didn't find helpful swift-specific links or tutorials. i'll link tutorial shows how in swift: ray wenderlich: overlays in mapkit this should cover need.

ASP.net MVC 5 C# returning the double from within IF statement -

how access double within if statement [httppost] public actionresult iflexcst([optional] float quan, [optional] float kammid, [optional] float kammod, [optional] float spacerinnerdim, [optional] float spacerouterdim, [optional] float washouterdim, [optional]float isowashinnerdim, [optional]float steelwashinnerdim, [optional] float steelwashquan, [optional] float isowashquan, formcollection form) { //other functions removed if (washouterdim <= 43.6) { double washerserrtime = 0.6; double serrwasherrun = (washerserrtime * isowashquan) * (1 / 60); viewbag.serrwasherrun = serrwasherrun; double serrwasherrunprice = ((serratesetup / quan) + washerserrtime) * serraterate; viewbag.serrwasherrunprice = serrwasherrunprice; } if (washouterdim > 43.6) { double washerserrtime = 0.833; double serrwasherrun = (washerserrtime * isowashquan) * (1

Python ValueError while dividing array by its own column -

numpy arrays a = [[1, 2, 3, 4], [1, 2, 3, 4 ]] , c = a[:,1] . b should a/c. expecting b [[0.5, 1, 1.5, 2], [0.5, 1, 1.5, 2]] trying same using normal division, or numpy division, error, valueerror: operands not broadcast shapes (2,4) (2,) . dividing entire array column in particular array. suggestions? there similar post, no solid answers it. to make broadcasting possible here add 1 more axis c : >>> = np.array([[1, 2, 3, 4], [1, 2, 3, 4 ]], dtype=float) >>> c = a[:,1][:, none] >>> a/c array([[ 0.5, 1. , 1.5, 2. ], [ 0.5, 1. , 1.5, 2. ]])

php - L5 | Relationship Tinker Query -

i've setup 1 many relationship following models job , steps. job can have many steps, , step belongs job. when go query relation job::with('steps')->find(1) , results displayed expected collection <mariasapp\job #000000002b07ae180000000036b76e17> { id: 1, number: 59221, customer_id: 5, user_id: 17, created_at: "2015-03-24 01:32:20", updated_at: "2015-03-24 01:32:20", steps: <illuminate\database\eloquent\collection #000000002b07ae070000000036b76e17> [ <mariasapp\step #000000002b07ae7b0000000036b76e17> { id: 37, job_id: 1, body: "eligendi reiciendis ratione labore sed.", created_at: "2015-03-24 01:32:21", updated_at: "2015-03-24 01:32:21" } ] } but when run job::with('steps')->find(1)->body response null . there way me pull body

c++ - Error: use of deleted function std::basic_ofstream (OpenCV and C++11) -

this question has answer here: why can't move std::ofstream? 1 answer i'm trying import project wrote time ago under windows using c++11 , opencv giving me troubles , can't figure out why. makefile project , added line enable c++11 support. however, when i'm trying run "make" or run project in eclipse receive following error (and few others) use of deleted function ‘std::basic_filebuf<char>& std::basic_filebuf<char>::operator=(const std::basic_filebuf<char>&)’ facadelabelingv2 line 599, external location: /usr/include/c++/4.8/fstream my code looks this: #ifndef _fileutil_cpp_ #define _fileutil_cpp_ #include "configuration.h" #include "utilities.cpp" #include <iostream> #include <fstream> static void savefeatures(const std::pair<cv::mat, cv::mat>& features

jquery - TypeError: $(...).get(...) is undefined when trying to open a .txt file with input type text -

i'm trying read .txt file, split in lines , console.log it. far i'm getting error when try read file. please tell me i'm doing wrong. $("#draftloginput").change(function () { //gets first file draftlog var filenumber = $('#draftlog').get(0).files.length; filenumber--; logfile = $('#draftlog').get(0).files[filenumber]; //reads file draftlog text var reader = new filereader(); reader.readastext(logfile); reader.onload = function (e) { var rawlog = reader.result; //splits text array of strings every new line var re = /\r\n|\n\r|\n|\r/g; var splitlog = rawlog.replace(re, "\n").split("\n"); console.log(splitlog); }; }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="file" id="draftloginput"> instead of using

java - ANDROID: Layouts do not look the same on different devices -

i had friend basic low resolution droid download app. looking same, phone made text seem larger mine. okay, went layout had grid view , happened: http://imgur.com/vde6fce as see grid falls off screen. here looks on lg g3 phone: http://imgur.com/afegfke i confused in layout used "dp" size. here layout xml file: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="top" android:background="#ff000000" android:layout_centerhorizontal="true" android:id="@+id/activity_game"> <button android:layout_width="80dp" android:layout_height="50dp" android:textsize="23sp" android:background="@android:color/transparent" a

jquery typescript definition file gives error -

i have 2 visual studio projects in same solution, have updated latest jquery 2-1-3 , typescript definition 2-2-3, error, build: interface 'jquerypromise' incorrectly extends interface 'jquerygenericpromise funny thing error in 1 project. ideas thanks had same problem, did copy following line bottom of "interface jquerypromise extends jquerygenericpromise" block. /** * add handlers called when deferred object resolved, rejected, or still in progress. * * @param donefilter function called when deferred resolved. * @param failfilter optional function called when deferred rejected. */ then<u>(donefilter: (value?: t, ...values: any[]) => u|jquerypromise<u>, failfilter?: (...reasons: any[]) => any, progressfilter?: (...progression: any[]) => any): jquerypromise<u>; /** * add handlers called when deferred object resolved, rejected, or still in progress. * * @param donefilter function called when deferred resolved.

php - Embedding another pages register form on my own page? -

how can embed page's register form, own page? the reason why is, promoting company. , wish spare person visiting page , wanting sign up, 1 step in process. instead of having them: visit page get interested in product redirecting them company's page and have them sign account. i instead have them: visit page get them interested in product / company have them sign account in company right @ page as can see if benefit both potential customer , me promoter save person step in process. so question is, how can embed company's register form own page / register form. i've seen group this, , know it's possible. wish know how make possible , set up. i hope clear enough. looking forward hear guys. thank's in advance. appreciate it. /fredrik there several ways include external page in own page, either using iframe or reading page per javascript , including in div container. in terms, not end desirable solution , propably won&#

javascript - How to obscure telephone number from database -

how obscure telephone number retrieved database? i'd users able click button , telephone number appears. so far it's hidden user until click button, can see number fine in source code. is there anyway hide/muddle number (perhaps inject characters?) on page load , clicking button removes these characters?

swift - string under Map Kit pin (mkannotationview image) -

i trying set names under pins on map. each name should specific. not using default pins, hence each pin specific image. thinking of generating kind of image present image of pin , name label under it. append whole thing image of mkannotationview. looks mess me. is there way possibly append label under mkannotationview? or should make custom mkannotationview? thank time. the mkannotationview class subclass of uiview, should able subclass easily. i create custom subclass, , have subclass add label subview of mkannotationview. might need adjust frame of view make room label you're adding.

Customize google placepicker colors for android -

i want customize google place picker widget android. can styling primary , primary dark colors devices api below 21 (using appcompat matherial)? yes possible use material design themes below android 5.0. check out link

SQL update with PL/sql function -

i have update 1 column in table ( requirement use function). have created simple function customer1 table. how can update table using function . there ways ? create or replace function fn_easy (name_in in customer1.last_name%type) return customer1.first_name%type name_tab customer1.first_name%type; begin select first_name name_tab customer1 last_name = name_in; return name_tab; end fn_easy; update customer1 set first_name = fn_easy(customer1.last_name); i understand need loop argument in function. 1 idea have through cursor. don't think optimal use cursor task when have 200 records. your function ok, have ensure select inside returns 1 value, otherwise exception. if want select values array, use bulk collect into . update column value using function, column value type must compatible function return type.

Write to a Google Doc using Drive API -

i looking create , write content google drive doc. i have create drive doc step down, aren't able post content. code create file test doc function createnewfile() { gapi.client.load('drive', 'v2', function() { var request = gapi.client.request({ 'path': '/drive/v2/files', 'method': 'post', 'body': { "title": "test.doc", "mimetype": "application/vnd.google-apps.document", "description": "some" } }); request.execute(function(resp) { console.log(resp); updatefile(resp.id, "test text"); }); }); } code add contents newly created google doc function updatefile(fileid, text, callback) { const boundary = '-------314159265358979323846'; const delimiter = "\r\n--" + boundary + "\r\n

tags - Can I add a git release as a submodule? -

i have binary files in github release tag, think not cloneable. in git repo i'd add these binary files (they dependencies) submodule, can updated easily. dont want submit binaries first repository if possible. how do this? from understand, git releases separate regular git repo, other git repo cannot directly reference them. all version script able releases first repo @ right tag, using github api releases .

c - Code to do Tolerance Analysis -

so, i'm trying build code , crashes somewhere in second custom function. i'd print out content of file "tin.txt", eof seems crash it. i'm coding in c. it seems junk getting arrays. need use string tok anyway, hints that? edit far. i've put in of suggested changes, , compiler (codeblocks, in case matters) has stopped screaming in pain. i'm struggling information arrays using strtok, can't figure out how make work. (i'm unsure if should ask second question @ point or edit on, edited one.) /************************************************************************* 3/25/2015 program takes in file of format part,2.000,-1,0.050,v part,0.975,-1,0.025,v part,3.000,+1,0.010,f gap,0.000,0.080 tolerance analysis **************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #define buffer_size 1024 #def

f# - fsharp compound interest beginner -

i not know i'm supposed here beginner let interest = 0.02 // interest rate 2% let periods = 12.0 // number of times interest compounded per year let years = 10.0 // number of years money borrowed // calculate compound interest using formula from: // http://en.wikipedia.org/wiki/compound_interest#compound_interest let compound investment = ***i supposed put here*** let res = compound 1000.0 shouldequal (round res) 1221.0 printfn "compound interest (full): %f" res printfn "compound interest (two digits): %.2f" res if right understand: let interest = 0.02 // interest rate 2% let periods = 12.0 // number of times interest compounded per year let years = 10.0 // number of years money borrowed let investment = 1000.0 //principal amount (initial investment) // calculate compound interest using formula from: // http://en.wikipedia.org/wiki/compound_interest#compound_interest let compound p j n t =

android - How to get the language code based on country code in java -

how language code based on country code in java hi had situation need find language based on country code. country name "switzerland" had country code "ch" . there can 3 languges german,french , ukenglish in switzerland . need find language code based on country code. scenario : country code "ch" . need language code based on country code. thanks in advance this program prints language codes available locales switzerland. can modified e.g. return list<string> of language codes. picking 1 want left exercise reader - swiss have not chosen pick single preferred language country. import java.util.locale; public class test { public static void main(string[] args) { locale[] = locale.getavailablelocales(); (locale locale : all) { string country = locale.getcountry(); if(country.equalsignorecase("ch")){ system.out.println(locale.getlanguage()); } } } } output: fr de

php - Openshift, 503 Service Unavailable. No server is available to handle this request -

Image
i have scalable php 5.4 cartridge on openshift, bronze account. it's wordpress blog , i've used until 2 weeks ago. today, returned visit , says: 503 service unavailable. no server available handle request. to check proxy status, have visited link http://myapp-mydomain.rhcloud.com/haproxy-status , there see this: it seems down. checking logs rhc tail see line: ==> app-root/logs/haproxy.log <== [alert] 077/194638 (138628) : proxy 'express' has no server available! [warning] 086/161237 (138628) : server express/local-gear down maintenance. [warning] 086/161239 (33522) : config : log format ignored proxy 'stats' since has no log address. [warning] 086/161239 (33522) : config : log format ignored proxy 'express' since has no log address. [warning] 086/161239 (33522) : server express/local-gear down, reason: layer7 wrong status, code: 500, info: "http status check returned code <3c>500<3e>", check duration

bash redirect stderr for time command? -

an application stderr being run using time command. want output of application redirected /dev/null, stderr redirected log, , timing redirected log. executing command: time cmd args >/dev/null 2>log redirects cmd, not time command timings. if goal capture time output log file, use: { time seq 1000 >/dev/null; } 2>log

PHP Register didnt working -

hi created php register page site,and page didint work corectly.i dnt have db erorr cant create new user. first time when create new user in db,there new user withuot username , password. <?php if(isset($_post['submit'])){ $con = mysql_connect('fdb13.biz.nf','xxx','yyy'); mysql_select_db('1846946_chat',$con); $uname1= $post['username']; $pword1= $post['password']; $pword2= $post['password2']; if($pword1 != $pword2){ echo "pasvordi se ne poklapaju!<br>"; } else{ $result = mysql_query("select username korisnici username='$uname1'"); if(mysql_num_rows($result)) echo "username vec postoji,izaberi drgaciji<br>"; else{ mysql_query("insert korisnici (username,password) values ('$uname1','$pword1')"); echo "uspesno si se registroavao.klikni <a href='index.php'>ovde</a> da zapocnes chat!<br>"; } } } ?> <

java - Passing value to servlet from image -

from jsp have .. <form action="testmartcontroller" method="post"> <input type="hidden" value="math"> <input type="image" src="<%=request.getcontextpath()%>/css/categories/math.jpg"> </form> .. in servlet have ... private static final string math = "web-inf/jsp/math.jsp"; protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { string forward = null; string action=request.getparameter("action"); if(action.equals("math")){ forward = math; flag = 1; } requestdispatcher rd = request.getrequestdispatcher(forward); rd.forward(request, response); } ... when clicked image got null pointer exception. want know why not pass value should. since hidden values pass. your input type="hidden" field missing name="action&

Twilio Client hold -

i working node.js , twilio client. i able place call on hold , retrieve it, however, if wait 6 seconds call disconnect once put in hold enqueue. if try disconnect softphone once caller in hold queue disconnects caller too. function holdcall(){ console.log(callstatus); //i passing agents name, , current call status boolean end modify call in hold enqueue socket.emit('holdcall', {agent: '{{client}}', status: callstatus}); //if call on hold returns true , connect agent custom queue if(callstatus){ params = {"phonenumber": $("#number").val(), "state": "{{client}}"}; call = twilio.device.connect(params); //if call not on hold want twilio client disconnect call can taken off hold. }else{ console.log(call); call.disconnect(); } //switch call status callstatus = !callstatus; } if there better day can modify live call hook client has not disconnected lov

ruby on rails - How to use private submit to hide from profile? -

when user submits via private how can hide submitted info feed , other users being able see on public profile? <%= button_tag(type: 'submit', class: "btn") %> ... <%= button_tag(type: 'submit', class: "btn", id: "2", name: 'private') %> ... we put below in controller, since private button in lot of different _forms, have put in each controller or can put in application controller? if params[:private] # private action / need put here? else # normal submit / , here? i followed railcast episode t build activity feed: http://railscasts.com/episodes/406-public-activity . here 's code public profile: users_controller.rb def show @user = user.find(params[:id]) @habits = @user.habits @valuations = @user.valuations @accomplished_goals = @user.goals.accomplished @unaccomplished_goals = @user.goals.unaccomplished @averaged_quantifieds = @user.quantifieds.averaged @instance_quant