Posts

dependency injection - DI container for Java without @Inject -

i'd know if there di container java world behaves close .net ones, namely, want these 2 features: main requirement - should work without @inject annotation. so, if @inject not specified anywhere, , class has single constructor container should use constructor. know, @inject annotation standard, don't it. 2nd requirement (not necessary @ all) - way auto-configure (by naming conventions etc.) it looks swing , guice require @inject, happy, if i'm wrong. pico satisfies 1st requirement. 2nd requirement can more or less done org.reflections library , this answer

bash - How to avoid 'are the same file' warning message when using cp in Linux? -

i'm trying copy files 1 directory another. using command find "$home" -name '*.txt' -type f -print0 | xargs -0 cp -t $home/newdir i warning message saying cp: '/home/me/newdir/logfile.txt' , '/home/me/newdir/logfile.txt' same file how avoid warning message? the problem try copy file itself. can avoid excluding destination directory results of find command this: find "$home" -name '*.txt' -type f -not -path "$home/newdir/*" -print0 | xargs -0 cp -t "$home/newdir"

osx - Retina issue (OS X) -

i creating cocoa app, , when import @2x images project, no image shows in app @ all. using non-retina macbook pro. if have image, such image.png, shows correctly. when import image@2x.png project, no image shows when app run (even normal image). when change image@2x.png image@2xx.png (or other name), image shows again. however, can't show image on retina device. am not handling retina images correctly? you need include image.png , image@2x.png in project. make sure when load files not include .png extension.

Django - MultipleCheckBoxSelector with m2m field - How to add object instead of save_m2m() -

Image
i use inlineformset_factory custom form option in order change queryset , widget of m2m field, ie: ezmap . want form give user option add or remove current selected_map m2m field checkboxselectmultiple widget. however, dont want give user ability remove other objects there. problem when save formset formset.save_m2m() , overides field , erase objects saved. how add new object without erasing others? models: (some of unecessary fields removed) class shapefile(models.model): filename = models.charfield(max_length=255) class ezmap(models.model): map_name = models.slugfield(max_length=50) layers = models.manytomanyfield(shapefile, verbose_name='layers display', null=true, blank=true) class layerstyle(models.model): stylename = models.slugfield(max_length=50) layer = models.foreignkey(shapefile) ezmap = models.manytomanyfield(ezmap) forms: class polygonlayerstyleformset(forms.modelform): add_to_map = forms.booleanfield(required=false)...

How to swap a double in Objective-C -

i'm trying read double file. need swap it. nsswaplittledoubletohost(nsswappeddouble x) requires nsswappeddouble . nsswapdouble() requires nsswappeddouble well. nsswappeddouble doubleswap = normaldouble; doesnt work. how convert double nsswappeddouble? to convert double nsswappeddouble can use nsconverthostdoubletoswapped per documentation . however, if want swap double can call nsswaphostdoubletobig or nsswaphostdoubletolittle directly (both take double parameter).

png - matplotlib subplot with image background -

how can create subplot, background created fully, without gray boundry, png image file.png i have tried: import matplotlib.pyplot plt im = plt.imread('map.gif') implot = plt.imshow(im,aspect='auto',origin='lower') fig0=implot.figure.tight_layout(pad=0.5) implot.axes.set_axis_off() fig1=implot.figure ax1=fig1.add_subplot(2,2,1) ax1.plot(range(10)) ax2=fig1.add_subplot(2,2,2) ax2.plot(range(9,-1,-1)) plt.show() i cannot image span whole graphics window thanks ilan

php get the max(accNumber) and then increment by 1 -

i'm trying highest number , increment 1. blank page, here code $query = $pdo->prepare("select max(accnum) accounts"); $query->execute(); while($num = $query->fetchall()){ if($num[1] == null){ $accnumber = "100001"; }else{ $accnumber = $num[1]++; } echo $accnumber; } what doing wrong here. thanks $query = $pdo->prepare("select max(accnum) accounts"); $query->execute(); while($num = $query->fetchall()){ if($num[0] == null){ $accnumber = "100001"; }else{ $accnumber = $num[0]++; } echo $accnumber; }