Posts

Showing posts from February, 2014

Android - getSupportFragmentManager returns null -

i trying specific instance of fragment using it's tag, using viewpager, makes things difficult. used: public fragment getfragmentbyposition(int pos) { string tag = "android:switcher:" + r.id.pager + ":" + pos; fragmentmanager fragmentmanager = this.getsupportfragmentmanager(); fragment fragment = fragmentmanager.findfragmentbytag(tag); return fragment; } to find fragment, getsupportfragmentmanager returning null. the above method in activity, outside of viewpager adapter class, , lost here. highly appreciated, thanks! you can use smartviewpager here https://gist.github.com/jacek-marchwicki/d6320ba9a910c514424d extend view pager class , fragment using getactivefragment method. can change implementation of method fragment tag name. public fragment getactivefragment(string name) { final fragment fragmentbytag = fragmentmanager.findfragmentbytag(name); if (fragmentbytag == null) { final bytearrayoutputstream out

Doubts about top level class acess modifiers in Java -

i have doubts access modifiers used top level classes in java. 1) can access modifier public or default used top level classes or nested classes? 2) lets there 2 different classes , b, both in different packages. in order have access (acess class members) class class b , both top level class, ‘a’ class members should defined public, right ? if either class or class members not public class b not have access class a, right ? please correct if i'm wrong. 1) nested classes can have same access modifiers top level classes. 2) in order access class class b, needs public. class b may package private (default). b can access methods of if a's methods public (if b not inherit a). if class package private, doesn't matter if contains public methods - won't accessible b. see oracle docs , this stackoverflow thread .

android - How to generate multiple buttons that have the same intent but have another Extra -

im trying generate multiple views in eclipse layoutinflater. button has onclicklistener , works. intent starts , give extra. but want button keeps own extras. saying first button has extra: number 1 second has 2 , on. @ moment al buttons same extra, number 5. because when try intent in com.example.http wizard says 5 string[] title = { "1", "2", "3", "4", "5" }; layoutinflater layoutinflator = (layoutinflater) getapplicationcontext().getsystemservice(context.layout_inflater_service); linearlayout insertpoint = (linearlayout) findviewbyid(r.id.ll_content); list<view> views = new arraylist<view>(); for(int i=0; i<title.length; i++){ view view = layoutinflator.inflate(r.layout.single_task, null); textview textview = (textview) view.findviewbyid(r.id.tvname); button bstartwizard = (button) view.findviewbyid(r.id.bstartwizard); textview.settext("opdrac

c++ - SDL_mixer wont play sound Raspberry Pi -

i can't sdl_mixer play sound on raspberry. program compiles , builds ok, hear short squeak (like static) , nothing. any ideas? #include <sdl/sdl.h> #include <sdl/sdl_mixer.h> #include <stdio.h> #include <string> #include <iostream> int main() { mix_chunk *snd1 = null; mix_music *m = null; if(sdl_init(sdl_init_video | sdl_init_audio) < 0) { std::cout << "something went wrong"; } if(mix_openaudio(44100, mix_default_format, 2, 1024) < 0) { std::cout << "kunne ikke loade musikk"; } snd1 = mix_loadwav("bicycle_bell.wav"); if(snd1 == null) { std::cout << "fant ikke filen"; } mix_playchannel(-1, snd1, 0); mix_freechunk(snd1); mix_quit(); return 1; } solved it. program terminated before sound playing. when testing simple: while(mix_playing(sound)); fixed it.

c++ - menu callback in not called -

i want add couple of buttons - "settings" , "restart" scene, placed above everything. below [in init()]: auto settingsmenu = menuitemimage::create("settings_gold@2x.png", "settings_white@2x.png", cc_callback_1(gamelevellayer::settingsbuttontapped, this)); settingsmenu->setposition(point(440, 280)); this->addchild(settingsmenu); i add touch handler process game "actions," below: // handle user touches auto dispatcher = director::getinstance()->geteventdispatcher(); auto listener = eventlistenertouchonebyone::create(); listener->ontouchbegan = cc_callback_2(gamelevellayer::ontouchbegan, this); listener->ontouchended = cc_callback_2(gamelevellayer::ontouchended, this); dispatcher->addeventlistenerwithscenegraphpriority(listener, this); my ontouchbegan() , ontouchended() called fine, settingsbuttontapped() never called, touch handler apparently swallows everything. how should processed in cocos2d-x 3.x, click

javascript - How can I select using jQuery 'select' tag with determined selected option? -

for instance, <div id="wrapper"> <select> <option value="en" selected="selected">english</option> <option value="ar">العربية</option> <option value="az">azərbaycanlı</option> <option value="bg">български</option> <option value="ca">català</option> <option value="cs">český</option> <!-- data cut --> </select> <select> <option value="en" >english</option> <option value="ar">العربية</option> <option value="az" selected="selected">azərbaycanlı</option> <option value="bg">български</option> <option value="ca">català</option> <option value="cs">český</option>

Unable to connect mysql via django -

i know old question on lots of forums answers suggesting flush privileges , reset passwords in case no answer has worked. here's scenario: i able connect mysql via following command mysql -u root -p -hlocalhost i able connect via python using following script import mysqldb con = mysqldb.connect(host="127.0.0.1", port=3306, user="root", passwd="mypass", db="mydb") cursor = con.cursor() sql = "select * test" cursor.execute(sql) #### gives 1l but unable connect via django. django settings.py contains databases = { 'default': { 'engine': 'django.db.backends.mysql', 'name': 'mydb', 'user': 'root', 'passwd': 'mypass', 'host': 'localhost', 'port': '3306', } } following main error django.db.utils.operationalerror: (1045, "access denied user 'root

java - Global Variables in spring mvc -

i have created spring mvc web application. menus database i.e stored in databases. whenever call index.jsp home page different browser, menu items retrieved every time database. how can stored menu items in global variable can accessed anytime without hitting database again or until restart server. you requirement can sufficed in 2 ways: server cache: use open source server cache library ehcache lets store data (you app data or data retrieved database or data received 3rd party app call) in server memory. idea instead of performing same 3rd party call expected give same result, once , store in server cache . ehcache works spring framework, , in fact use ehcache server side caching our enterprise application based on spring framework. browser database storage: html5 provide indexeddb api lets store data in browser database. so, can retrieve data server once , store in local database, whenever need data can first check if present in local database or not, if not r

image - How to send a shape object from Excel in the body of an Email? -

i'm struggling 1 (seemingly) simple step in macro i'm trying write. have excel shape object i'm trying copy paste outlook mail item. shape object product of using excel's "camera tool." did created chart need flip 90 degrees viewing. camera tool makes simple. problem have pasting picture shape outlook item. suggestions? here's code far: sub emailer() dim wb workbook dim ws worksheet dim p shape dim o outlook.application dim om outlook.mailitem dim rec outlook.recipient dim recs outlook.recipients 'create outlook session set o = createobject("outlook.application") 'create message set om = o.createitem(olmailitem) set recs = om.recipients set rec = recs.add("email@email.com") rec.type = 1 set wb = activeworkbook set ws = activeworkbook.worksheets("chart_pic") set p = ws.shapes("picture 2") p.copypicture om .sentonbehalfofname = "email@email.com" .subject = "subject" .htmlbody =

javascript - How do I append text to many user inputs within the same html class? -

i have html form, has many inputs within same html class. when user presses submit button, need every input field submit whatever user wrote in them, , specific string. if user puts word "cat" in text box, form submit "catptq". have function sort of accomplishes this, instead of retaining user input, uses first instance of input in class. function have looks this. $(function () { $('#question_entry_submit_button').on('click', function () { var text = $('.ptq'); text.val(text.val() + 'ptq'); }); }); this loop through html class of '.ptq' , append "ptq" end of user input, no matter user inputs second input box , onward, submits first user input + 'ptq' in place of actual user input + 'ptq'. i think makes sense, can try , clarify if needed. try use .val() 's callback function, text.val(function(_,val){ return

c# - Why is my query string so long? -

i using mvc 5, , got following message: "the request filtering module configured deny request query string long." why query string long? notice how repeats same information over-and-over. trying default [authorize] using global filtering, haven't altered in web.config...what cause this? query string loks like: localhost:80/yourapplication/account/login?returnurl=%2fyourapplication%2faccount%2flogin%3freturnurl%3d%252fyourapplication%252faccount%252flogin%253freturnurl%253d%25252fyourapplication%25252faccount%25252flogin%25253freturnurl%25253d%2525252fyourapplication%2525252faccount%2525252flogin%2525253freturnurl%2525253d%252525252fyourapplication%252525252faccount%252525252flogin%252525253freturnurl%252525253d%25252525252fyourapplication%25252525252faccount%25252525252flogin%25252525253freturnurl%25252525253d%2525252525252fyourapplication%2525252525252faccount%2525252525252flogin%2525252525253freturnurl%2525252525253d%252525252525252fyourapplication%252525252

ios - xcode - how do i get all font on a view to scale depending on device? -

Image
i trying constraints correct font size scales depending on device. seems when vertical size of uilabel shrinks scaling not happen. scaling happens when horizontal size changes. have tried fixing aspect ratio text not fit in screen vertically in case. i text centered in gray container , scale according width of container. this trying accomplish: here xcode file trying modify - https://www.dropbox.com/sh/c1yx8gk2h8d1ycg/aacnsxuq2j3eiycnsmhjiqxba?dl=0 my suggestion: create custom uilabel, uibutton, uitextfield subclasses project. in classes, can adjust font size on initialise. use custom classes in storyboard/xib/code instead of standard. for example uilabel - (void)awakefromnib { [super awakefromnib]; cgfloat fontsizemultiplier = 1; if (isphone5) { fontsizemultiplier = 1.1; } else if (isphone6) { fontsizemultiplier = 1.2; } else if (isphone6plus) { fontsizemultiplier = 1.35; } self.font = [uifont fontwithnam

visual studio 2015 - VS2015: Prevent download of dynamically generated JavaScript reference by "JavaScript Language Service" -

Image
please see below image.. note timestamps -- computer not activity. problem seems happen whenever have *.js or *.cshtml file open. i have turned off "download remote references (e.g. http://) files in miscellaneous files project" in javascript -> intellisense -> general, problem continues. i tried moving inclusion of "doorbell.io.js" bundle rather _layout.cshtml file, didn't work. how can prevent vs downloading javascript reference? to fix immediate issue remove offending line "_references.js". save. problem should stop immediately. /// <reference path="doorbell.io.js" /> future considerations... note default references set auto-sync. means if ever refresh sources, such nuget or adding javascript file manually, offending file added in. can disable functionality right-clicking inside file , unselecting auto-sync javascript references if decide disable feature, can still manually update them u

Why super.onDestroy() in java - Android goes on top in destructors? -

this question has answer here: what correct order of calling superclass methods in onpause, onstop , ondestroy methods? , why? 7 answers i new in java development! may tell me... according logic super.ondestroy(); in destructors goes on top? example: protected void ondestroy() { super.ondestroy(); releasemediaplayer(); } and not protected void ondestroy() { releasemediaplayer(); super.ondestroy(); } like c++, obj-c, pascal, etc ?? it depends on want in ondestroy . super.ondestroy (in order): dismiss dialogs activity managing. close cursors activity managing. close open search dialog if logic put inside ondestroy has 3 things android does, may have worry order. otherwise, , in of cases, not matter.

pyinstaller - python executables alarms antivirus -

i made simple gui (wxpython) application (some static text, buttons, comboboxes etc) , made exe file pyinstaller, avast antivirus says it's virus. how can fix this? send exe file avast analysis: report virus if you’ve encountered suspicious file or received think false-positive virus alert , please contact our virus lab analysis. there bug report pyinstaller this. bug supposedly fixed 13 months ago. perhaps should reopen it.

android studio Execution failed for task ':app:mergeDebugResources' -

i decompiled app using online tool (www.decompileandroid.com) then, after downloaded zipped source code (assets + java code), extracted in folder , imported folder in android studio (file>new>import project). then, without editing file, tried run project got error: error: found item ###/item-name more 1 time error:execution failed task ':app:mergedebugresources'. > c:\users\fabrizio\androidstudioprojects\com.hwlogos.ytstars\app\src\main\res\values\public.xml: error: found item ###/item.name more 1 time i searched web hours can't find useful answer... please help! ps: tried other applications same error... update: now tried decompile simple app created android studio , when reimported in android studio got same error. seems there 2 resources same name, 1 declared string , other id. here's part of public.xml, never wrote when made application!!! <public type="string" name="action_settings" id="0x7f070006" /&g

c# - Add new input text and save data in database -

i need create dynamic form. user can add new input box form , define if gonna used text, number or date, can add n input box how can create dynamic forms , save data in database , best way save data in sql server table? thanks what you're trying achieve form designer. can done simple student project, large framework supporting lots of features. a lot of convenience tools asp.net mvc provides not useful , need lower-level handle this. also, lots of architecture decisions arise, , making wrong decision in each step can lead useless product. exmaple: going store user data in single table, or you'll create database tables match user designs? are going allow inter-field relationships: field b invisible/disabled unless fill field b. what i'm trying deeper can covered in answer.

any rails command not doing anything freezing up/hanging up(rvm related?) -

i trying debugg few things , copying , pasting bunch of commands , think 1 of them did rvm or installed rbnv accident. now when trying run console stays frozen , doesnt no matter how long wait. when exit process see following output: $ rails c ^c/users/c5227806/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/client/run.rb:98:in `gets': interrupt /users/c5227806/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/client/run.rb:98:in `verify_server_version' /users/c5227806/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/client/run.rb:56:in `run' /users/c5227806/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/client/run.rb:37:in `warm_run' /users/c5227806/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/client/run.rb:26:in `call' /users/c5227806/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/client/command.rb:7:in `call' /users/c5227806/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/client/rails.rb:24:in `call' /us

java - How can I check if one value is A or B and another value is A or B? -

i'm trying effect of: if (firstchoice == || b && secondchoice == || b){ //passes check. } logically, want pass if first , second choice either or b. syntax valid? there better way it? you can't == || b ; can (but shouldn't, see below): if ((firstchoice == || firstchoice == b) && (secondchoice == || secondchoice == b)) { that's readable you're going it. breaking on line makes easier follow logic; horizontal scrolling bad thing, , breaking @ && operator readable way. however, there's way make more readable: create helper method, want. private boolean isaorb(yourobject choice) { return choice == || choice == b; } then if statement be: if(isaorb(firstchoice) && isaorb(secondchoice)) { this more readable future readers, including yourself, you're going here.

unity3d - admob ads not shown in android game made by unity -

anyone me in integrating admob ads android game ? from unity editor console see ads created , requested , shown , works 100% not shown in android device .. why using unityengine; using googlemobileads.api; public class ads : monobehaviour { bool called = false; void start() { if (application.loadedlevelname == "gameplay") { interesrequest(called); } if (application.loadedlevelname == "mainmenu") { bannerrequest(); } if (application.loadedlevelname == "levelscore") { } } void bannerrequest() { bannerview bannerview = new bannerview("ca-app-pub-5443208681329246/6087569010", adsize.banner, adposition.bottom); adrequest request = new adrequest.builder().build(); bannerview.loadad(request); bannerview.show(); } void interesrequest(bool call) { interstitialad inters = new interstitialad("ca-app-pub-5443208681329246/7564302219"); if (call) { if (i

ios - How to add images into placeholder in xcode? -

currently working in swift xcode want add, example, image icon placeholder position text field. many modern ui designs feature on log in/log out pages. how able implement this? you can add uibutton using interface builder , have both image , text 1 object. simply drag , drop uibutton object library panel uiviewcontroller . check attributes inspector , set image property image you've added project either using assets catalog or image you've added project library. set title property text wish display. can select image in edge dropdown property , adjust position of image relative text.

C++ How do I print elements of an array but leave out repeats? -

my assignment have user type in how many elements in array enter integer number put in array. have sort through array , find largest number , print out elements of array if there repeat print number 1 time. have print out number of times each element in array occurs. example if user types in there 5 elements enters 2, 1, 2, -3, 2 should print -3 1 count, 1 1 count, , 2 3 count. far have print out elements , delete repeats cant print out correct number of occurrences each element. code far. void findrepeats(int numbers[], int num) { int instances = 0; cout << "number" << " " << "occurrences" << endl; (int = 0; < num; i++) { bool matching = false; instances = 1; (int j = 0; (j < i); j++) { if (numbers[i] == numbers[j])

Add a copy to clipboard button in a GitHub readme -

i writing readme.md in github flavored markdown, i'll push on github repository. there way add copy-to-clipboard button each code snippet readme.md contains, when viewing on https://github.com/username/reponame/readme.me ? i created chrome extension copy posted source code readme files. works on: github stackoverflow npmjs check repository: https://github.com/panzerdp/clipboardy

javascript - How to exit properly from node.js -

the following read , import many csv files disk mongodb nodejs won't exit after importing files if doesn't go through resizephoto() function (which contains process.exit after resizing images). how can have close after importing files without interrupting? if add process.exit .on end exit after importing first file. var importdata = function(filename) { // file disk. var filepath = path.join(folder, filename); // read , import csv file. csv.frompath(filepath, { objectmode: true, headers: keys }) .on('data', function (data) { var obj = new models[filename](data); models[filename].find({}).remove().exec(); obj.save(function (err, importedobj) { if (err) { console.log(filename, err); } else if (filename === 'photos') { resizephoto(importedobj); } }); }) .on('end', function() { console.log(f

C++ Compilation error - Undefined reference -

i'm having bit of trouble trying compile following simple code in cygwin: main.cpp: #include <iostream> #include "point.h" using namespace std; int main() { point a; return 0; } point.cpp: #include <iostream> #include "point.h" using namespace std; point::point() { cout << "compile test" << endl; } point.h: #ifndef point_h #define point_h class point { public: point(); }; #endif make file: cc=g++ cflags=-c -wall ldflags= sources=main.cpp point.cpp objects=$(sources:.cpp=.o) executable=test all: $(sources) $(executable) $(executable): $(objects) $(cc) $(ldflags) $(objects) -o $@ %.o : %.cpp $(cc) $(cflags) -c $< clean: rm -rf *.o core when try compile main.cpp, i'm getting following error: main.o:main.cpp:(.text+0x15): undefined reference `point::point()' main.o:main.cpp:(.text+0x15): relocation truncated fit: r_x86_64_pc32 against undefined symbol `

mysql - How to replace html symbols via sql query on php -

i have situation have custom field html symbol ( &#8218; ). when try replace equivalent (,) cannot it... i'm using sql query: $wpdb->query ("update $wpdb->postmeta set `meta_value` = replace(`meta_value`, \'%&#8218; %\') `meta_value` '‚'"); what doing wrong? to convert &#8218; comma, use replace below: select replace(meta_value, '&#8218;', ',') your_table meta_value ',' shown select statement testing, actual update: update set your_table set meta_value = replace(meta_value, '&#8218;', ',') meta_value ','

osx - How to create an event loop in Objective C? -

i'm trying use corebluetooth module list detected bluetooth devices in command-line osx application. what have looks this, far: @import corebluetooth; @interface mycentralmanager : nsobject<cbcentralmanagerdelegate> - (void) centralmanagerdidupdatestate: (cbcentralmanager *) central; - (void) centralmanager:(cbcentralmanager *) central diddiscoverperipheral:(cbperipheral *) peripheral advertisementdata:(nsdictionary *) advertisementdata rssi:(nsnumber *)rssi; @end @implementation mycentralmanager - (void) centralmanagerdidupdatestate: (cbcentralmanager *) central { nslog(@"state changed..."); } - (void) centralmanager:(cbcentralmanager *) central diddiscoverperipheral:(cbperipheral *) peripheral advertisementdata:(nsdictionary *) advertisementdata rssi:(nsnumber *)rssi { nslog(@"discovered %@", peripheral.name); } @end int main() { mycentralmanager* mycentralmanager

php - How to make Compact code Laravel 5 Eloquent Relationships -

i have not simple code on controller : namespace app\http\controllers; use illuminate\http\request; use app\user; use app\userdetail; use app\usersex; use app\province; use app\http\requests; use app\http\controllers\controller; class usercontroller extends controller { ... public function show($id) { // $user = user::find($id); $userdetail = user::find($id)->userdetail; $usersex = user::find($id)->usersex; $province = user::find($id)->province; return view('users.show', compact('userdetail', 'user', 'usersex', 'province')); } ... this code on 1 of model : namespace app; use illuminate\auth\authenticatable; use illuminate\database\eloquent\model; use illuminate\auth\passwords\canresetpassword; use illuminate\contracts\auth\authenticatable authenticatablecontract; use illuminate\contracts\auth\canresetpassword canresetpasswordcontract; class user extends model implements

c++ - How to publish asynchronously with HiRedis -

i using hiredis c/c++ program , have written tests verify subscriptions work (i based solution on this comment ). however, can publish manually typing publish foo "abcd" redis-cli terminal. works per linked comment, i'd publish from c++ program. how can this? i have tried command: redisasynccommand(c, subcallback, (char*)"command", "publish foo \"abcd\""); but results in runtime error: error: err (p)subscribe / (p)unsubscribe / quit allowed in context how can publish data within hiredis? from https://github.com/redis/hiredis in hiredis/examples/example-libevent.c : #include <stdio.h> #include <stdlib.h> #include <string.h> #include <signal.h> #include <hiredis.h> #include <async.h> #include <adapters/libevent.h> void getcallback(redisasynccontext *c, void *r, void *privdata) { redisreply *reply = r; if (reply == null) return; printf("argv[%s]: %s\n

multithreading - What is most efficient Python IPC mechanism for plotting real-time serial data? -

Image
what fastest python mechanism getting data read off of serial port, separate process plotting data? i plotting eeg data in real-time read off of serial port. serial port reading , packet unpacking code works fine, in if read , store data, later plot stored data, looks great. this: note: device generates test sine wave debugging i using pyqtgraph plotting. updating plot in same process read serial data in not option because slight delay between serial read() calls causes serial buffer overflow , bad check-sums ensue. pyqtgraph has provisions rendering graph on separate process, great, bottle-neck seems in inter-process communication. have tried various configuration of pipe() , queue(), of result in laggy, flickering graph updates. far, smoothest, consistent method of getting new values serial port graph seems through shared memory, so: from pyqtgraph.qt import qtgui import pyqtgraph pg multiprocessing import process, array, value, pipe serial_interface import eeg64board c

c - Why doesn't the last line of the child process print? -

#include <stdlib.h> #include <sys/wait.h> #include <unistd.h> #include <stdio.h> int main( ) { pid_t pid; int status = -1; if ((pid = fork()) != 0) { printf("father process wait child pid=%d\n", pid); wait(&status); printf("child finish status: %d\n",wexitstatus(status)); exit(0); } else { printf("child process running...\n"); execl("/bin/ls","ls", "-la", null); printf("child ending...\n"); } } when compiling code last line of else doesn't print , don't know why. http://linux.die.net/man/3/execl the exec() family of functions replaces current process image new process image. .... return value the exec() functions return if error has occurred. return value -1, , errno set indicate error.

javascript - How to alert the value using $this in jquery? -

i have code , want alert value of "first div" when click button on first object , "second div" when click button on 2nd object. . how ? :) $(document).ready(function(e) { $('.clickme').click(function() { var selected = $(this).closest('.rel-wrap').find('.my-div').text; alert(selected); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script> <div class="main-wrapper"> <div class="rel-wrap"> <input type="button" class="clickme" value="click me"> <div class="my-div"> first div </div> </div> <div class="rel-wrap"> <input type="button" class="clickme" value="click me"> <div class="my-div"> second div </div> </div>

java - Libgdx game Runs perfect in Eclipse, doesn't even open when Exported -

i creating game in java, using libgdx. worked fine when compiled until added layers tiled map. still runs fine when ran eclipse when compile runnable jar, not open. commented out layers , ran perfect again, have no idea causing issue. here stack: exception in thread "lwjgl application" java.lang.nullpointerexception @ com.mygdx.game.game_screen.render(game_screen.java:181) @ com.badlogic.gdx.game.render(game.java:46) @ com.badlogic.gdx.backends.lwjgl.lwjglapplication.mainloop(lwjglapplication.java:‌​215) @ com.badlogic.gdx.backends.lwjgl.lwjglapplication$1.run(lwjglapplication.java:120‌​) and here code: package com.mygdx.game; import com.badlogic.gdx.gdx; import com.badlogic.gdx.input; import com.badlogic.gdx.screen; import com.badlogic.gdx.graphics.gl20; import com.badlogic.gdx.graphics.orthographiccamera; import com.badlogic.gdx.graphics.texture; import com.badlogic.gdx.graphics.g2d.animation; import com.badlogic.gdx.graphics.g2d.spritebatch; import com.badlogi

regex - How can I collapse multiple whitespace lines with vim? -

the question , answers here cover in detail how following vim command collapses series of empty lines single line: :g/^$/,/./-j however, want same treat lines onlywhite space in them blank. following command tried doesn't work: :g/^\s*$/,/./-j as far can tell, should find lines empty , have whitespace on them, not lines being collapsed. you're halfway there. remember initial command consisted of search part , action part. search part :g/^$/ found empty lines , action part ,/./-j executed each (well, each hadn't been deleted previous j ). the modification made search part of string correct in find lines either empty or contain whitespace. however, it's action you're executing after that's causing grief. original action executed on found line ,/./-j means execute join j on range line 1 before next 'real' character. more detail on how works can found in question linked to. the first 'real' character finds in case

android - Offer free features to earlier buyers -

i have paid app in google play store. i'm considering reducing price of app (somewhat; not way free) , offering 1 of features separate in-app purchase. if did that, wouldn't want yank feature away who's bought it. is there way figure out either date user bought app, or original version of app bought, or that? i'd like, "if app before price change (either date or version), should have feature free; otherwise, require iap unlock feature." for example, ios have feature this; app receipt includes "originalversion" field can used control access features. unfortunately customers, impossible. there no api call or else google play can time on app bought. i know there android-publisher api in existance, doesn't offer feature check that. the functions want use not public availible , used playstore internally! workarounds do: 1. time app installed on first start check , unlock features. warning : system abused

c# - Adding a `-` to a string once at 8 chars, then again at 4? -

i've been trying past hour , it's driving me insane. trying minecraft uuid proper formatting (with dashes), api use gives in regular format. what have: 7a4730f8f948471dbc77f6f71a250f87 proper format: 7a4730f8-f948-471d-bc77-f6f71a250f87 how go formatting string this? the .net framework has guid class . can invoke constructor , use .tostring() above described format. instance: csharp> new guid("7a4730f8f948471dbc77f6f71a250f87") 7a4730f8-f948-471d-bc77-f6f71a250f87 csharp> new guid("7a4730f8f948471dbc77f6f71a250f87").tostring() "7a4730f8-f948-471d-bc77-f6f71a250f87" in case process uuids internally, advice use guid class instead of string: since can compare 2 guids, etc. furthermore expect there less bugs in .net framework in code created users (not because less competent, because number of users of .net framework large, bugs spotted , solved).

osgi - upgrade kura installation without losing configuration -

i'm running kura 1.1.1 on beagle bone black running debian linux custom packages , altered configuration. i upgrade latest kura release without losing configuration , packages. how upgrade while maintaining state of kura installation? afaik there not official way yet. can backup following files , include them again after upgrading: data/snapshots/snapshot_14xxx.xml file containing bundles' configuration. recent changes have higher timestamp. kura/dpa.properties files contains list of deployed deployment packages , installed through web-ui or deploy-v1 cloudlet. *.dp actual deployment packages installed. if manually added jars or edited start scripts, must copy/edit them again depending on how upgrade, may or may not have previous installation deleted. shell script installer example changes /opt/eclipse/kura/ symlink version installs, without deleting old one.

javascript - How to get number of elements with certain class that occur before current element in a table? -

i trying index tr of table class slot , slineitem lineitem comes under lot in hierarchy. <table style="width:100%;" id="summarytable"> <tr class="slot"> <td>lot1</td> </tr> <tr class="slineitem"> <td>lineitem1</td> </tr> <tr class="slot"> <td>lot2</td> </tr> </table> i want : 1 lot1 lot1 desc 1.1 lineitem1 2 lot2 2.1 lineitem1 under lot2 assume, using table option. i think work //add column rows $('tr').prepend($('<td />', { class: 'srno' })); $('.slot').each(function(i, el) { //get index of current slot element var index = + 1; //set current slot rows index text $(el).find('.srno').text(index); //find rows in between , next slot .slinei

Latency and Security in using Apigee Cloud -

i new apigee, , started using apigee edge cloud solution. need know answers. helpful me. what latency in using apigee cloud instead of on premise solution. know downtime percentage if using apigee server dependent on them. apigee provided me organiztion account having username , password, there other authtication though apigee recognizes request coming account ony, , same goes response, asking these can hack url , send same request. as our api's containing data financial transaction, bit worried keeping data on cloud , passing through apigee server. kind of security there on cloud? thanks in advance , kindly dont mind if quesitions basic. cross posting apigee community , latency depends on several things, region, complexity, load , many more, applicable both on-prem , cloud. have seen several apigee customers both in cloud , on-prem having apigee added latency of few milliseconds few hundred milliseconds. hard tell number, news apigee provides tools understa

ruby - Sort hash by nested value -

my hash looks below. want output in same hash form hash arranged according price. { 1=>{ "name"=>"mark", "date"=>"27/08/2015", "bed"=>"3", "furnish"=>"fully", "size"=>"10", "price"=>790000 }, 2=>{ "name"=>"mark", "date"=>"27/08/2015", "bed"=>"3", "furnish"=>"fully", "size"=>"10", "price"=>720000 }, 3=>{ "name"=>"mark", "date"=>"27/08/2015", "bed"=>"3", "furnish"=>"fully", "size"=>"10", "price"=>750000 }, 4=>{ "name"=>"mark", "date"=>"27/08/

How in android we can play audio one after another? -

sorry english. i'm writting android background service app. app electronic voice queue in bank. need play audio files 1 one in right order. example create container audio-files names example: string music_names[] = {one.wav, two.wav, three.wav, four.wav, five.wav}; how can play files raw directory example, or other place? how can play in right order 1 one delay 1 second? you have set oncompletionlistener each , start next 1 on completion. mediaplayer.setoncompletionlistener(new mediaplayer.oncompletionlistener() { @override public void oncompletion(mediaplayer mp) { // code start next audio in sequence } }); the best way achieve create class implements oncompletionlistener handles oncompletion , receives next file play. way can instantiate nicely in code. of course, don't forget break; in cases above. thanks

cancan - Rails, Devise, Role Model and CanCanCan - defining abilities -

i using rails 4 make web app. i trying use cancancan define abilities various roles. i have user model , profile model. each user can have many profiles. each profile can have different role. in profile.rb, have defined roles (using role model gem) as: include rolemodel roles :admin, :manager, # coalfacer :student, :educator, :researcher, :ktp, :faculty_manager, :ip_asset_manager, # universities :sponsor, # industry :project_manager, :representative, # both uni , industry :grantor, :investor, :adviser, :innovation_consultant, :panel_member, # external :participant, :guest # public roles_attribute :roles_mask in ability.rb, trying define first ability, as: user ||= user.new # guest user (not logged in) #users not signed in can read publicly available projects can :read, project, {:active => true, :closed => false, && project.sweep.disclosure.allusers: true} in projects table, have boolean a