Posts

Showing posts from August, 2014

data modeling - Represent a many to many relationship in sqlite -

i want represent many many relationship in relational model , i'm having doubts. create table tipodeseguro ( tiposeguro text not null, tipodeseguroid integer not null primary key ) ; create table cobertura ( nome text not null, coberturaid integer not null primary key ) ; these tables want join using many many relationship. create table jointipodesegurotocobertura ( coberturaid integer, tipodeseguroid integer ) ; this junction table. both of these tuples primary keys? should both reference main class? best regards they should foreign keys , not null if needed. create table jointipodesegurotocobertura ( coberturaid integer not null, tipodeseguroid integer not null, foreign key(coberturaid) references cobertura(coberturaid), foreign key(tipodeseguroid) references tipodeseguro(tipodeseguroid) );

ruby on rails - Simple form text input fields as part of an array -

so have 3 text input fields , each 1 represents co-ordinate , stored in array format [x, y, z] in model. i trying use input fields work produce array submitted form. code currently: =f.input_field :coordinates[0], value: "1" =f.input_field :coordinates[1], value: "2" =f.input_field :coordinates[2], value: "3" so hoping can use coordinates param in controller save database. issue setup html produced <input value="1" name="shape[o]" id="shape_o"> when should <input value="1" name="shape[coordinates][]" id="shape_coordinates_0"> n.b. have serialize :coordinates in model try set custom attributes directly this: = f.input_field :coordinates, input_html: { value: 1, id: "shape_coordinates_0", name: "shape[coordinates][]" } but suggest create attr_readers

svn - What file formats does Subversion Edge ViewVC support -

i've been looking around, , either don't understand answer given or i'm not asking right question. figure i'll open up. know viewvc plugin subversion edge. made email program hooks post-commit. @ first attached href @ end of each file added, modified, , deleted. of files don't work. if click on added , deleted says viewvc error. if click on file not supported viewvc diff error. plan this..easier show c# code. private string getlistelementbasedontype(string thetype, string element, int rev) { switch (thetype) { case "added": return string.format(""); //todo case "deleted": return ""; //todo case "modified": return string.format("<a href=\"{0}/viewvc/{1}/{2}?r1={3}&r2={4}&pathrev={3}&diff_format=h\">\t[view diff]</a>", repourl, this.reponame, element, rev, rev -

jquery - Wait Until Infinite Scroll Finishes Loading - Javascript -

i'm working "infinite scroll" page calls 40 elements @ time when user scrolls bottom of page. how detect moment @ content of recent set has been loaded? this works initial page load: $(window).load(function() { // }); is there similar when there's "load" long after page has been done loading? sorry if repeat of question. unable find solution anywhere else. after more digging around, i've used variation of question/answer . my end result looks this: function ($container, previouscount, callback) { var _imgs = $container.find('img'), _newimages = _imgs.slice(previouscount), // 'start index' new images imgcount = _newimages.length, // count how many new ones exist counter = 0; _imgs.on('load', function() { // count loaded runcallback(20, callback); }).on('error', function() { // count errors, anyway, reach total runcallback(20, callback); })

unix - subversion permissions on files in .svn -

i setting shared working copy web development. of users not unix/command line capable connecting working copy on webserver via samba , using tortoisesvn. have set default umask on bash , samba give read/write access user , group. i've made users default group "webteam" belong to. means file create writable them , other member of team. we using svn version 1.6 (as default on rhel). umask , group ownership stuff works fine, when run checkout: # svn co svn://scythia/www . if go directory files, first check permissions of .svn dir: drwxrwxr-x 6 geofa webteam 4096 jul 3 09:28 .svn that want. same goes sub directories. files wrong permissions: [geofa@scythia dac_property]$ ll .svn total 20 -r--r--r-- 1 geofa webteam 838 jul 3 09:28 entries drwxrwxr-x 2 geofa webteam 4096 jul 3 09:28 prop-base drwxrwxr-x 2 geofa webteam 4096 jul 3 09:28 props drwxrwxr-x 2 geofa webteam 4096 jul 3 09:28 text-base drwxrwxr-x 5 geofa webteam 4096 jul 3 09:28 tmp al

vaadin7 - vaadin TwinColSelect not side by side -

Image
for reason twincolselect not side side. see below: has seen before? have tried putting horizontallayout, etc. edit: here better example: it in formlayout, inside panel, if helps. matches examples have seen online. edit 2: overall structure ( mimics dashboard demo app!!! ): mainview - horizontallayout menu component content component ( verticalsplitpanel ) header - horizontallayout content, things go ( csslayout ) usersview ( verticallayout ) user header ( horizontallayout ) user list ( table ) userform ( panel ) form ( formlayout ) various data entry fields ( textfield, combobox, etc ) notifications selection ( twincolselect ) save button ( button ) edit 3: stated in comments, captions positioned. elements broken ui elements allow user interaction, arrow buttons , right selection box.

mc - How to open context menu in mcedit under ubuntu 16.04? -

can't open context menu mouse right click. worked fine in ubuntu 14.04. there way fix it? the solution easy holding shift key during right click. well, never required before 16.04.

javascript - WebSocket application doesn't work properly when deployed on Tomcat8 server -

the problem i'm trying run example minimal changes in source code: https://spring.io/guides/gs/messaging-stomp-websocket/ i have managed run using eclipse , maven, terminal window, again, maven. i've managed package .war file , run in terminal using java -jar myfile.war works expected in cases, i.e. localhost:8080 displays simple interface , connects , returns greeting in same window. problem comes when deploy .war file tomcat8 server have running on raspberrypi. in case, index.html displays, "connect" button nothing, leads me believe sort of javascript related issue. server works fine, btw, have other stuff deployed on it. things i've tried edited .war archive index.html , .js files outside web-inf directory, may accessible outside world. problem persists. changed script references .js files in index.html to <script src="http://cdn.sockjs.org/sockjs-0.3.4.js"></script> <script src="http://cdnjs.cloudflare.com/a

How to Get "Click URL" as a Google Tag Manager Trigger List Item -

Image
i following number of tutorials create gtm tag event click. in part of final setup process, need create trigger event clicks. all tutorials seeing show should able select click url in dropdown list, yet in browser not exist. see screen shot below. how can gtm give me click url option in selection list? make sure have enabled click url (and other useful) variables:

can't use HttpPost in Android Studio after successful Gradle sync -

Image
i'm trying use httppost did in past in android. realize has been removed recent android versions. following solutions on similar stackoverflow question, added gradle dependencies: compile 'org.apache.httpcomponents:httpcore:4.4.1' compile 'org.apache.httpcomponents:httpclient:4.5' after gradle sync complained of no errors, still cannot import httppost program. in fact, org.apache.http.client.methods package not resolve @ all. i tried apache httpclient website suggested, use instead in gradle dependencies: compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1' once again, sync went fine, , time package resolved, not httppost program. i'd grateful suggestions. just add line in build.gradle inside android plugin : uselibrary 'org.apache.http.legacy'

osx - SVN Update Error on Mac OS -

i trying update project in svn , getting following error: "unable connect repository ar url ‘svn+ssh://svn.abc.com/svn/project' better debug ssh connection problems, remove -q option ‘ssh’ in [tunnels] section of subversion configuration file." i using os x , configuration file located @ ~/.subversion went file , see rows in config file commented out !!! kindly me in resolving issue. in ~/.subversion/config have line in [tunnels] section: # ssh = $svn_ssh ssh -q this show default if ssh not defined. after line add: ssh = $svn_ssh ssh hth

ios - Call same method multiple times on different parts of array -

i have method can work array of maximum 100 objets. however have array more 100 objects, how call method multiple times work arrays have more 100 objets? let's have array of 264 objects. i call method 3 times so: [self dosomething:[arraywithmorethan100objects subarraywithrange:nsmakerange(0, 100)]; [self dosomething:[arraywithmorethan100objects subarraywithrange:nsmakerange(100, 100)]; [self dosomething:[arraywithmorethan100objects subarraywithrange:nsmakerange(200, 64)]; this works fine, don't know size of array method needs process calling manually wont work. how around this? thanks! use loop: nsinteger increment = 100; (nsinteger start = 0; start < arraywithmorethan100objects.count; start += increment) { nsinteger length = min(increment, arraywithmorethan100objects.count - start); nsrange range = nsmakerange(start, length); [self dosomething:[arraywithmorethan100objects subarraywithrange:range]; } the value of length set either

php - Laravel: Do multiple environments require multiple .env files? -

in laravel 4.x possible have development , production environment 1 configuration file. framework detect automatically should used according host. with laravel 5.x seems have take following approach: on local machine .env file in root directory "app_env=local" , other config stuff run locally. on server same thing "app_env=production" , related settings. so if deploy site, have watch don't overwrite .env file on server local version. is correct far or missing here? the main goal keep sensitive data out of version control , have in 1 place. following points , questions approach unclear: the creator of .env package recommends not use in production mode (source: https://github.com/vlucas/phpdotenv ). solution in laravel issue hard code every setting across framework , make sure .env file not deployed server (could huge security hole). if solution in point above used, how keep sensitive data out of version control? let's 2 different .env

c# - Parameterless Controller Constructor Autofac -

i'm having problems mvc4 project frustratingly works fine on 1 computer (vs 2012), not on other (vs 2010). (i hope conflicting vs versions aren't problem, project came vs2010 computer, did work on 2012, , i'm trying put on 2010.) i "make sure controller has parameterless public constructor" error think controller has default one: public class homecontroller : authorizedcontrollerbase { public viewresult index() { return view(); } } the code throws error in controllerfactory: public class controllerfactory : defaultcontrollerfactory { private readonly istateprovider _sessionstateprovider; public controllerfactory(istateprovider astateprovider) { _sessionstateprovider = astateprovider; } public override icontroller createcontroller (system.web.routing.requestcontext requestcontext, string controllername) { icontroller controller = base.createcontroller(requestcontext, controllername);

java - elasticsearch group by ID field and perform max on date field -

my index has data mentioned below. id version_number groupid indexdate 1 v1 1 2016-11-15t12:00:00 2 v1 2 2016-11-20t12:00:00 3 v2 2 2016-12-01t12:00:00 4 v1 3 2016-13-01t12:00:00 5 v1 4 2016-11-01t12:00:00 6 v2 4 2016-13-01t12:00:00 7 v1 5 2016-14-01t12:00:00 how can write elasticsearch query in java. if search date 2016-13-01t12:00:00 expect see latest version per groupid has indexdate less or equal date searched? output expected: id version_number groupid indexdate 1 v1 1 2016-13-01t12:00:00 2 v2 2 2016-11-20t12:00:00 6 v3 3 2016-10-01t12:00:00 7 v2 4 2016-10-01t12:00:00 i dont see max function on date field in elasticsearch achieve this. i first aggregate on version_number and use top_hits sub

AJAX requests made by another domain's javascript file -

have 2 visual studio's running on same computer following urls: http://localhost:47503 (web api, #1) http://localhost:12345 (client calls above web api, #2) client (#2) hard codes site #1's <script src="http://localhost:47503/file.js"></script> . inside file.js single function: function getdata() { $.ajax({ url: 'http://localhost:47503/api/autos', type: 'get', datatype: 'json', data: { "a": '_1', "b": 'test', "c": "val c" }, success: function (result) { alert("success"); } }); cross-origin request blocked: same origin policy disallows reading remote resource @ http://localhost:47503/api/autos?a=_1&b=test&c=value+c . (reason: cors header 'access-control-allow-origin' missing). thought since script loaded client #1, invoked client #2 hence bypassing same origin policy in way? script client #1 c

jFreeChart setLabelFont size not working in GroupedStackedBarRenderer -

Image
i'm using groupedstackedbarrenderer allow subcategory in chart. add subcategories , control font size of subcategory with: subcategoryaxis domainaxis = new subcategoryaxis(""); domainaxis.addsubcategory("skill 1"); domainaxis.addsubcategory(...) domainaxis.setsublabelfont(new font("tahoma", font.plain, 12)); but following line has no effect on major category itself, date labels: plot.setdomainaxis(domainaxis); font font3 = new font("dialog", font.plain, 16); domainaxis.setlabelfont(font3); on reflection realize need reference category domain axis rather subcategory. tried following: categoryplot catplot = (categoryplot) chart.getplot(); catplot.getdomainaxis().setlabelfont(new font("tahoma", font.plain, 20)); but still didn't work. here's chart: use setticklabelfont() change font tick labels. use derivefont() preserve existing font attributes. domainaxis.sett

xml - Curved edges on Activity android -

Image
i trying create pop-up window curved edges. saw there existing question similar year ago many answers tried out , none of solve problem @ hand. ultimately, creating activity have curved edges itself, however, there white background has corners beneath effect not work. additionally, trying display on other activity using intents creates whole new screen , blacks out space not taken activity. appreciate help, thank you. xml format: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <corners android:radius="25dp" /> <solid android:color="@color/greenyellow"/> </shape> java code initializing window: confirmlayout = (relativelayout) findviewbyid(r.id.confirm_window); getwindow().setlayout(width,height); confirmlayout.setgravity(relativelayout.center

postgresql - Load Postgres dump after docker-compose up -

i have dump.sql file load docker-compose. docker-compose.yml: services: postgres: environment: postgres_db: my_db_name postgres_user: my_name postgres_password: my_password build: context: . dockerfile: ./devops/db/dockerfile.db my dockerfile.db simple @ moment: from postgres maintainer me <me@me.me> copy ./devops/db ./devops/db workdir ./devops/db i run command psql my_db_name < dump.sql @ point. if run script dockerfile.db, issue script run after build before docker-compose up , , database not running yet. any idea how ? reading https://hub.docker.com/_/postgres/ , section 'extend image' explains .sql in /docker-entrypoint-initdb.d executed after build. i needed change dockerfile.db to: from postgres add ./devops/db/dummy_dump.sql /docker-entrypoint-initdb.d and works!

c# - Can I set an explicit task timeout for RabbitMQ consumer? -

i understand rabbitmq ack, default, re-queue message if detects consumer/worker has died. what situation consumer/worker still alive process has stalled out long , didn't ack? i set explicit time says if message has been dispatched consumer consumer has held message without ack long message gets re-queued. i recognize might result in messages getting processed in duplicate consequence of not bad delayed message delivery. can happen errant exception handling if swallowed, task terminates, , message never ack'd , never re-queued. timeout rabbitmq consumer explicitly set on consumer side. think clear mention - there must not automatic acks in case. solution consumer multithreaded 1 thread doing message processing , acking message after has been processed, , other thread being timeout thread would: terminate connection broker once timeout has expired, , consequence message requeued ack received message , re-publish (explicitly) nack received message, based o

java - Refactoring to expose private methods for unit testing -

i have class process string , many actions on turn turn. those actions need done in specific order. example: public string process(string stringtoprocess) throws exception { processedstring = process1(processedstring); processedstring = process2(processedstring); processedstring = process3(processedstring); processedstring = process4(processedstring); ... processedstring = process10(processedstring); ... return processedstring; } i'm sure there better way refactor make cleaner, of all, want able unit test process1, process2 etc. note process1, 2 etc... can whether 2 line methods or big ones. i need process methods somehow public test them. there design pattern achieve this? i thought using enums achieve this, thought somehow making more confusing. implementation not best sure, @ 1 glance, know what's happening. edit : approach not bad me, process methods should private. , want unit test them. saw question , can test them if

ssis - What does "Combined" expression mean in derived column transform -

i new ssis , trying analyze existing package. in dervied column transformation component, there derived column expression set "combined". per online resources, understand expressions can functions "combined" mean. combined input column derived column transformation. expression referring input column making copy of combined column.

java - Eclipse Mars Background Process Issue -

Image
started eclipse today , reason having issue completing background process(stuck @ 6%) of updating 1 of projects. ive tried couple different options letting hours or tried stop it. no luck far. have clue on how can fix this? working 100% day before.. picture is: things i've tried disabled autobuild restarted pc eclipse many times attempt hit stop process, result in frozen eclipse.

angular - Angular2 Routes, Components and Inputs: Can they work together? -

i have component has set of inputs in takes in. component generic , takes in bunch inputs config way. i've had requirement component needs used part of routeconfig. issue running don't see how can supply these inputs through routeconfig through bindings or component references. the solution can forsee if create level between component , route creates these inputs , loads component there way around not having this? thanks! for how routeparams see how get paramater in angular2? if component should work routed component and statically added component uses @input() s , @output() s binding, using wrapper imho best approach.

c# - Deleting Entity Object with 1 to Many Association to View-Based Entity -

i have model-first entity model contains customer table linked view fetches customer details separate database. relationship 1 many between customer table , view , have navigation property on both customer entity , view entity. when try perform delete using context.customers.deleteobject(cust) , call context.savechanges() error: unable update entityset 'viewentity' because has definingquery , no [deletefunction] element exists element support current operation. i have tried setting on delete cascade , none , both generate same error. edit: there's not code show, here go: customer selectedcust = (customer)dgvcustomers.selectedrows[0].databounditem; if (selectedcust != null) { if (messagebox.show(string.format("are sure want delete customer {0}?", selectedcust.customerid.tostring()), "customer delete confirmation", messageboxbuttons.yesno) == dialogresult.yes) { // todo - fix this.r

C# Reading and Writing File over Sockets -

i have pretty weird issue right how i'm sending data on sockets. read buffer getting data i'm sending through socket, reason file.write or file.writeasync methods i'm calling not writing bytes, or stopping(i think that's issue) or wrong sockets , how they're being read , written too. so here snippet of code, keep in mind, both of these on same file different threads. byte[] buffer = new byte[1024]; int bytesread; while((bytesread = receiversocket.receive(buffer)) > 0) { totalbytesread += bytesread; //mydownload.write(buffer, 0, bytesread); mydownload.writeasync(buffer, 0, bytesread); } the code above receive function download client. keep in mind i'm getting same results regardless of write method use. and using this: byte[] filedata = file.readallbytes(filetosend); serversocket.sendfile(filetosend); i send file filesize: 10560 , retrieve bytes on receive

ios - Tab bar without TabBarController - add View Controller for Tab bar item in storyboard -

i have added tab bar (not tabviewcontroller) view controller , added tab bar items tab bar. now want attach other view controllers tab bar items in storyboard. when ctrl + drag view controller tab bar item not options. please suggest way this. i had same problem, couldn't find way assign viewcontroller own viewcontrollers in tabviewcontroller case. i solved using containers. 1 contarner each tabbaritem in tabbar, hidden or showed depending of selected tabbaritem in tabbar:(uitabbar *)tabbar didselectitem:(uitabbaritem *)item method. 1. create containers in uiviewcontroller in storyboard: just this select tabbar , ctrl+drag delegate class listen tabbardelegate methods: look here 2. declare corrisponging iboutlets, incliding tabbar: #import <uikit/uikit.h> @interface tabsmainviewcontroller : uiviewcontroller @property (strong, nonatomic) iboutlet uitabbar *tabbar; @property (strong, nonatomic) iboutlet uiview *directorycontainer; @property (st

slideshow - Using transition effect instead of easing -

i trying have slides in specific transition. right now, have called "easing" used within slideshow. problem have no idea how change specific portion. have modified slideshow great extent make usable work project working on. wanna use work , myself, because find such slideshow. but, love have simple transition sudo slider, opposed easing. (once have basic transitition, change sudo transitiion effect, not problem) anyhow, plugin found - sudo slider - found on website http://webbies.dk/assets/files/sudoslider/package/demos/continuous.html <script type="text/javascript" > $(document).ready(function(){ var sudoslider = $("#slider").sudoslider({ numeric: true continuous:true }); }); </script> as slideshow (called movingboxes), 1 of things have modified within code. speed, have put @ 1 "remove" effect of easing. capable of using sudo slider transition effects instead (or other non-easing transiti

ios - Admob display interstitial before segue - Swift -

Image
i have button segue's on view. when user clicks button, want display interstitial ad (if 1 loaded) , once user dismisses interstitial ad, perform segue usual. if there no interstitial ad, perform segue normal. i have code display interstitial, when user dismisses it, takes them previous view controller. have click button again taken next view controller. tips? // in storyboard-based application, want little preparation before navigation override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { if(interstitial.isready) { interstitial.presentfromrootviewcontroller(self) } } i wanted same thing. once watch ad, want proceed regular segue. added alert callback. difference mine uitableviewcell tap. in case this: @ibaction func buttontapped(sender: uibutton) { self.presentviewcontroller(interstitialadalert( { adwatched in if adwatched { // perform se

javascript - PHP Chart Js Load Mysql and Interface -

this source viewgraph.php <?php $datesgraph = array(); $moneyss = array(); $sql = "select right(datetransaksi,2) dates, sum(allmoney ) money view_resume_transaksi datetransaksi between '20160401' , '20160420' group datetransaksi order datetransaksi asc" ; $hasil=sqlsrv_query($conn, $sql) or die($sql . "<br>" .print_r( sqlsrv_errors(), true)) ; while($row = sqlsrv_fetch_array($hasil)){ $moneyss[$row[0]] = (int)$row[1]; $datesgraph[]=$row['tgl']; $moneyss[]=$row['money']; } ?> <script> var randomscalingfactor = function(){ return math.round(math.random()*100)}; var linechartdata = { labels : <?=json_encode($datesgraph);?>, data

python 3.2 - imported module.submodule namespaces interfering with eachother -

so i'm pretty deep making custom job/process custom manager module, , when got integrating came across interaction hadn't seen before modules , namespaces. code speaks better words: so there 2 different scripts: test1: import jobmanager jobmanager.jobmap = {'test1':'test123'} and test2: import jobmanager jobmanager.jobmap = {'test2':'test222'} top level script: import test1 import test2 print(test1.jobmanager.jobmap) print(test2.jobmanager.jobmap) so when run top level script prints: {'test2':'test222'} {'test2':'test222'} but expected output is: {'test1':'test123'} {'test2':'test222'} is case test1.jobmanager , test2.jobmanager same namespace? there way keep them separate? is case test1.jobmanager , test2.jobmanager same namespace? yes. is there way keep them separate? not without creating module.

haskell - How can I create a travis script for Haskel/stack? -

i've seen quite few travis stack scripts, seemed pretty complicated, don't think have complicated. here's mine: language: haskell sudo: false ghc: - '7.10.3' locally compile app "stack build". how can add "stack" travis file properly? @ moment need stack, no tests. there's thorough example at http://docs.haskellstack.org/en/stable/guide/#travis-with-caching it used smaller, added support build both stack , cabal, complicated things lot. can trim down remove support of more complicated features.

scikit learn - CountVectorizer gives empty vocabulary error is document is cardinal number -

i have encountered problem in using sklearn countvectorizer document consists of word - 'one'. have worked out error occurs when document consists of words of pos tag cd (cardinal number). following documents result in empty vocabulary error: ['one', 'two'] ['hundred'] ngram_code=1 cv = countvectorizer(stop_words='english', analyzer='word', lowercase=true,\ token_pattern="[\w']+", ngram_range=(ngram_code, ngram_code)) cv_array = cv.fit_transform(['one', 'two']) get error: valueerror: empty vocabulary; perhaps documents contain stop words the following not result in error because (i think) cardinal number words mixed other words: ['one', 'two', 'people'] interestingly though, in case, 'people' added vocabulary, 'one', 'two' not added: cv_array = cv.fit_transform(['one', 'two', 'people']) cv.vocabulary_ out[143]: {'people&

php - Can I continue coding if ($a[undefined]) as false? -

i wonder code has security risk or etc? this code cause notice error. <?php $array = array(); if ($array['hoge']) { } ?> and set ~e_notice in php.ini. should use empty()? thank you. the notice error caused because checking if $array['hoge'] either true or false, when in fact value isn't set. correct way code previous if conditional be: <?php $array = array(); if !empty($array['hoge']) { //...code executed inside conditional... } ?> it practice check if array both set , if it's not empty. hope helps! :)

Can I make an array of classes in C#? (I don't want an array of objects) -

i have tried create array of classes, first of regular classes, of static classes, in both cases, hasn't worked. hasn't compiled. class program { static class : bunch1 { } static class b : bunch1 { } class aa : bunch2 { } class bb : bunch2 { } class bunch1 { } class bunch2 { } static void main(string[] args) { bunch1[] bunch1s = new bunch1[] { a,b }; bunch2[] bunch2s = new bunch2[] { aa,bb }; } } the compilation error has been aa "is 'type' used 'variable'" (same error message class - or b or aa or bb) i can see (at least non static classes), can bunch2[] bunch2s = new bunch2[] { new aa(),new bb() }; but don't want instances of classes. i don't want array of objects. added a practical scenario of why. i have bunch of classes each static field (public static char c), , i'd set field. class {

javascript - Whats the quickest way to append or edit a function in an object? -

i have example object such: var shooter = {fire : function(){shootrighthandgun("shotgun");}} however shooter finds new gun , want set shooters fire function this: {fire : function(){shootrighthandgun("shotgun"); shootlefthandgun("handgun");}} what best/quickest way achieve this? helper functions, function array in object, anything. i'm totally open suggestions. technically can edit functions getting function's source code via .tostring() method string manipulations on using regexp etc. very, messy , don't recommend it. instead, give object bit more structure. first separate out right , left hand weapons: var shooter = { righthand : function () {}, lefthand : function () {}, fire : function () {} } now make .fire() method shoot (or use) weapons: var shooter = { righthandweapon : function () {}, lefthandweapon : function () {}, fire : function () { this.righthandweapon(); this

javascript - Call a function before refreshing the page -

when user hit f5 or refresh button need call function before refreshing page, tried below code , did'nt work, please suggest me i'm doing wrong , there better way this. i'm using anuglar 1.5 ui-router. angular.module('module.name', [ ]).controller('somecontroller',['$scope', function($scope) { $scope.$on("$statechangestart", function () { functiontocallonpagerefresh(); }); }]); functiontocallonpagerefresh() not getting called on page refresh. you need create parent state 'secure' , inherit every state in application state as- angular.module('modulename').config(['$stateprovider', '$urlrouterprovider', function ($stateprovider, $urlrouterprovider) { $stateprovider. state('secure', { url: "/", abstract: true, templateurl: "/path/to your/ master page", resolve:

ios - How would I convert these four lines of code from AVAudioPlayer to AVPlayer? -

i need change code avaudioplayer avplayer because supports rewind , avaudioplayer doesn't. im having trouble these 4 lines of code seeks audio thats playing using slider. here code have: func changeaudiotime() { //musicplayer declared avaudioplayer , want change avplayer , named variable player musicplayer.preparetoplay() musicplayer.currenttime = nstimeinterval(slider.value) musicplayer.numberofloops = -1 slider.value = float(musicplayer.currenttime) } for setting time in both case can use this: self.player.seektotime(cmtimemake(int64(slider.value),1)) slider.value = float(cmtimegetseconds(self.player.currenttime())) for looping may try this, there no direct method of loop, till want repeat may set flag/observer , repeat song if repeat off can don't execute observer/seek nsnotificationcenter.defaultcenter().addobserver(self, selector: "playeritemdidreachend:",name: avplayeritemdidplaytoendtimenotification, object: self.

xml - XSLT 2.0 case-insensitive matching with key() -

i'm checking existence of string in @id attribute in xml file. don't care case, letters of strings match. "myid_5" can equal "myid_5" , "myid_5" , on. i'm using <xsl:key> , key() , , apparently can't use lower-case() function keys normalize @id's found key. can i? or similar? example of xml file ( $lookup-file below): <root> <p id="a41_yrlydedhdr">blah</p> <p id="a42_yrlyded15">blah</p> </root> the key $lookup-file : <xsl:key name="p-id" match="/root/p" use="@id"/> the template: <xsl:template match="fig"> <xsl:variable name="id" select="lower-case(@id)"/> <xsl:choose> <!-- ?? can force lowercase below?? --> <xsl:when test="exists(key('p-id', $id, $lookup-file))"> <!-- <fig> --> </xsl:when> &l

ios - How to fetch all music apps name contains in device -

this question has answer here: finding list of installed apps on iphone 7 answers i have fetch music apps name contains in device (like google play,gaana,saavan) , has show name in app. search lot not able find solution.please me if has idea. there way fetch downloaded music files or list itunes store? ios applications installed in sandboxed environment, meaning they cannot outside own application . may work on jailbroken devices! more details given in this link ,

php - Running image upload code in Apache -

i tried code sample uploading image server using jquery ajax , php wamp server. same code work using apache web server? thanks... wampserver is apache , mysql , php installed in nice easy bundle. so nice , easy did not @ had installed.

oracle11g - Oracle 11g fetch values using offset value -

i trying fetch set of records database part part. tried use limit , fetch seems not working oracle 11g. there alternative solution this. have tried many in google results nothing working properly. you can use query , u want. select a.* (select a.*, rownum rownumber table1 t rownum <= to) t rownumber > from; from number , to number

eclipse plugin - Property Testers do not load despite forcePluginActivation. For popup menu enablement -

i in charge of refactoring popup menus in company's eclipse plugin use new commands/handler/menu extension point scheme. had business logic when menu items should enabled or not, , handled through onselectionchanged method of selectionlistener applied action. trying control enablement using custom propertytester, seems custom propertytesters not being loaded. i've followed eclipse's doc tutorials find online , reason not want work. if set "test" method return true, doesn't work because tester never loaded (i threw break points in , never hit). i've tried setting "forcepluginactivation='true'" flag in test in xml, not remedy situation. here code, company name replaced "company" , product replaced "product"... command xml <extension point="org.eclipse.ui.commands"> <command categoryid="com.company.product.android.core.category2" id="com.c