Posts

Showing posts from September, 2011

java - Issue with interface and parameter -

i have problem interface , parameters: public class functions { public static double getinfosum(treemap<string, iinterface> map){ ....some counting } } public class exampleclass { private treemap<string, exampleclassitem > xxxx; public static void somefunction(){ functions.getinfosum(xxxx); //here error } } public class exampleclassitem implements iinterface { ..... } is there other possibility except this: private treemap<string, exampleclassitem > xxxx; -----> private treemap<string, iinterface > xxxx; because need work exampleclassitem there specific functions can not in interface. you can change public static double getinfosum(treemap<string, iinterface> map){ ....some counting } to public static double getinfosum(treemap<string, ? extends iinterface> map){ ....some counting } this allow pass treemap<string, exampleclassitem> method.

javascript - Determine a reverse value based on a range -

i have html page css animation 'pushing' main container of page right 100px when left-hand nav menu hovered over. however, menu needs pushed in decrementally less pixel amounts window size increases. at browser window size of 790px wide (or less), container's left position 59px (retrieved using jquery's $.offset().left , , needs pushed full 100px make menu visible. however, browser window size increases between 790px , 1039px, menu needs pushed less , less - time window size 1039px/container's left position 184px, push needs 1px. so window size range working is: 1039 - 790 = 249px the position range of container adjusts in window sizes to: 183 (when window size 1039) - 59 (when window size 790) = 124px i want push menu this: min container position: left 59px = 100px push max container position: left 183px = 1px push and between 1px , 100px values between the min , max container position. how can assign push value of 100px when window

xcode - How can i get the "App Invitable " facebook friends list from ios app? -

in application , there 1 button enable after invite 10 or more friends on facebook. so how can total number of app invite counter ? if want find 'my' friends have installed app, be: https://graph.facebook.com/me/friends?fields=installed you can status of before send out invites , compare later how has changed. also, if don't use app request, use invite likes, can track better tools tapstream. they provide ios framework allows call getconversiondata contains information whether user clicked tapstream link app. can use link this: www.rounak.com/invite/invite_id , use invite_id determine whom user invited (and count this..) you can find information here: https://tapstream.com/developer/ios/onboarding-links/ their service free unless have lot of new users (link clicks)

mamp - apache server can't start anymore -

with latest version of mamppro (3.3) set php version host 5.3.29(standard) 5.4.42. when mamp asks restart servers message appears mamp can't stop apache. hard stop of apache possible , proceeded. apache error log: [sat jun 20 11:33:06 2015] [notice] digest: generating secret digest authentication ... [sat jun 20 11:33:06 2015] [notice] digest: done [sat jun 20 11:33:06 2015] [notice] fastcgi: process manager initialized (pid 52324) [sat jun 20 11:33:06 2015] [notice] apache/2.2.29 (unix) mod_wsgi/3.4 python/2.7.8 mod_fastcgi/2.4.6 dav/2 mod_ssl/2.2.29 openssl/0.9.8zd mod_perl/2.0.8 perl/v5.20.0 configured -- resuming normal operations [sat jun 20 11:44:30 2015] [notice] caught sigterm, shutting down from point on not possible start apache again. no further log entries. when changing php version 5.3.29 works fine again. same problem appears in mamp pro version before (3.2.1) any solution it? os x yosemite 10.10.3 mamp pro 3.3 i had same problem. found out pr

java - Swing: saving and loading components -

i'm trying save , load state of jpanel has nested custom panels (instances of other classes) , various listeners. these components have been created matisse, have private sub-components. i've tried xmlencoder / xmldecoder , threw various exceptions on serialization try. with xstream , can save , load gui state; however, doesn't reload listeners, leaving me stuck read-only component, undesirable. so, opens little bunch of questions me: is there might doing wrong xstream serialization? is access modifier of sub-components relevant of 2 libraries? are there other options swing component serialization worth exploring? should stick serializing component logic?

oop - Python method that can be called on a list of objects -

when method called on object in python as: obj.func() then python passes obj first argument func() . want like: [obj1, obj2].func() and have processed as: [obj1.func(), obj.func()] is there way of defining kind of methods in python? the way you're asking subclass python build-in class list . this should help. ps: bad thing though.

android - how to convert whole content of scrollview to bitmap -

i trying convert scrollview bitmap , bitmap returns null. don't know how manage, please give me solution achieve this. want whole scrollview content bitmap in order create pdf afterwards. following code: @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); setcontentview(r.layout.activity_first__resume__screen); rlv = (relativelayout) findviewbyid(r.id.rltv_layout); rlt_layoutwhole = (relativelayout) findviewbyid(r.id.rlv_whole); srvw = (scrollview) findviewbyid(r.id.scrollview1); // view u = ((activity) mcontext).findviewbyid(r.id.scrollview1); random rnd = new random(); int prevtextviewid = 0; relativelayout.layoutparams params1 = new relativelayout.layoutparams( layoutparams.wrap_content, layoutparams.wrap_content); (int = 0; < 15; i++) { final textview

ads - Applovin AdclickListener not working in android -

i integrating applovin sdk integrate ads in app.my app game app , want user reward coins when click on ads.but adclicklistener of applovin seems not working in case. the code: private applovinadview adview; // create applovin ad view final applovinsdk sdk = applovinsdk.getinstance(sceneactivity.this); adview = new applovinadview(sdk, applovinadsize.interstitial, sceneactivity.this); //show ad after 4 levels if (currentlevel % 4 == 0) { // ad available display. it's safe call show. applovininterstitialad.show(sceneactivity.this); adview.loadnextad(); } adview.setadclicklistener(new applovinadclicklistener() { @suppresslint("simpledateformat") @override public void adclicked(applovina

Database Design: Multiple identifying relationships between two entities -

i have 2 entities user , , message . to avoid surrogate primary key message should weak entity depending on user , having 2 references of same (primary key) attribute user - email , partial key supposed unix_timestamp . is fine approach? there other alternative?

php - Why does the webserver throttles ajax queries - DDoS? -

i have issue on html5 web app have repetitive data updates via ajax query every 2 seconds. first 2 or 3 go through @ 175ms, after this, slow down 500ms, on. hosting company swears not them. did simple test - see test scripts below. not app test script has same results. question is: is hosting service throttling thinking ddos attack, or there can stop throttling , slowing down ajax queries? the index file: <!doctype html> <html> <head> <script src="jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ var count = 0; var my_timer = setinterval(function(){ $.ajax({url: "test.php", success: function(result){ $("#div1").html(result); }}); count = count + 1; if(count == 10) clearinterval(my_timer); },2000); }); }); </script> </head> <body> <div id=&quo

inheritance - how to use inheritence in ArrayList in java? -

Image
this question has answer here: why can't list<parent> mylist = arraylist<child>(); 3 answers i hava class called qgnode extends gnode , class qgraph extends graph . in qgnode constructor when call super constructor argument arraylist<qgnode> error occurs. misunderstand inheritance? here code: 0 public class questiongraph extends graph{ 1 2 public questiongraph(arraylist<qgnode> nodes) { 3 super(nodes); 4 } 5 } 1 public class graph { 2 3 arraylist<gnode> nodes; 4 5 public graph(arraylist<gnode> nodes) { 6 this.nodes = nodes; 7 } 8 } error occurs @ line 3 , it's syntax error , ide suggest : create method (java.util.arraylist) in questiongraph inheritance in generics works bit differently. in java arraylist<qgnode> not subtype of arraylist<gnode> . generics in java , i

git - What tools to gain visibility on multiproject feature development? -

as is: have 10+ projects (each repo) interdependent when comes developing feature. currently naming each story branch same way across projects see when there dependencies in different git repos regarding particular story. e.g. cannot have story deploying project1, need project2 well. example naming: project1 story branch - "[task-1] new login process" project2 story branch - "[task-1] new login process" the problem: not sure if better way represent dependencies across multiple projects. seems bit weird @ first rely on naming convention again don't see better solution. having in mind solution of following naming convention branch naming i'd gain better visibility of where. consider commit history within single project. http://www.kdgregory.com/images/scm.git/03-sprint.gif let's made release on black dot in master. there started developing new stories. visibility on: which stories merged in dev which stories merged in master w

ios - how to enable UITextField userinteraction property inside UITableView Cell -

i have uitableviewcell , inside have uitextfield , made 7 sections (dynamic) , each section have 1 cell (one row) includes uitextfield . now have 1 button on right top corner of uinavigationbar (edit button). need enable user interaction enable section textfields . hows possible? this uitableviewcode - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { sharedmanager=[mymanager sharedmanager]; return 1; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { //uitableviewcell *cell; uilabel *label = nil; nsstring *text; cell = [tableview dequeuereusablecellwithidentifier:@"cell"]; if (cell == nil) { cell = [[timelinedetailscell alloc] initwithframe:cgrectzero reuseidentifier:@"cell"]; label = [[uilabel alloc] initwithframe:cgrectzero]; [label setlinebreakmode:uilinebreakmodewordwrap]; [label

Convert Json array to Assosiative array and bind it to AutoCompleteTextView -- Android -

Image
i have array below .. [{"instituteid":"1","institutename":"demo institute"},{"instituteid":"16","institutename":"sheridan college"},{"instituteid":"17","institutename":"icent prosp"},{"instituteid":"18","institutename":"seneca college"}] i want convert array associative , want set institution name autocompletetextview. here code @override protected void onpostexecute(string res) { try { jsonobject responseobject = new jsonobject(res); string status=responseobject.getstring("status"); jsonarray detailsarray = responseobject.getjsonarray("institutelist"); string[] newarray = new gson().fromjson(string.valueof(detailsarray),string[].class); log.i("institute register assc" , string.valueof(newarray));

php - Page is reloading when form submit usng jquery ajax -

i trying submit form using jquery ajax. problem when submitting form submitting page reloading. tried using preventdefault() . still couldn't figure out. this html form: <form action="" method="post" id="addcategoryform"> <div class="form-group"> <input type="text" class="form-control" id="new_category" name="new_category" autofocus> </div> <div class="form-group"> <select class="form-control" name="parentcategorylist"> <option value="">-- parent category --</option> <option value="">lorem ipsum</option> <option value="">lorem ipsdffum</option> </select> </div> <div class="form-group"> <button class="btn btn-default" id="addc

ASP.NET PHP View: using Phalanger for only one page -

Image
question is possible use phalanger ( https://phalanger.codeplex.com/ ) in asp.net mvc 1 view , leave else using normal razor view engine? situation i using elfinder in site integrated using elfinder connector .net. ideally, integrate responsive file manager, here: http://www.responsivefilemanager.com/index.php unfortunately, aforementioned file manager written php. i have read php can used within mvc using phalanger (see: http://www.infoq.com/articles/phalanger ) and wondering whether @ possible create php view , make file manager work site while @ same time leaving other pages alone. note, know nothing of php @ all... if @ possible, how go starting this? edit i found simple implementation of mvc php view engine here (which based on phalanger ): https://phpviewengine.codeplex.com/ i seem have sort of got working tinymce. shows quite nicely, when trying select file, throws various javascript errors. here link demo project made: http://www.mediafire.com/dow

python - Transforming a text file into column vectors -

i have text file break column vectors: dtstamp ozone ozone_8hr_avg 06/18/2015 14:00:00 0.071 0.059 06/18/2015 13:00:00 0.071 0.053 how produce output in following format? dtstamp = [06/18/2015 14:00:00, 06/18/2015] ozone = [0.071, 0.071] etc. import datetime dtstamp = [] # initialize dtstamp list ozone = [] # initialize ozone list open('file.txt', 'r') f: next(f) # skip title line line in f: # iterate through file if not line: continue # skip blank lines day, time, value, _ = line.split() # split line dtstamp.append(datetime.datetime.strptime(' '.join((date, time)), '%m/%d/%y %h:%m:%s') # add date ozone.append(float(value)) # add value you can combine these list s zip work corresponding dates/values: for date, value in zip(dtstamp, ozone): print(date, value) # example

php - Limit the number of letter returned from a DB recordset field -

i have following string asp vb string: <%= left ((rsmyrecordset.fields.item("text").value), 75)%> this returns 75 characturers left how do same thing in php, current string is: <?php echo $row_rsmyrecordset['text']; ?> many thanks look substr in php manual

c - Compile coretuils as shared objects? -

i trying compile gnu coreutils set of shared libraries, instead of set of executables. thought make let me pass in flag tell this, can see have modify configure.ac , makefile.am in order make work. prefer not this, since potentially introduces bugs code can rely on being bug-free. tried manually turning object files so's entering: make cflags='-fpic' gcc -shared -o ls.so coreutils/src/ls.o i able create file, there seem number of flags missing, , don't see way access list of necessary flags compile , link code (even though information contained in computer). thing can think manually go through of linker errors , try figure out flags missing, i'm hoping there less tedious way of getting want. not sure you're trying do, related ./configure --enable-single-binary option links objects single executable.

rest - How to create mock data in store proxy of ExtJS -

here code data using rest api , rest api return array of objects items = [ {id: 1, group: group1}, {id: 1, group: group2} ] but while waiting rest api(url: '/api/group') want mock data can continue task don't know how. there anyway can have items in proxy instead of url now. appreciated ext.define('console.store.groups', { extend: 'ext.data.store', model: 'console.model.group', autosync: false, buffered: false, pagesize: 1000, autoload: false, autodestory: true, purgepagecount: 3, sorters:[{ property:'name', }], trailingbufferzone: 100, proxy: { simplesortmode: true, type: 'rest', url: '/api/groups', reader: { type: 'json', root: 'data', totalproperty: 'total' } } }); using memory proxy worked in case. below code using memory proxy

gruntjs - grunt.file write/copy with permissions -

is there way specify permissions of file during grunt.file.copy(...), except using 'fs.chmod' after copy has finished? i have require whole 'fs' module otherwise, changing permissions. lot of overhead? grunt.file.copy not provide option that, unfortunately. but grunt copy task (from grunt-contrib-copy ) has option ( options.mode , see https://github.com/gruntjs/grunt-contrib-copy#mode ).

How to read one row at a time from excel file using aspose in java -

i have excel file 1000's of rows , want read each row @ time in java using aspose api's. want convert each row string array. can me this? worksheet worksheet = workbook.getworksheets().get(0); cells cells = worksheet.getcells(); aspose.cells provides lightcells api, designed read/ write cell's data 1 one without building complete data model block (using cell collection etc.) memory. works in event-driven mode. think may try it. when reading template files, component parses every cell , provides value 1 one. please see document reference here . i developer evangelist @ aspose.

javascript - Using a document method from within object prototype? -

i'm pretty new javascript , trying set prototype called "number" key called "button" grabs html element whatever id pass it. there element id of "one" present in html. i'm wondering why doesn't work? function number(num, idofnum) { this.val = num; this.button = document.getelementbyid(idofnum); }; var 1 = new number(1, "one"); console.log(one.button); // null? if one.button null , that's because document.getelementbyid("one"); did not find dom object when ran constructor number() object , returned null . that either because there no object in page id or becase running code before page has finished loading , object not yet exist when run code. you have show more of overall page context (where code executing in relation parsing of page dom) know situation happening here. a common fix situation you're running code move <script> tag code resides right before </body> tag. ensur

javascript - Sequelize, how do I get current value of updating row? -

how current value of row i'm update? have findone query before update, in order find previous value? here's want do: update usermodels set nonce = nonce + 1 u_id = 1 is there way make work here? how [current value of nonce]? have separate query? return usermodels.update({ nonce: [current value of nonce] + 1 },{ where: { u_id: 1 } } ); as docs say, updated value of object should retrieved again. @lj_1102 commented this link here on api implementation can see better explanation. refer reload if cant reload instance , prevent creating again

javascript - Setting a variable when user selects from a dropdown -

in rails view, have dropdown menu of patients. when user selects patient, want set @patient patient.find(id) id data attribute on item user selected. how can achieve this? action: def options @assessment = current_user.assessments.new @patients = current_user.patients.sort_by{|e| e.first_name.downcase} @patient = current_user.patients.new @templates = template.all end view: <%= form_for @assessment, :method=>"get", :url => url_for(:action => 'new') |f| %> <%= f.select :patient_id, content_tag(:option,'select patient...',:value=>"")+content_tag(:option,'new patient',:value=>"")+options_from_collection_for_select(@patients, 'id', 'full_name'), :class=>"form-control" %> <%= f.hidden_field :user_id, :value => current_user.id %> <div class="row" id="assessment-type" style="display:none;">

javascript - How to save Checkbox Value and status -

i need save values status of checkboxes on page; can check @ time of submit if checked box has been unchecked , use value using comparestatus() function further logic. have tried , error variable periodchk not defined. <input type="checkbox" name="periods" value="25301601" > <input type="checkbox" name="periods" value="25301602" checked> <script type="text/javascript"> $j(document).ready( function() { var periodchk; $j(":checkbox").each( function() { periodchk["$j(this.id).val()"]=($j(this).is(':checked')); } ); console.log(periodchk); function comparestatus() { var periodstring; if (!$j(this).is(':checked')) { // if 1 checked before, grab , make string if (window.periodchk["$j(this.id).val()"])

how to cbind the column generated in a loop in R -

i have loop gives me column of data per run. run loop in range 0:4, gives me 5 columns. if print out, column1, column2, ... want save of 5 columns csv file. in 1 single file, want have 5 columns ordered order of loop, namely, column1, column2, ... there many ways achieve have described. here 1 approach work in many circumstances. # start empty list mydata <- list() # run through loop, adding each vector list for(i in 1:10){ # whatever in loop mydata[[i]] <- # result of iteration of loop } # turn list dataframe mydf <- data.frame(mydata) # write dataframe file write.csv(mydf, file="destfile.csv")

ruby on rails - Not able to install jekyll without root access -

i trying install jekyll, there documentation says install : gem install jekyll when try above gives error: error: not find valid gem 'jekyll' (>= 0), here why: unable download data https://rubygems.org/ - no such name ( https://api.rubygems.org/specs.4.8.gz ) but when tried: sudo gem install jekyll it worked fine , gave following output : successfully installed jekyll-2.5.3 1 gem installed i went through this write permission, while problem facing not being able access source. my internet connection fine , https_proxy unset not behind proxy server. sudo/root access doing able access when can't?

sql - Error with Declare usage -

i learn how use declare . my query like: declare @iter int set @iter = 1 error: msg 137, level 15, state 1, line 1 must declare scalar variable "@iter". please help! you need put thw 2 instructions in different lines declare @iter int set @iter = 1

objective c - Cocoa ScreenSaverView -

i trying play screensaverview in mac os x. i followed tutorial http://cocoadevcentral.com/articles/000088.php , worked (can't flawlessly ,but worked). saw in part 2 of tutorial playing opengl stuff etc. i have 2 general questions: 1)can use sprtekit within screensaver view? 2)what wrong code here -> compiles well, don't see except black screen (i want see *.png). - (instancetype)initwithframe:(nsrect)frame ispreview:(bool)ispreview { self = [super initwithframe:frame ispreview:ispreview]; if (self) { _imageview = [[nsimageview alloc]initwithframe:[self bounds]]; [_imageview setimage:[nsimage imagenamed:@"settingsbutton.png"]]; [self addsubview:_imageview]; [self setanimationtimeinterval:1.0]; } return self; } edit: attempt use draw rect: - (void)drawrect:(nsrect)rect0 { [super drawrect:rect0]; nsimage *anotherimage = [nsimage imagenamed:@"settingsbutton.png"]; [anotherim

serialization - How can I write to two different serializers simultaneously in Django 1.8 and REST 3? -

i sending json data angular app django view/serializer , need serialize both arrays @ same time in order create user successfully. tried ridiculous way of separating data in view , doing 2 serializations separately, realized messy , become problematic if errors occurred during second part. basically: {"email": "foo@foo.com", "password": "barbar", "first_name":"baz", "last_name":"buzz", "profile": {"cdata":"1" "other":"0" "sex":"m"} "message": "i don't know comes after buzz in foo bar baz buzz etc." } should separate arrays in view? if so, how tell serializers separated array of data should take? (this profile data saved onetoone field user model) if can show me succinct way of handling this, grateful. please let me know if can or if u need more info. appreciate time. thanks.

dictionary - How do I get tourist attractions around zip code using OpenStreetMap? -

i want tourist attractions around zip code in us. how do openstreetmap api? i have found http://wiki.openstreetmap.org/wiki/key:tourism but i'm not sure how use it. http://nominatim.openstreetmap.org/search?q=135+pilkington+avenue,+birmingham&format=json&polygon=1&addressdetails=1&tourism=attraction you can use overpass turbo e.g. query wizard show current bounding box available objects. to zip code instead of bounding box more complicated in mapped region germany, because knowledge there no relations (or rarely) map zip code boundary polygon. obtain several addresses zip codes , create kind of boundary won't precise. regarding have less features zip code mapped due tiger import (less mapping activity), not sure.

android - How to import only selected native library ABIs from AAR? -

i have bit unusual problem - android app contains native libs , build native libs armeabi-v7a , x86. however, need integrate third party library app contains native libraries (third party library crashlytics included via maven build.gradle.). problem third party library's aar provides arhitectures (armeabi, arm64-v8a, armeabi-v7a, mips, mips64, x86 , x86_64) , app supports armeabi-v7a , x86 (arm64-v8a planned near future), when final apk built contains 3rd party library's abi's , x86 , armeabi-v7a abi's of native code. causes app crash when launched on arm64 device galaxy s6. my question is: possible include selected abi's 3rd party aar? please note aware of apk splits , solves problem partially, i.e. works if distribute app via play store. although play store supports beta test distribution, propagation of updated apk rather slow, prior pushing update app's playstore beta channel, push update via crashlytics' beta distribution system, faster. probl

c# - entity framework validation context - null exception in null test -

i working on pc configurator application , have problem validating. point of app check if socket on motherboard same socket of cpu etc. i made code first database using scaffolding in visual studio 2013. public class configuration : ivalidatableobject { [key] public int configurationid { get; set; } [required] [stringlength(50, minimumlength = 3)] [displayname("configuration name")] public string configname { get; set; } [foreignkey("mb_id")] public motherboard motherboard { get; set; } [column("mb_id", typename = "int")] public nullable<int> mb_id { get; set; } [foreignkey("cpu_id")] public cpu cpu { get; set; } [column("cpu_id", typename = "int")] public nullable<int> cpu_id { get; set; } } this part of configuration model using (rest of looks pretty similar - other components) i scaffolded model controller. this start of validat

javascript - jQuery will not update textarea -

i have html textarea defined in index.html defined follows: <textarea id="mytextarea" rows="12" readonly="7" class="form-control"></textarea> i have javascript file named shared.js . right now, shared.js has following: function appendtotextarea(id, text, stayoncurrentline) { var current = $(id).val(); var newtext = current + ' ' + text; if (!stayoncurrentline) { newstatus += '\n'; } $(id).val(newtext); console.log($(id).val()); } index.html referencing shared.js. calls appendtotextarea fine. i'm calling code function in index.html called mybuttonclick. function mybuttonclick() { appendtotextarea('#mytextarea', 'hello', false); appendtotextarea('#mytextarea', 'how', false); appendtotextarea('#mytextarea', 'are', false); appendtotextarea('#mytextarea', 'you', false); } when

c++ - Managing asynchronous communication: how to examine response received in another thread -

i have dispatcher thread , listener thread. when dispatch command, want wait response before send follow command. need examine respond before can proceed 2nd command, least of confirm response received , okay. pseudo code below: void mainwindow::downloaddata() { dispatcher->getinfo(); // sends command // qstring response = receiver->response() // idealy check response since async, can't that! dipatcher->askdata(); // 2nd command , forth } is there elegant way solve issue? way can think of if use same thread , calls blocking that's not solution. in qt, use signals , slots connect them in cascading manner when first signal triggered initiates whole sequence of operation (each slot emitting new signal) seems rather dirty well. one of robust ways handle asynchronous events , process chains/graphs of actions upon these events fsms. qt provides basis implementing fsms qt-state machine framework . i'd suggest go way. unfortunately example

ios - Updating App Store app from a web server -

i'm wondering if it's possible allow users replace apps installed app store updated version via browser download. my use case is, i'd users able download , play game via app store, allow them update app adult content version (not permited on app store) if see fit. a breakdown of users steps follows: 1.) user download app app store. 2.) play game, gets bored, wants adult content version 3.) navigates url hosting adult version .ipa (e.g. https://myappcompany.com/fungameadultversionupdate/index.html hosted along side manifest.plist etc) 4.) app downloads , replaces app store version. i understand without existing app downloaded app store there way possible (the iphone reject ipa on basis it's not signed apple). assuming updated app compiled , signed of same same keys (apple ios certificates, identifiers, profiles etc). the difference between app store ipa , updated ipa updated ipa have modified codebase , not signed apple. hope isn't confusing. a

bit manipulation - Bit twiddling to get sign bit of 32 bit int -

i convert (n < 0 ? 1 : 0) into bit twiddling (assuming 2s complement arch). for performance reasons. with unsigned shift, x = n >>> 31; // java's unsigned shift x = (int)((uint)n >> 31); // c#'s unsigned shift, casts nop gcc automatically, other compilers may also. or not. mileage may vary.

python - Importing the same modules in different files -

supposing have written set of classes used in python file , use them in script (or python code in different file). both files require set of modules imported. should import included once, or in both files ? file 1 : my_module.py . import os class myclass(object): def __init__(self,path): self.list_of_directories = os.listdir(path) file 2 : import os import my_module my_module.m = myclass("c:\\user\\john\\desktop") list_ = m.list_of_directories print os.getcwd() should adding line import os both files ? how impact performance, supposing there lots of modules imported ? also, module ,once imported, reloaded in case ? each file using module in, must import module. each module own namespace. things explicitly import within file available in namespace. thus, if need os in both files, should import them in both files.

c# - Return Variable From Method -

i know how pass variables procedure, how return variable calling procedure? example, syntax, no issue @ passing in variable arr how can return value nummmm main ? please disregard empty sqlconnection & update statement etc, valid in actual syntax. namespace consoletest { class test { public static string sqlconnectionstring = ""; public static string updatestatement = null; public static string[] arrarray; public int static void main(string[] args) { arrarray = new string[3] { "1412", "1618", "1223" }; foreach (string arr in arrarray) { runupdates(arr, out nummmm); } } private static int runupdates(string arr, out int nummmm) { updatestatement = ""; using (sqlconnection connection = new sqlconnection(sqlconnectionstring)) { connection.open(); using (sqlcommand command = new sqlcommand(updates

creating a registration profile in python django -

my goal django application upon registration, users able use site, prompt them later verify email (activate it). send them email verification email register, , again if can't find email. i'm using django 1.7.8 , django-registration-redux . here's landing page view: from django.shortcuts import render django.http import httpresponseredirect django.core.urlresolvers import reverse django.contrib.auth import authenticate django.contrib.auth import login registration import signals registration.models import registrationmanager drivers.forms import myusercreationform def create_registration_profile(user, request, **kwargs): user.backend = 'django.contrib.auth.backends.modelbackend' login(request, user) reg_manager = registrationmanager() reg_profile = reg_manager.create_profile(user) reg_profile.save() print "callback reached!" signals.user_registered.connect(create_registration_profile) def landing(request): if requ

xml - Use XSLT 2.0 to display an image from a directory -

Image
team, i'm using xlst 2.0 create ms word documents xml data. i'm working on creating header , want call in image file local directory display our company logo. software i'm using, unable use ms word template call. billing software , needs create each ms word document on fly each time bill (using xml data) get's thrown @ it. i've searched site extensively , tried majority of examples given no avail. assistance or guidance appreciated. here result of header in ms word doc want create... here xsl header... <xsl:stylesheet xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:c2f41010-65b3-11d1-a29f-00aa00c14882" xmlns:fo="http://www.w3.org/1999/xsl/format" xmlns:kmf="http://www.kleinmundo.com/functions" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:sl="http://schemas.microsoft.com/schemalibrary/2003/core" xmlns:tlr="http://www

django - Python zipfile not being delivered to user -

update: got zip file created, response still isn't working properly. here's updated code. def index(request): if request.is_ajax(): uploaded = request.body newstring = "{\"testdata\": [" + uploaded + "]}" data = json.loads(newstring) num_lines = sum(len(v) v in data.itervalues()) testing(data, num_lines) zip_subdir = 'testapi' zip_filename = '%s.zip' % zip_subdir zf = z.zipfile(zip_filename, mode='w') zf.write('test.xlsx') zf.close() zip_file = open(zip_filename, 'r') response = httpresponse(zip_file, content_type='application/x-zip-compressed') response['content-disposition'] = 'attachment; filename=%s' % zip_filename return response just make sure, deleted zip file , excel spreadsheet, , after running program, both created properly. excel spreadsheet populat

grouping - Find social network components in Stata -

[i copied part of below example separate post , changed suit specific needs] pos_1 pos_2 2 4 2 5 1 2 3 9 4 2 9 3 the above read person_2 connected person_4,...,person_4 connected person_2, , person_9 connected person_3. i want create third categorical [edited] variable, component, lets me know if observed link part of connected component (subnetwork) within network. in case, there 2 connected components in network: pos_1 pos_2 component 2 4 1 2 5 1 1 2 1 3 9 2 4 2 1 9 3 2 all nodes in component 1 connected each other, not nodes in component 2 , vice versa. there way generate component variable in stata? know there alternative programs in, code more seamless if can integrate stata. if reshape data long form, can use group_id (from ssc) want: clear input pos_1 pos_2 2 4 2 5 1

javascript - Codecademy "SyntaxError: Unexpected token else" -

i'm doing codecademy js course, , i'm @ part rock paper scissors. when save code says "syntaxerror: unexpected token else". did wrong? code: var compare = function(choice1, choice2) { if (choice1 === choice2) { return("the result tie!"); } else if (choice1 === "rock") { if (choice2 === "scissors") { return ("rock wins"); } else { return ("paper wins"); } } else if (choice1 === "paper"); { if (choice2 === "rock") { return("paper wins"); } else { return("scissors wins"); } } else if (choice1 === "scissors") { if (choice2 === "paper"); { return ("scissors wins"); } else { return("rock wi

parse python functions as a string within decorator -

i trying write function debug decorator at: def foo(baz): bar = 1 bar = 2 return bar and wrap to: def foo(baz): bar = 1 print 'bar: {}'.format(bar) bar = 2 print 'bar: {}'.format(bar) return bar i need play function text, grab "\w+(?=\s*[=])", not know how access that. have decorator modified blog works, tried changing to: class decorator_string_check(object): def __init__(self, func): self.func = func wraps(func)(self) def __call__(self, *args, **kwargs): print dir(self.func) print dir(self.func.__code__) print self.func.__code__.__str__() ret = self.func(*args, **kwargs) return ret @decorator_string_check def fake(x): y = 6 y = x return y y = fake(9) and getting nothinng of value, namely: ['__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr__', '__dict__', '__doc

login - Access control of a Module in Yii2 -

i having trouble login part. read topic : http://www.yiiframework.com/wiki/771/rbac-super-simple-with-admin-and-user/ . follow steps, in step 6. configs 1 controller. have module called admin many controllers in , don't know how apply access control whole module. can me ? sorry bad english. you can create admincontroller class, extends yii\web\controller define access rules in behaviors method , make other module controllers extend admincontroller , override behaviors method this: public function behaviors() { return \yii\helpers\arrayhelper::merge(parent::behaviors(), [ 'verbs' => [ 'class' => verbfilter::classname(), 'actions' => [ 'delete' => ['post'], ], ], ]); } here parent::behaviors() behaviors admincontroller define default access rules, , merge them specific behaviors in child controller. gives flexibility override acces

php - Codeigniter 3 upload not saving thumb to directory -

i trying save thumbnail image directory, not working. able save original image , save info database, reason thumbnail not saving thumbs directory create. directory has read/write access. note using dropzone.js. here partial code: if ( ! $this->upload->do_upload('file')) { //upload failed, echo negative response dropzone.js } else { //upload success, upload file(s) $image_data = $this->upload->data(); $img_config['source_image'] = '/uploads/videos/'.$image_data['file_name']; $img_config['new_image'] = '/uploads/videos/thumbs/'.$image_data['file_name']; $img_config['create_thumb'] = true; $img_config['maintain_ratio'] = true; $img_config['width'] = 251; $img_config['height'] = 180; $this->load->library('image_lib', $img_config);

ruby - Override one attribute in Rails strong params -

is there way can override 1 attribute yet still use strong parameters in rails? such in following example, if wanted override person's name every time, use person_params method. there has better way manually setting @person.name , right? class peoplecontroller < actioncontroller::base def create @person = person.new(person_params) @person.name = "abc" @person.save end private def person_params params.require(:person).permit(:name, :age) end end if want override name other string, or format before saving, can do: @person = person.new(person_params.merge!(name: 'abc')) if want create , merge in 1 line, this: def create @person = person.create(person_params.merge!(name: 'abc')) end

How to form complex mysql query that has left outer join, aggregate data with group by using SQLAlchemy? -

how write following query using sqlalchemy? select i.itemid, sum(i.quantitysold) total_quantity_sold, max(t.createdat) last_sale_time itemlist left outer join itemtransactions t on i.itemid = t.itemid i.active = 'y' group i.itemid order total_quantity_sold asc; this ended writing: from sqlalchemy.sql import func sa_func query = itemlist.query.with_entities(itemlist.itemid) query = query.outerjoin(itemtransactions, itemtransactions.itemid == itemlist.itemid) query = query.add_columns(sa_func.sum(itemlist.quantitysold).label('total_quantity_sold')) query = query.add_columns(sa_func.max(itemtransactions.createdat).label('last_sale_time')) query = query.filter(itemlist.active == "y") query = query.group_by(itemlist.itemid) query = query.order_by(sa_func.sum(itemlist.quantitysold).asc()) if limit not none , limit not 0: query = query.limit(limit) if offset not none: query = query.offset(offset) # execute query sales = query.all()