Posts

Showing posts from January, 2010

windows - Is Writeln capable of supporting Unicode? -

consider program: {$apptype console} begin writeln('АБВГДЕЖЅzЗИІКЛМНОПҀРСТȢѸФХѾЦЧШЩЪЫЬѢѤЮѦѪѨѬѠѺѮѰѲѴ'); end. the output on console uses consolas font is: ????????z?????????????????????????????????????? the windows console quite capable of supporting unicode evidenced program: {$apptype console} uses winapi.windows; const text = 'АБВГДЕЖЅzЗИІКЛМНОПҀРСТȢѸФХѾЦЧШЩЪЫЬѢѤЮѦѪѨѬѠѺѮѰѲѴ'; var numwritten: dword; begin writeconsole(getstdhandle(std_output_handle), pchar(text), length(text), numwritten, nil); end. for output is: АБВГДЕЖЅzЗИІКЛМНОПҀРСТȢѸФХѾЦЧШЩЪЫЬѢѤЮѦѪѨѬѠѺѮѰѲѴ can writeln persuaded respect unicode, or inherently crippled? just set console output codepage through setconsoleoutputcp() routine codepage cp_utf8 . program project1; {$apptype console} uses system.sysutils,windows; const text = 'АБВГДЕЖЅzЗИІКЛМНОПҀРСТȢѸФХѾЦЧШЩЪЫЬѢѤЮѦѪѨѬѠѺѮѰѲѴ'; var numwritten: dword; begin readln; // make sure consolas font

Sybase code has has where clause: where a & b=c -

i have code below: select id,role,unit user_id i,user_rol r,unit u unit_grp_catg_map_c & ib_unit_grp_catg_c = ib_unit_grp_catg_c can explain me & , how works? cannot find on internet & stands bitwise , operation, here have details.

c - Count number of processes created using fork in a for loop -

i trying find way count number of processes created in loop of length 10 fork() call. easy see result 2^n n calls, need way compute in program. i have found identical question in here . however, when tested second solution given here, works ok number of forks less 10. 10, yelds 256. why that? , there solution problem? (apart using pipes). here actual code: for(i=1; i<=10; i++) { fork(); printf("the process pid=%d\n", getpid()); } there 1 byte exit status of process. therefore, cannot count higher 255 via process exit codes. furthermore, quirk of specific algorithm tried happens produce maximum possible exit status (to parent process adds 1 256 ). exit() function uses least significant 8 bits of argument (and returning x main() has same effect calling exit(x) ). to count higher, need different approach. establish counter in shared memory, , have each child process increment (with appropriate synchronization). runs cleanly, shared memory n

How to fill multiple areas with different colours in a map & adding labels so as not overlapping each other in R? -

this follow question earlier post . i have been able of way answer help. still trying fill function work correctly. have each padd in data set different colour. padd made of number of states. here data: structure(list(state = structure(c(1l, 2l, 3l, 4l, 5l, 6l, 7l, 8l, 9l, 10l, 11l, 12l, 13l, 14l, 15l, 16l, 17l, 18l, 19l, 20l, 21l, 22l, 22l, 23l, 24l, 25l, 26l, 27l, 28l, 29l, 30l, 31l, 32l, 32l, 33l, 34l, 35l, 36l, 37l, 38l, 39l, 40l, 41l, 42l, 43l, 44l, 45l, 46l, 47l, 48l, 49l, 50l), .label = c("alabama", "alaska", "arizona", "arkansas", "california", "colorado", "connecticut", "delaware", "florida", "georgia", "hawaii", "idaho", "illinois", "indiana", "iowa", "kansas", "kentucky", "louisiana", "maine", "maryland", "massachusetts", "michigan", "m

python - PyQt QTableWidget signal emitted when selecting no rows -

i have qtablewidget in pyqt single row selection set. connecting itemselectionchanged call row selection function , take action on selected row. detect when user selects inside qtablewidget , selects empty space (no row selected), can deselect selected row. similar how "windows explorer" works file selections. what signal triggered when selecting blank area inside qtablewidget ? how can accomplished? check mouse-press events see if clicked item none : class table(qtgui.qtablewidget): def mousepressevent(self, event): if self.itemat(event.pos()) none: self.clearselection() qtgui.qtablewidget.mousepressevent(self, event) or if can't subclass, use event-filter: class window(qtgui.qwidget): def __init__(self): ... self.table.viewport().installeventfilter(self) def eventfilter(self, source, event): if (event.type() == qtcore.qevent.mousebuttonpress , source self.table.view

elasticsearch - Rotating logstash logs holding onto file handle. Can I force it to write to a new log? -

so have been experimenting rotating logs in logstash. created script rotate logs because logrotate undesirable in environment. said rotates logs correctly logstash still writes old file after renaming , moving file. i hesitant delete said file @ risk of causing service crash. few other posts indicated let go of file handle after few hours been days multiple renames , still writes same file. the config options offer max file size according documentation isnt supported yet. there way force logstash write new log file without restarting service?

apache - how to configure nginx to rewrite all the requests to a bootstrap php file -

i'm planning migrate apache nginx, rewritting stuff keep dragging me down. depressed! when in apache .htaccess , have single line right thing: rewriterule .* index.php/$0 [pt,l] that means like: http://example.com/a/b/c/d will rewritten to: http://example.com/index.php/a/b/c/d when stepped nginx, expecting same thing single line of code in conf: rewrite ^(.*) /index.php/$1 last; but, keeps giving me 404 page?! it's single line of code indeed: try_files $uri $uri/ /index.php?$args;

c# - How to add images in a objectlistview -

i extremely confused on how use control properly, attempts create media library , show cover art of movies in detailed view not understanding how associate particular column particular image. advice/tips? i have model object using contains movie details public class moviedetails { public string moviename { get; set; } public string key { get; set; } public string id { get; set; } public string coverarturi { get; set; } public string movieuri { get; set; } public string downloaduri { get; set; } public int itemcount { get; set; } } //setup columns generator.generatecolumns(objectlistview2, typeof(moviedetails), true); //show movies a-z displayallmovies(); public void displayallmovies() { try { objectlistview2.updateobjects(movies); } catch (exception) { throw; } } and how

ruby on rails - Validations with Active Admin -

i have 2 models, event , image: class event < activerecord::base has_many :images accepts_nested_attributes_for :images validates :date, presence: true validates :location, presence: true validates :name, presence: true end class image < activerecord::base belongs_to :event mount_uploader :file, avataruploader validates :file, presence: true validates :event, presence: true end here migrations: class createevents < activerecord::migration def change create_table :events |t| t.date :date t.string :location t.string :name t.timestamps end end end class createimages < activerecord::migration def change create_table :images |t| t.string :file t.string :caption t.boolean :featured_image t.integer :event_id t.timestamps end end end i using carrierwave upload image. have no problem getting feature work when no validations built in, i'm trying prevent image being uploa

virtual machine - Creating Hyper-V VMs with unique names using Powershell -

i'm trying make sort of script creates new vm, need told create unique vm name (with sort of logic, if possible, check existing names , using different automatically or telling me use else) . understand new vm made using unique guid default there no system conflicts, further need script go in , perform commands on vm, such starting vms, copying files onto it, etc. without unique name i'm not sure how script can automatically give commands right one. for example, have: new-vm testserver1 -asjob -generation 2 -memorystartupbytes 8192mb -novhd -switchname vswitch-1 but if vm named 'testserver1' exists, , have script automatically run: start-vm testserver1 both vms turn on... edit: also, know 1 can export results of creating new vm using 'out-file' don't know cleanest way format output read later.

I need user's email address after successful facebook login in android using SDK 4.0 -

i have integrated latest facebook android sdk 4.0. in sdk 3.0+ user's email address retreived using user.getproperty("email") after successful login. looking corresponding command in facebook android sdk 4.0 reference links: https://developers.facebook.com/docs/facebook-login/android/v2.3#overview https://developers.facebook.com/docs/android/upgrading-4.x @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); facebooksdk.sdkinitialize(getactivity().getapplicationcontext()); callbackmanager = callbackmanager.factory.create(); } @override public void onviewcreated(view view, @nullable bundle savedinstancestate) { super.onviewcreated(view, savedinstancestate); loginbutton = (loginbutton) view.findviewbyid(r.id.login_button); loginbutton.setreadpermissions("email", "user_likes", "user_friends"); loginbutton.setfragment(this); setfacebooklogintext(loginbutton);

multithreading - Forcing MPI to use a specified no. of cores -

i kinda new mpi, forgive me if trivial question. have quad core cpu. , want run openmpi c++ program uses 2 processes on single core. there way so? if so, how? referred this link on stack overflow which, most probably , says there might way... if so, how can it? since mpi spawns separate processes, scheduling of processes onto cores generally/usually performed operating system. can still achieve want manually setting affinity of processes specific core. you can in linux using sched_setaffinity function. to pin process specific core, can use following approach: #include <mpi.h> #include <sched.h> // ... void pin_to_core(int cpuid) { cpu_set_t set; cpu_zero(&set); cpu_set(cpuid,&set);

javascript - select method fails in Firefox and Chrome -

when user enters "junk" in input field 1, blur event triggers function notify them of error , select() 's field triggering error. works fine in ie , safari firefox , chrome skip right on select() . if use firebug step through code, works designed. here sample of code: function checkforjunk(fld) { if (fld.value == 'junk') { alert('please take out junk'); fld.select(); } } <form name="junk" action="junk.htm" method="post"> input1: <input type="text" name="morejunk" value="" onblur="checkforjunk(this);" /> <br> input2: <input type="text" name="evenmorejunk" value="" onblur="checkforjunk(this);" /> </form> it works fine me on chrome when put select in settimeout settimeout(function() { fld.select(); }, 1);

android - display bitmap setImageBitmap -

in application android, trying receive image server socket, can't display them setimagebitmap(). don't have error, screen stay white. here code : public class communicateurandroid implements runnable { public communicateurandroid(socket s, imageview img) { _imagev = img; try { _din = new datainputstream(s.getinputstream()); _dout = new dataoutputstream(s.getoutputstream()); } catch (ioexception e) { e.printstacktrace(); } new thread(this).start(); } public void run() { int length = 0; byte tmp; while (true) try { length = _din.readint(); byte tab[] = new byte[length]; (int = 0; < length; i++) { tmp = _din.readbyte(); tab[i] = tmp; } _image = bitmapfactory.decodebytearray(tab, 0, tab.length); system.out.println("----------"); if (_im

Mendix: The FileManager widget and uploaded file extensions -

when using filemanager widget upload files, backing filedocument entity contain binary contents of uploaded file , metadata file. problem don't know within filedocument entity can find uploaded document's file extension. see there filedocument attribute called "name", value doesn't contain file extension. example, when uploading "myfile.txt" name attribute "myfile". know full name being persisted somewhere assume there easy way me grab it, don't know look. need full file name extension because storing newly uploaded document remote file-server via web-service. thanks. the name attribute you're looking for. contains full file name , extension. somewhere in application, name getting changed or extension stripped off.

ssis - choosing the value of BypassPrepare property -

i know setting "bypassprepare" property true means preparing (parsing) query done database engine i'm connecting to. otherwise preparation done integration services package how matter whether parsing done on ssis side or database engine side. want make best choice. thanks , if set option true preparing (i.e. parsing) done database engine connecting to. if set option false preparation done integration services package. this option available oledb type connections , introduced because pacakge (sql task) cannot prepare/parse sql commands oledb database supports. meaning error in parse phase , not able execute statement valid statement on oledb database cannot prepared/parsed sql task.

javascript - Generate input field using jQuery's append -

issue: attempting append input field modal window, containing value inserted user, existing panel. far user able create new field modal , add it, however, part of edit page, want input added input field. here working code: bootply example . want newly generated field formatted same existing fields because become part of giant form allowing submitted , update operational page. question: have format within append function declare other formatting constraints? or can somehow set attributes within 'cloudcontainer' div input being appended to? also, should using .html function instead of append? performance not concern here. thanks you have append same formatted input tag have generated in beginning , add form value it $("#clickme").click(function(){ $('.cloudcontainer').append('<div class="cloud"><p><b>'+$('#fieldtitle').val()+': </b><input style="display: inline; width: 325px;

android - Foreign Key Constraint Failed 787 causing abort on attempt to insert entry into table -

trying insert accounts table. data collected fine , thing runs smooth until after confirms account added. @ point operation aborted due foreign key constraint failure shown here : logcat 04-01 22:58:58.750 23053-23053/? e/sqlitelog﹕ (787) abort @ 37 in [insert accounts(terms,amount,accountname,datecreated,status,balance,purpose,payperiod) values (?,?,?,?,?,?,?,?)]: foreign key constraint failed 04-01 22:58:58.999 23053-23053/? e/sqlitedatabase﹕ error inserting terms=0 amount=10000 accountname=acc 1 datecreated=04-01-2015 22:58:58 status=1 balance=10000 purpose=test payperiod=1 i've pulled dbfile , opened check if tables accounts referenced we're populating , are. i've ran database schema in sqlfiddle see fails , ran without problems. now i'm lost , don't know should looking for, if can point me in direction of mistake appreciated. database helper oncreate @override public void oncreate(sqlitedatabase db) { db.execsql("create table

javascript - Manage dependency of dependencies with Bower -

i have angular app has bower dependencies. angular-gridster has in bower.json : "dependencies": { "jquery-ui": "*", } that meant computer hadn't updated in while, has older version of jquery-ui. coincidentally enough, version of jquery-ui works, whilst newer 1 doesn't. for quick fix, force gridster use older version? i guess modify there in bower.json file, seems hacky, best course of action achieve this? on bower.json can this: "dependencies": { "jquery-ui": "1.0", "angular-gridster": "5.0" }, "resolutions": { "jquery-ui": "1.0" }

c# - Cleaning up FileInfo.name switch/case statement with an interface -

i have following: foreach(var file in today.getfiles()) { if(file.length > 0 && file.extension == ".txt") { switch (file.name) { case "realy_long_ugly_file_name_0": //do break; case "realy_long_ugly_file_name_1": //do else break; } } } i have come across this post , thought clean code using interface . right application situation? have set interface , inheritance don't quite know how proceed. i understand interface calling different class based on ipizza member in ilist<ipizza> . have hard time understanding how can pass in file.name (formerly done switch/case ) interface call different classes. interface imyfiles { void process(fileinfo file); } public class filename0 : imyfiles { void imyfiles.process(fileinfo file) { //do somthing specific filename0 } } public class

SQL Server performance of copied database -

i encountered problems sql server performance. i have daily process using 15gb size database. i'm executing lot of scripts. the thing is, first step copy original database, , work on copy. , surprising me, queries on copy executing few times slower on original one. i'm not expert in databases, don't know might reason. to compare: query "a" took: 50 seconds on original database 600 seconds on copied database thank interest, dejvid

Map System.Drawing.Image to proper PdfName.COLORSPACE and PdfName.FILTER in iTextSharp -

i'm using itextsharp update image object in pdf modified system.drawing.image. how set pdfname.colorspace , pdfname.filter based on system.drawing.image? i'm not sure system.drawing.image properties can used mappings. private void setimagedata(pdfimageobject pdfimage, system.drawing.image image, byte[] imagedata) { prstream imgstream = (prstream)pdfimage.getdictionary(); imgstream.clear(); imgstream.setdata(imagedata, false, prstream.no_compression); imgstream.put(pdfname.type, pdfname.xobject); imgstream.put(pdfname.subtype, pdfname.image); imgstream.put(pdfname.width, new pdfnumber(image.width)); imgstream.put(pdfname.height, new pdfnumber(image.height)); imgstream.put(pdfname.length, new pdfnumber(imagedata.longlength)); // not sure how set these entries based on image properties imgstream.put(pdfname.bitspercomponent, 8); imgstream.put(pdfname.colorspace, pdfname.devicergb); imgstream.put(pdfname.filter, pdfname.dctdeco

mongodb - Meteor: record in db updating, but data not changing on screen -

here's simplified version of have in 1 of templates: {{#each datarecord}} {{#if editingnow}} <tr class="datarow"> <td><button class="updaterecord" id="{{this._id}}">sav</button></td> <td><input type="text" id="{{this._id}}" value="{{this.f}}"></td></td> </tr> {{else}} <tr class="datarow"> <td><button class="edit" id="{{this._id}}">edit</button></td> <td>{{this.f}}</td> <td><button class="deleterecord" id="{{this._id}}">del</button> </td> </tr> {{/if}} {{/each}} editingnow returns value of boolean session variable starts out false. when page loads, user sees value of 'f' field each record , edit button. edit button flips session variable true , data shown using input element. user can edit

php - Laravel 5 - paginate Eloquent collection -

model: class category extends model { public function trainings() { return $this->hasmany('app\training'); } } controller: return view('category', [ 'trainings' => category::find(1)->trainings->paginate(10) ]); i'm getting call undefined method illuminate\database\eloquent\collection::paginate() error. how can paginate eloquent collection in laravel 5? you have call trainings method: category::find(1)->trainings()->paginate(10) // ^^

knockout.js - Knockout checked and click both (prevent double checkbox switch) -

i have checkbox described this: <input id="checkbox1" type="checkbox" data-bind=" click: function () { handle_compare($element) }, checked: is_product_compared"> .handle_compare() inverts observable "is_product_compared", problem allow normal behavior checkbox, if click on it, seems double switches, , never see changes. if bind handle_compare button - ok, checkbox switches normally. there way allow both bindings? you can see demo here, button ok, checkbox has wrong behavior. http://jsfiddle.net/g5rpcw2c/1/ you need inline click handler return true: http://jsfiddle.net/g5rpcw2c/2/ either: <input id="checkbox1" type="checkbox" data-bind=" click: function () { handle_compare($element); return true; }, checked: is_product_compared"> or (since handle_compare returns true): <input id="checkbox1" type="checkbox" data-bind=" click: f

javascript - Pass package name into Gulp task -

is possbile pass things such package.json name gulp task? instance, like: <%= pkg.name %> you can require package.json , it'll return object. var pkg = require('./package.json'); gulp.task('default', function() { console.log(pkg.name); }

c# - The RegularExpression data annotation is not being recongnized by the Validator -

i believe code pretty self-explanatory. why isn't regularexpression attribute being used validator ? license.cs: public class license { [required] [regularexpression("([0-9a-f]{4}\\-){4}[0-9a-f]{4}")] public string code { get; set; } } licensetest.cs [testmethod] public void testvalidationofcodeproperty() { // these tests pass know regex not issue assert.istrue(regex.ismatch("abcd-ef01-2345-6789-ffff", "([0-9a-f]{4}\\-){4}[0-9a-f]{4}")); assert.isfalse(regex.ismatch("abcd-ef01-2345-6789-ff00", "([0-9a-f]{4}\\-){4}[0-9a-f]{4}")); assert.isfalse(regex.ismatch("3331313336323034313135302020202020212121", "([0-9a-f]{4}\\-){4}[0-9a-f]{4}")); // setup validator license lic = new license(); var ctx = new validationcontext(lic); var results = new list<validationresult>(); // passes - tryvalidateobject returns false because required field empty lic.code =

gwt - GWTP Invalid attempt to reveal errorplace, but then works normally -

i have couple of places set up, , work correctly, except delay caused issue. they're using nested presenters. 1 place, appears repeat attempt load causes infinite loop of reveal error / unauthorized place (no idea why, no gatekeeper set), loads page correctly. issue have delay , unnecessary log spam causes - loads page correctly, why can't without going through loop first? have ideas? -- update -- i using gwtp 1.4 gwt 2.7.0, project first created using gwtp 0.6 or maybe earlier. we've updated deprecation etc we've upgraded, know there anachronisms left. tried switching out our clientplacemanager default, bound errorplace , unauthorizedplace our home page, , removed gatekeeper, still tries go error place (overrode revealerrorplace method , noticed it's throwing error valid token had been loaded @ least once session. 1 page in particular, none of presenter lifecycle phases firing, though presenter visible (only breaking in firefox think). don't unde

How to get a slack user by email using users.info API? -

i'm trying use slack's users.info api retrieve users information, need find users email, there way that? thanks! currently can users users.info id. an alternative solution problem call users.list , filter within client profile.email whichever email you're looking for.

handlebars.js - Handlebars templatig: Difference between empty list and list not given -

i creating summary emails recent activities can configured recipient. using mandrill handlebars templating syntax , {{#each objects}} passing in objects . that works fine. , can use {{else}} display message when list empty. (that event hasn't happened in referenced period of time) but want give user option never see summary particular kind of event (no matter whether exist or not). tried using {{#if objects}} , not adding parameter user. results in entire block not showing when list empty. in case want "no recent activity in category" has been working fine far. tl;dr: how differentiate between parameter not given , empty list given handlebars.

javascript - jQuery click action stripped out by sorting function -

i have function, including following code: $(list).append(item); $(list).html( $(list).children("li").sort(function (a, b) { return $(a).val() - $(b).val(); })); $(item).click(this.listclick); (basically, creating <ul> <li> array of items, including listclick function fires when of list items clicked, , sorting list according li value ). if strip out sort function script, works fine (as in, list compiled, click-function working perfectly, albeit not in correct order). however, if sort list, strips out click-functionality (i..e. clicking items doesn't perform listclick function). why being stripped out? doesn't seem matter whether place sort function before or after listclick line added. that's because using html method replaces html content of element , has nothing sort method. old elements removed , attached event handlers too. should either use event delegation or better use appendto instead of html : $(

objective c - NSURLConnection returning error instead of response for 401 -

i have web api that, specific request returns status code 200 if went ok, , 401 if user not logged in based on authorization token. works fine if response status 200, doesn't seem work if response status 401, returning connection error code -1012, while response nil. so, following code: [nsurlconnection sendasynchronousrequest:request queue:queue completionhandler:^(nsurlresponse *response, nsdata *data, nserror *connectionerror) { nslog(@"%@", response); nslog(@"%@", connectionerror); nshttpurlresponse *httpresponse = (nshttpurlresponse *) response; int statuscode = (int)[httpresponse statuscode]; nslog(@"response status code: %d", statuscode); will display 2015-04-01 15:58:18.511 myproject[3618:694604] <nshttpurlresponse: 0x155facc0> { url: *some_url* } { status code: 200, headers { "access-control-allow-headers" = "content-type, accept, x-requested-with"; "access-control-allow-m

javascript - Check/Uncheck using jQuery not working -

i trying make check boxes behave radio buttons in asp .net mvc web application. have got 20-30 check boxes grouped in two. example: <input type="checkbox" id="@riggingtype.riggingtypeid 1" name="riggingtypeplus" value="@riggingtype.riggingtypeid" checked="@riggingtypeids.contains(riggingtype.riggingtypeid)" /> <input type="checkbox" id="@riggingtype.riggingtypeid 2" name="riggingtypeminus" value="@riggingtype.riggingtypeid" checked="@riggingtypeids.contains(riggingtype.riggingtypeid)" /> goal: i want make check boxes behave in such way if plus check box checked minus unchecked automatically , vice versa. have written following code try , achieve functionality: $(":checkbox").change(function () { var inputs = $(this).parents("form").eq(0).find(":checkbox"); var idx = inputs.index(this); if (thi

html - How to set color to text within <a href> -

i have following auto-generated markup: <th id="__id__th__" class="__generated_classes__"> <a href="#" id="__id__a__" class="__other__generated_classes__"> text </a> </th> i need apply color: #21610b; . issue th , a tags generated ui -framework, can't directly affect them. thing can apply style attribute both th , a tags. html <th id="__id__th__" class="__generated_classes__"> <a href="#" id="__id__a__" class="__other__generated_classes__" style="color: #21610b;"> text </a> </th> as style inline, overwrite other styling set. javascript if unable that, can use bit of javascript change font color. pure js: var x = document.getelementbyid('someid'); x.style.color = '#21610b'; jquery: $( document ).ready(function() { $('#somei

collaboration - Remote Website JavaScript library -

i looking javascript library allow me invite people "session" 1 person leader , other person spectator. spectator sees leader sees on website. awesome if script allowed switch roles (who leader , spectator). i googled lot , found togetherjs, looking for. problem togetherjs there quite lot of problems forms (as 2 people click on same stuff , on). there library out there, more "remote desktop" solution web pages?

c# - WPF Image RenderOptions.BitmapScalingMode.LowQuality consumes 10x more memory than HighQuality -

Image
i have image 5k x 5k pixels. image contains layouttransform scaletransform. <image x:name="image" source="{binding imagesource, mode=oneway}" width="{binding imagewidth, mode=oneway}" height="{binding imageheight, mode=oneway}" visibility="{binding imagevisibility, mode=oneway}" renderoptions.bitmapscalingmode="highquality" renderoptions.edgemode="aliased"> <image.layouttransform> <scaletransform scalex="{binding scalevalue, mode=oneway}" scaley="{binding scalevalue, mode=oneway}"/> </image.layouttransform> </image> since scaling image slow due highquality option, decided set lowquality during scaling process. turns out lowquality option consumes more memory highquality can see in screenshot. renderoptions.setbitmapscalingmode(image, bitmapscalingmode.lowquality); //reduce quality during resize improve performance (or not :() the memo

objective c - Set a UIView in a fixed proportional position from the Right Edge of screen iOS -

say, have uiimageview or object , set in uiview subview cgrectmake this: uiview *headerview = [[uiview alloc] initwithframe:cgrectmake(0, 0, self.view.frame.size.width, 30)]; uiimageview *imgview = [[uiimageview alloc]initwithframe:cgrectmake(266, 0, 30, 30)]; [imgview setimage:[uiimage imagenamed:[self.imagedickey objectatindex:section]]]; [headerview addsubview:imgview]; here set position of imgview cgrectmake(266, 0, 30, 30)]; , counts it's position form left x position (which 266). if want set imgview 's position right side of screen? that,in different width of iphone screen shows in same ratio position. counted it's position right edge. lot in advanced. i recommend not hard coding exact positions , instead calculating x , y. way different sized screens it's not exact position , rather it's based upon views' size. uiview *headerview = [[uiview alloc] initwithframe:cgrectmake(0, 0, self.view.frame.size.width, 30)]; cgfloat p

html - Wordpress Template CSS issues -

i have modified website template colour has changed. the wordpress template uses .less files default settings admin panel when changing settings , saving console style.css file rewritten. i modified style.css file , use couldn't find of css code in .less files. after changing colours in style.css file of active items change colour on mouse roll on or off , change white result on disappearing on white background. problem can't find location in code change these!! have attempted examining elements in browser, following file locations , names, searching colour codes too. what best way find them? thank you. you need change css .btn then. try adding custom css inside template settings page , add !important rules apply. the magnifying glass class .btn work of buttons. i guess don't want border-bottom: red property!

ios - How to display my search results in UICollectionView -

Image
i have uiview has 2 textfield,two labels ,uicollectionview, , 1 search bar.i want add searchdisplaycontroller , searchbar uiview. i have linked datasources , delegate search. searchbar=[uisearchbar new]; searchdisplaycontroller=[[uisearchdisplaycontroller alloc]initwithsearchbar:searchbar contentscontroller:self]; searchdisplaycontroller.delegate=self; searchdisplaycontroller.searchresultsdelegate=self; searchdisplaycontroller.searchresultsdatasource=self; [self.view addsubview:searchbar]; my problem searchdisplaycontroller has results in searchresultstableview , can populated tableview delegates have uicollectionview. how can display search results in collection view delegate methods? view looks this: with uisearchdisplaycontroller, simple: create uisearchbar , add custom uicollectionview section header, initialize uisearchdisplaycontroller search bar have @ answer: https://stackoverflow.com/a/24992762/2082569

php - PDO fetchAll Results returns only one record issue -

i have developed following script in localhost (using wamp 2.2, apache 2.2.1 windows, php 5.3.9, mysql 5.5.20). when upload script production server (apache 2.2.29 unix, php 5.3.29, mysql 5.5.42) i noticed php+pdo script did not return fetched rows in same way same script in local server. if try add "order by" sql instance, works on local in production server resulted fetched row same. also tryed change inner join table order same result. clues? maybe wrong inner join php + pdo: $user = ''; $pass = ''; $dsn = 'mysql:host=myhost;dbname=mydbname;charset=utf8'; try { $pdo = new pdo($dsn, $user, $pass); $pdo->setattribute(pdo::attr_errmode, pdo::errmode_exception); } catch (pdoexception $e) { echo 'error: ' . $e->getmessage(); } function contents($id) { global $pdo; $stmt = $pdo->prepare('select historia.id idhistoria, pub_us.comic, pub_us.id historia inner join pub_us on pub_us.historia = histor

android - JSON and location distance calculate -

i planning this. first device location , info json. json includes latitude , longitude. after, calculate every items distance device. if less x number show in list view. have used use json parsing , list view basic. and here code location calculate location locationa = new location("point a"); locationa.setlatitude(lata); locationa.setlongitude(lnga); location locationb = new location("point b"); locationb.setlatitude(latb); locationb.setlongitude(lngb); float distance = locationa.distanceto(locationb); i use code. i think this. json items. before on list check distance if lover x put in list else return getting json item i need codes it. so have code calculate distance 2 points coordinates? make web page. can save coordinates database, when have phone position can take coordinates near position (like filter). after can use code check witch coordinates inside range x , put class contain coordinates. your coordinates class: p

Displaying a pop up message in javascript for my rails application -

question in rails application have method in user controller auto populate. fills in form new user when signing .when fill in emp_id text box looks @ employee table pulling data if id matches emp_id typed auto populate thier emp_first_name , emp_last_name. able have pop message when data returns has data but, im stuck on how make show message if no data exist perticular emp_id... this controller class usercontroller < applicationcontroller def populate_form @visual = visual.find_by_id(params[:emp_id]) if @visual.nil? respond_to |format| format.json { render json: @user, status: :unprocessable_entity, flash[:error] => "error no id found." } #this didn't work no message displays.. end else @emp_first_name = @visual.first_name @emp_last_name = @visual.last_name render :json => { :emp_first_name => @emp_first_name, :emp_last_name => @emp_last_name

ruby / rails: TypeError: can't convert Symbol into Integer -

i'm trying update representation attributes ivpn & idirect (from csv file via rake task print here meat of program) , getting typeerror: # in rails console: representation = representation.where(id: 977) # => representation_id: 977, ivnp: false, idirect: false rows = hash.[:ivpn => "", :idirect => "x"] # rows coming csv-file representation.update_attributes! ivpn: rows.any?{|r| r[:ivpn].present?}, idirect: rows.any? {|r| r[:idirect].present?} typeerror: can't convert symbol integer (irb):42:in `[]' (irb):42:in `block in irb_binding' (irb):42:in `each' (irb):42:in `any?' what i'm missing here? try this: representation.update_attributes! ivpn: rows.any?[{|r| r[:ivpn].present?}], idirect: rows.any? [{|r| r[:idirect].present?}]

Throwing custom error messages in java struts -

are there useful patterns or best practices throwing/showing user friendly error messages in struts 1? if(something nasty...) { throw new userexception("very bad thing happened"); } else if(something other nasty...) { throw new userexception("other thing happened"); } .... other 100 cases because using above sample in validate() method on , on again seems bit redundant , unprofessional. create actionmessage(s) , display these. there better information here can give you: http://www.mkyong.com/struts/struts-logic-messages-present-logic-messages-notpresent-example/

Qt Creator 3.3.2: Moving views -

Image
in previous version of qt creator (i don't know one), drag , drop views. in version use (3.3.2), apparently not possible. is possible move views in 3.3.2, , if so, how? see below want achieve. also, screenshot of windows -> views menu. thanks! just disable "automatically hide view title bars" in views menu second screenshot. should have title bar above each view draggable.

node.js - Is there a way to retrieve data of a Google Form ITSELF (not spreadsheet) using Javascript? -

i build node.js server , use retrieve data of google form, like: title, type, options of questions on form. e.g. if have google form: http://goo.gl/forms/dsnfs0cfgw i somthing like: var form = getformdata(); // returns // [ // {title: "name", type: "text", options:[]}, // {title: "favorite season", type: "select", options:["spring", "summer", "autumn", "winter"]}, // {title: "favorite fruit", type: "radio", options:["apple", "banana"]} // ] is there way using javascript or node module? i don't see lot of options aside whipping cheerio , parsing html source. cheerio looks , feels lot jquery, if you're familiar that, shouldn't have lot of problems.

javascript - Disable certain selected option for its counterpart from dropdown -

i have 2 dropdowns. when select option one , want option five disabled second dropdown. how can achieve that. below dropdown code. <form> <select class="myselect"> <option>one</option> <option>two</option> <option>three</option> </select> </form> <br> <form> <select class="myselect"> <option>four</option> <option>five</option> <option>six</option> </select> </form> here's fiddle that. first of 1 thing should notice cannot use same ids multiple elements in 1 single page. id has unique each element. in case can change class : $('.myselect:eq(0)').change(function(){ $('option:contains(five)').prop('disabled', this.value == "one"); }).change(); // <---this makes sure fire change event on doc ready // because have option valu

.net - Split collection into n of parts is not giving the desired resulting secuences -

i'm trying split collection specific number of parts, i've taken seeying solutions on stackoverflow: split collection `n` parts linq? this vb.net translation @hasan khan solution: ''' <summary> ''' splits <see cref="ienumerable(of t)"/> specified amount of secuences. ''' </summary> public shared function splitintoparts(of t)(byval col ienumerable(of t), byval amount integer) ienumerable(of ienumerable(of t)) dim integer = 0 dim splits ienumerable(of ienumerable(of t)) = item t in col group item item = threading.interlocked.increment(i) mod amount group select group.asenumerable() return splits end function and vb.net translation of @manu08 solution: ''' <summary> ''' splits <see cref="ienumerable(of t)"/> specified amount of secuen

html - Why my DIV wont get down? -

im having little issue here. html. <div class="one"> </div> <div class="two"> <ul class="ulclass"> <li>dasda</li> <li>qweqw</li> </ul> </div> this css: .one{ width: 100%; height: 300px; background-color: black; } .two{ margin-top: 0px; display: block; padding: 0px; margin-bottom: 0px; } .ulclass{ list-style-type: none; margin:0px; margin-bottom: 0px; } .ulclass li{ width: 500px; padding: 10px; overflow: auto; float: left; } my problem divs next each other , not above other. looks this. http://oi57.tinypic.com/2lm5e1i.jpg want green 1 down black one. have tried lot of things , cant it... please me. sorry if newbie stuff. thanks. forget, divs inside div wich container here css: .rost{ height: 100%; min-height: 300px; background-color: #fff; padding: 0px; padding-left: 0px; box-shadow: 0 0 28px rgba(0, 0, 0, .6); display: flex;

How to add cordova AppRate plugin to Intel XDK? -

i have added plugin cannot setup config file(intelxdk.config.additions.xml). if add code config: var customlocale = {} customlocale.title = "rate %@"; customlocale.message = "if enjoy using %@, mind taking moment rate it? won’t take more minute. support!"; customlocale.cancelbuttonlabel = "no, thanks"; customlocale.laterbuttonlabel = "remind me later"; customlocale.ratebuttonlabel = "rate now"; apprate.preferences.openstoreinapp = true; apprate.preferences.storeappurl.android = 'market://details?id=com.site.test'; apprate.preferences.customlocale = customlocale; apprate.preferences.displayappname = 'my custom app title'; apprate.preferences.usesuntilprompt = 1; apprate.preferences.promptagainforeachnewversion = false; apprate.promptforrating(true); nothing happing when test app on real device. first off, go project tab. go in plugins-> third party plugin

android - SplunkMint lib throwing exception, SocketException: shutdown failed: EBADF -

i started using splunk mint , working fine, throwing many exceptions logcat , rid of them. 04-01 11:18:03.142: w/system.err(21409): com.splunk.mint.network.util.delegationexception: java.net.socketexception: shutdown failed: ebadf (bad file number) 04-01 11:18:03.143: w/system.err(21409): @ com.splunk.mint.network.util.delegator.invoke0(delegator.java:62) 04-01 11:18:03.143: w/system.err(21409): @ com.splunk.mint.network.util.delegator.invoke(delegator.java:45) 04-01 11:18:03.143: w/system.err(21409): @ com.splunk.mint.network.socket.monitoringsocketimpl.shutdownoutput(monitoringsocketimpl.java:417) 04-01 11:18:03.145: w/system.err(21409): @ java.net.socket.shutdownoutput(socket.java:652) 04-01 11:18:03.145: w/system.err(21409): @ org.apache.http.impl.sockethttpclientconnection.close(sockethttpclientconnection.java:195) 04-01 11:18:03.145: w/system.err(21409): @ org.apache.http.impl.conn.defaultclientconnection.close(defaultclientcon