Posts

Showing posts from July, 2013

sqlite - rails: How to find entries with empty arrays -

i've got issue finding empty arrays in sqlite table. i serialized product_category param, works saving arrays db, follows: serialize :product_category, array the following query find empty arrays param, giving me nil error: product.where(product_category: []).first how find products product_category has no values in array? i tried using {} instead of [] suggested in similar postgress related question. does know right way? i have tried on mysql, works me, please try. #product.rb serialize :product_category, array #rails console >> product = product.new >> product.product_category = [] >> product.save >> product.where("product_categoty = '[]'") #it returns last record have created. hope help!

java - Why does SimpleDateFormatter returns an error -

this method called , should give time out void msgout(string s) simpledateformat sdf = new simpledateformat("dd.mm.yyyy hh:mm:ss"); string uhrzeit = sdf.format(new date()); msgout("[system] zeit: "+uhrzeit); txtsname.settext(""); txtsname.requestfocus(); } but every time returns error: exception in thread "awt-eventqueue-0" java.lang.stackoverflowerror @ sun.util.calendar.zoneinfo.getoffsets(zoneinfo.java:236) @ java.util.gregoriancalendar.computefields(gregoriancalendar.java:2340) @ java.util.gregoriancalendar.computefields(gregoriancalendar.java:2312) @ java.util.calendar.settimeinmillis(calendar.java:1804) @ java.util.calendar$builder.build(calendar.java:1508) @ sun.util.locale.provider.calendarproviderimpl.getinstance(calendarproviderimpl.java:88) @ java.util.calendar.createcalendar(calendar.java:1666) @ java.util.calendar.getinstance(calendar.java:1655)

AngularJS UI Router Resolve not called second time -

i using angularjs ui router resolves checking if user authentificated. called once. first works should, when try enter page again, skips resolve part , opens page. .state('login', { url: "/login/:state/:stateparams", templateurl: "views/main.html", params: { stateparams: "" } }) .state('placeorder', { url: "/placeorder", templateurl: "views/placeorder.html", params: { neworder: { from: null, to: null, selectedlogtype: null, selectedlogsubtype: null } }, resolve: { auth: function ($cookies, $stateparams, $location) { if (!angular.isdefined($cookies.get('token'))) { $location.path('/login/placeorder/'+json.stringify($stateparams.neworder)); } else { authservice.checktoken().then(function (d) {

r - Counting rows based upon conditional grouping with dplyr -

i have dataframe follows: position_time telematic_trip_no lat_dec lon_dec 1 2016-06-05 00:00:01 526132109 -26.6641 27.8733 2 2016-06-05 00:00:01 526028387 -26.6402 27.8059 3 2016-06-05 00:00:01 526081476 -26.5545 28.3263 4 2016-06-05 00:00:04 526140512 -26.5310 27.8704 5 2016-06-05 00:00:05 526140518 -26.5310 27.8704 6 2016-06-05 00:00:19 526006880 -26.5010 27.8490 is_stolen hour_of_day time_of_day day_of_week lat_min 1 0 0 0 sunday -26.6651 2 0 0 0 sunday -26.6412 3 0 0 0 sunday -26.5555 4 0 0 0 sunday -26.5320 5 0 0 0 sunday -26.5320 6 0 0 0 sunday -26.5020 lat_max lon_max lon_min 1 -26.6631 27.8743 27.8723 2 -26.6392 27.8069 27.8049 3 -26.5535 28.3273 28.3253 4 -26.5300 27.8714 27.8694 5 -26.5300 27.

asp.net - Concat without blank in C# Linq -

i concatenating different address fields in linq query 1 address merge. public static ilist getofferlist() { using (var objentity = new dbcontext()) { string[] listcategoryid = categoryid.split(','); return (from tbl.offermaster select new { primaryid = om.offerid, address = om.streetaddress + " ," + om.city + " ," + om.state + " ," + om.country + " ," + om.zipcode, }).tolist(); } } currently fields like address=fákafen 11 ,reykjavik , ,iceland ,108, or address: " , , , ,",; i want address=fákafen 11 ,reykjavik ,iceland ,108 means blank fields not required. i this. address = string.join(" ," (new string[] {om.streetaddress, om.city, om.state, om.country, om.zipcode}) .where(x=> !string.isnullorempty(x)));

javascript - Polyfill window.showModalDialog in webview -

Image
so creating chrome app embedded <webview> element. embedded webapp contains lot of legacy code such window.showmodaldialog calls (which chrome no longer supports). the thing i'm trying polyfill calls. i've created simple test example: <webview src="http://legacycodeisawesome.com/" style="width:100%; height:100%"></webview> code operating on webview element: webview.addeventlistener('contentload', function() { webview.executescript( { code: 'window.showmodaldialog = function() { console.log ("hello, world");}', runat: 'document_start' } ); }); the above code runs (adding debug console.log works), doesn't it's supposed do, overwrite showmodaldialog function. is there sort of restriction on overwriting functions on window object in webviews? there way around it? when call webview.executescript , create content script . one of core pr

javascript - How to access Model Data in Ajax response -

i have 2 forms, consider form1 , form2, both mvc forms only. these forms using 2 different view models shown below : public class form1viewmodel { //some public properties public string querystring { get; set; } } public class form2viewmodel { //some public properties public string previousquerystring { get; set; } } in controller post action i'm writing : [httppost] public actionresult processform1(form1viewmodel form1obj) { //some logic goes here //i'm preparing querystring form1 data , appending form2 model form2viewmodel form2obj=new form2viewmodel(); form2obj.previousquerystring = form1obj.querystring; return view("form2",form2obj) ; } and in form1, i'm submitting through jquery ajax as frm.submit(function(ev) { var formdata = frm.serialize(); $.ajax({ type: "post", url: 'controllername/processform1', data: formdata, success: function(response) {

jquery .change() function not working on dynamically changed element -

i have 1 button , 2 select elements. in jquery code there 2 event handlers: if click button 1st select box changes. if first select box changed second box changes. so if click button 1st select box change , 1st select box has changed second select box should changed well. second box not changing. here code. there live link of code. <button id="b_a_1"> click select 2nd element </button> <br><br><br> : <select id='s_a'> <option value=1>1st element</option> <option value=2>2nd element</option> <option value=3>3rd element</option> <option value=4>4th element</option> </select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b : <select id='s_b'> <option value=1>first element selected</option> <option value=2>second element selected</option>

Saving Array to Realm in Swift? -

is possible save array of objects realm ? anytime make change array should saved realm. my current solution save object object for loop . append/modifying objects calling save() job, not when remove object it. class customobject: object { dynamic var name = "" dynamic var id = 0 override static func primarykey() -> string? { return "id" } } struct realmdatabase { static var sharedinstance = realmdatabase() var realm: realm! let object0 = customobject() let object1 = customobject() var array = [object0, object1] init() { self.realm = try! realm() } func save() { object in self.array { try! self.realm.write { self.realm.add(object, update: true) } } } } to save lists of objects have use realm list , not swift array. let objects = list<customobject>() then, can add elements: objects.append(object1) take @ t

Microsoft Dynamics CRM 2013 Asynchronous system jobs status code in progress -

i'm using microsoft dynamics crm 2013 on-premise version. i'm facing issue asynchronous jobs not executing. status reason in progress . suggest how can force system run these workflow/system jobs. when open workflow/system job details tab empty. as per understanding somehow system jobs/workflows not executing, they're on hold. please suggest. please make sure perform steps: restart asynchronous services restart sql server restart iis verify sql memory hope can you.

python - Struggling to get a simple function running from command line -

i'm trying below function running command line using python filename.py however, isn't doing want. could please me out this? i'm sure i'm missing simple... infile = "" infile = raw_input("enter file name: ") x = open(infile, 'w') def summation(x): sum = 0 in x: sum = sum + return sum if __name__ == "__main__": print(summation(x)) hopefully it's self explanatory i'm trying achieve, in case it's not... i'm asking raw_input ; text file full of numbers (each on it's own line). file should fed variable x used in summation function. finally, loop each value summed , sum returned (and printed in terminal). there 2 problems: you're opening file in write mode. deletes contents of file. drop "w" parameter. you can't add strings (as read file) integer. need convert them integers first: sum += int(i) also, should close file after you'

Get UTC Date To Local Date in swift iOS -

i trying convert utc date local date in swift after utc local date in string convert string again in nsdate getting in utc date format, below code date : in utc : 2016-07-20 18:30:00 +0000 i trying date in local date, check below code: let dateinutc = nsdate() let seconds: int = nstimezone.systemtimezone().secondsfromgmt print(seconds) let localdateformatter: nsdateformatter = nsdateformatter() localdateformatter.dateformat = "mm/dd/yyyy hh:mm" localdateformatter.timezone = nstimezone(forsecondsfromgmt: seconds) let lastdate: string = localdateformatter.stringfromdate(dateinutc) print(lastdate) at time getting “07/12/2016 16:56:36 gmt+5:30”, means got local date in string want date in nsdate again convert string date in nsdate,check below let getdate:nsdate = localdateformatter.datefromstring(lastdate)! print(getdate) but @ stage again got date in utc (2016-07-12 11:26:36 +0000) want in local date

visual studio - Angular2 & typescript get error with import -

i'm starting implement simple component based on angular 2 , issue tsconfig.json , import here structure root | node_modules | | | @angular | | | core | platform-broswer-dynamic script | components | myfirstcomponent.ts myfirstcomponentservice.ts here code import { bootstrap } '@angular/platform-browser-dynamic'; // line ok import { component } '@angular/core'; // line ok import { firstservice } 'root/script/components/myfirstcomponentservice'; // line error @component({ selector: 'firstcomponent', template: '<div>my first component</div>', }) export class myfirstcomponent { constructor(public abc : firstservice) { console.log(abc.dosomething()); } } bootstrap(myfirstcomponent, [firstservice]);

php - Add dynamic string in moodle form help icon -

Image
i new in moodle. have requirement add dynamic text in icon created using $mform->addhelpbutton(); function. not able this. can tell me way pass dynamic string in moodles form icon. the addhelpbutton() method has parameter $component contains current text shown when clicking onto icon ( ). text read $string array defined in language file. the trick here array element can built dynamically:-) let's make example: in mod_form.php build icon with: $mform->addhelpbutton ( 'element_name', 'your_identifier', 'your_help_text' ); the text your_help_text read in language file with: $string ['your_help_text_help'] = 'this static text'; here change line with: $string ['your_help_text_help'] = get_dynamic_help_string($any_parameter); and define function: function get_dynamic_help_string($any_parameter) { $text = dynamic text current date: ; $text .= ' '.date("y/m/d"); return $text; } no

angularjs - Angular 2 - Create Component Dynamically - Is it mandatory to call 'detach()' method on the component reference? -

i have angular 2 app need create child components dynamically. is mandatory call ' detectchanges() ' , ' detach() ' method on component reference variable 'componentref.changedetectorref' ? i see things work if dont use them. are these methods meant component injection performance improvement ? @component({ selector: 'container', template: '<template #content></template>' }) export class containercomponet implements afterviewinit { contentcomponentref:any; @viewchild('content', {read: viewcontainerref}) contenthandle; constructor(private componentresolver:componentresolver) { super(); } ngafterviewinit() { if (this.contentcomponentref) this.contentcomponentref.destroy(); this.componentresolver.resolvecomponent(childcomponent) .then((factory:componentfactory<any>) => { let componentref = this.contenthandle.createcomponent(facto

html - Validation is not working mvc -

i can`t find out wrong. trying no allow setting null values field, when user tries it, must show message "*", , wait him set values, doesnot work , null values sent action. model : public class companymaininfomodel { public int companyid { get; set; } [required(errormessage = "*")] [display(name = "company_name", resourcetype = typeof(localization))] public string companyname { get; set; } [required(errormessage = "*")] [display(name = "company_address", resourcetype = typeof(localization))] public string companyaddress { get; set; } [required(errormessage = "*")] [display(name = "company_director", resourcetype = typeof(localization))] public string companydirector { get; set; } [required(errormessage = "*")] [display(name = "company_phone", resourcetype = typeof(localization))] public string companytelephonenumber { get; set; } } ma

java - Draw Line on Graph -

i want create grid of 6*6 next step put image tiles column column in each grid.a complete image composition of tiles in each grid. want draw lines on complete image formed 6*6 grid. have tried jlabel , created 6*6 grid of jlabels , image formed trying draw line on image formed , unable that. line starting end of image on right side. strucked @ point.please tell me in someway. so... want 6*6 image tile grid? can jpanel paint method. if not using jpanel, then: main class public class main{ public static void main(string[] args){ mywindow window = new mywindow(); } } this mywindow class: public class mywindow extends jframe{ public mywindow(){ super.setvisible(true); super.setsize(500,500); mypanel panel = new mypanel(); super.setcontentpane(panel); } } this mypanel class: public class mypanel extends jpanel{ public mypanel(){ super.setsize(500,500); super.setvisible(true); } @ove

database - Updating a particular array element in nedb -

in nedb, have array field in document. how update array element @ index? for example, { fruits:['mango','apple','banana'] } i modify 2nd element , make array ['mango','pear','banana'] . how using db.update ? you can this: db.update({_id:idtoupdate}, { $set:{'fruits[1]':'pear'} }, {}, callback);

concatenation - How to combine 2 4-bit unsigned numbers into 1 8-bit number in C -

i have 2 4-bit numbers (x0x1x2x3 , y0y1y2y3) , want combine them create 8-bit number that: x0x1x2x3 y0y1y2y3 => x0y0x1y1x2y2x3y3 i know how concatenate them in order create x0x1x1x3y0y1y2y3 stuck on how compose them in pattern explained above. any hints? here's direct way of performing transformation: uint8_t result; result |= (x & 8) << 4; result |= (y & 8) << 3; result |= (x & 4) << 3; result |= (y & 4) << 2; result |= (x & 2) << 2; result |= (y & 2) << 1; result |= (x & 1) << 1; result |= (y & 1) << 0;

sql server - Full invoice number + comma separated SQL list (TSQL) -

does perhaps know how comma separated list sql doesn't duplicate - it's little hard explain. let me give example. i have list of invoices + shipment belongs in table below: invoicenumber shipmentnumber 0180376000 1stshipment 0180376005 1stshipment 0180376003 1stshipment 0180375997 1stshipment 0180375993 1stshipment this list needs divided main invoicenumbers followed right 2 digits of remaining invoice numbers. result should similar below. 01803760, 00, 05, 03, 01803759, 97, 93 at point can comma separated list cannot figure out how position 2 digit after each respective invoice belongs to. any suggestion of how great!! try this declare @tbl table (invocenumber nvarchar(50)) insert @tbl values ('0180376000') insert @tbl values ('0180376005') insert @tbl values ('0180376003') insert @tbl values ('0180375997') insert @tbl values ('0180375993') select ( select a.invo

css - Inline styling failing to work with side menu -

i'm not quite sure why cannot seem menu go horizontal instead of vertical. i've followed lot of community posts, using combinations of floats , inline-blocks etc , seems may missing something. here code; <div class="sidebar-left"> <div class="sidebar-links"> <a href="#"><i class="fa fa-tachometer"></i>1</a> <a href="#"><i class="fa fa-tachometer"></i>2</a> <a href="#"><i class="fa fa-tachometer"></i>3</a> <a href="#"><i class="fa fa-tachometer"></i>4</a> </div> </div> .sidebar-left { width: 15vw; height: 0; position: fixed; background-color: black; } .sidebar-left .sidebar-links { margin: 20px auto; } .sidebar-links div { display: inline-block; } .sidebar-left .sidebar-links > { disp

Runnning an IDL code with text file output in Python -

i have number of different codes take text file data input , write different 1 output. 3 of these codes written in python 2.7, 1 written in idl. goal create 1 "master" python program can run of these codes, typing "python master.py". however, because of limitations of system, unable use 'pyidl' or 'pyidly' modules referred in this question . not sure if matters, using linux command prompt. currently 'master.py' code looks this: import os os.system("python pycode_1.py") os.system("idl") os.system(".com idlcode.pro") os.system(".r idlcode,"imputfile.dat"") os.system("exit") os.system("python pycode_2.py") os.system("python pycode_3.py") this code runs first python code , enters idl fine. however, not enter later comands idl. means idl command prompt comes up, cannot run idl code follows. i appreciative advice solve issue. in advance! if have i

The "php" plugin does not exist drupal 8 -

i have strange issue in drupal 8 says: drupal\component\plugin\exception\pluginnotfoundexception: "php" plugin not exist. in drupal\core\plugin\defaultpluginmanager->dogetdefinition() (line 57 of core/lib/drupal/component/plugin/discovery/discoverytrait.php). anyone know how fix this?

c - what is the address pointed by file pointer? -

#include <stdio.h> #include <stdlib.h> int main() { file *file1; char c; file1=fopen("find1.txt","r"); if(file1==null) { printf("\n file doesnt exist\n"); exit(1); } else { while(1) { c=fgetc(file1); if(feof(file1)) { break; } putc(c,stdout); } } } what think how code work fgetc() take character file pointed filepointer , put character in "c".next time takes next character file , put in "c". filepointer increment , point next character?or handeled in other way ? the file1 pointer not incremented. file object points contain (among other things) pointer current stream position, , that updated read or write file.

c# - Adding a context menu only to the Expander header -

Image
i'm trying compose data grid (in mvvm 4.5 project) show data grouped specific property (by use of expanders). works i'd add context menu options " expand all " , " collapse all " collapse/expand groups. event handlers menu item click events being handled in window's code-behind. the problem context menu applied expander , inherited children includes <itemspresenter/> , rows/cells. i want only apply context menu grouped header itself. achievable if it's applied innards (like stackpanel in example below) in case, context menu isn't accessible entire header line, on stackpanel contents/text. i'm planning on using different context menu items (add/edit etc) , have collapse/expand context menu apply group header. achievable? <datagrid name="dgdata" itemssource="{binding myitems}" autogeneratecolumns="false" canuseraddrows="false" canuserdeleterows="false">

excel - How to retrieve the sheet of power pivot window /model back? -

data has been imported power pivot excel tables.these tables shown in separate sheet in power pivot window. created charts , pivot tables these imported tables.saved , closed. can retrieve separate sheet of power pivot window,once closed book? there excel processes in task manager.killed process,reopened.now power pivot option available

python - How to write a list of values to text file with strings and numbers -

i have 3 lists : alist = ['name','name2'] blist = ['desg1','desg2'] inlist = [1,2] i writing text file using follo code snippet: fo = open(filepath, "w") in zip(alist,blist,inlist): lines=fo.writelines(','.join(i) + '\n') but getting follo error: typeerror: sequence item 2: expected string, int found how can write values text file new line character. join expects sequence of str items first argument, inlist contains int values. convert them str : lines=fo.writelines(','.join(map(str, i)) + '\n') i'd suggest use with block while working files. write lines in single statement: with open(filepath, "w") fo: fo.writelines(','.join(map(str, x)) + '\n' x in zip(alist,blist,inlist))

android - Fragment with ListView: NullPointerException on setAdapter -

i have problem, nullpointexeption when want set adapter on listview. before had fragment extended listfragment , simple adapter, works problem was, have 3 fragments in activity listviews , got display errors (shows wrong list in fragment). decided set every fragment own ids on listview doesnt work. error listview.setadapter(adapter): java.lang.nullpointerexception @ de.resper.e2cast.mainfragmentlive.oncreateview(mainfragmentlive.java:46) fragment: import android.os.bundle; import android.util.log; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.arrayadapter; import android.widget.imagebutton; import android.widget.listview; import java.util.arraylist; import java.util.list; import de.resper.e2cast.classes.globalbox; import de.resper.e2cast.helper.getxml; import de.resper.e2cast.helper.parsexml; public class mainfragmentlive extends android.support.v4.app.fragment { private list<string> bo

java - Android: Notifications are not showing in Notification bar -

i trying display notification in notification bar when alarm triggered. below code. alarmreciever.java import android.app.notification; import android.app.notificationmanager; import android.app.pendingintent; import android.content.broadcastreceiver; import android.content.context; import android.content.intent; import android.telephony.smsmanager; import android.util.log; import android.widget.toast; /** * created yohan on 6/29/2016. */ public class alarmreciever extends broadcastreceiver { @override public void onreceive(context context, intent intent) { // todo auto-generated method stub // here can start activity or service depending on need // ex can start activity vibrate phone or ring phone string message="hi there later, see soon";// message send // show toast in above screen shot log.d("alarm",message); toast.maketext(context, "alarm triggered , sms sent", toast

java - Can not convert Base64 String and unGzip it properly -

i have base64 string. trying decode it, decompress it. string texttodecode = "h4siaaaaaaaaaaegan//0jtqtdgc0ldqu9c40lfqunga0l7qstcw0l3qvdgl0lmrcuyiiaaaaa==\n"; byte[] data = base64.decode(texttodecode, base64.default); string result = gziputil.decompress(data); code using decompression: public static string decompress(byte[] compressed) throws ioexception { final int buffer_size = 32; bytearrayinputstream = new bytearrayinputstream(compressed); gzipinputstream gis = new gzipinputstream(is, buffer_size); stringbuilder string = new stringbuilder(); byte[] data = new byte[buffer_size]; int bytesread; while ((bytesread = gis.read(data)) != -1) { string.append(new string(data, 0, bytesread)); } gis.close(); is.close(); return string.tostring(); } i should string: Детализированный insteam of it, getting string question mark symbols: Детализирован��ый what mistake? , how solve it? one problem when conver

java - Keep DROP_DOWN ToolItem highlighted while menu is shown -

Image
i have toolitem swt.drop_down , , selectionlistener popup menu few menuitem . the toolitem highlighted when mouseover, , on click submenu appears. however, toolitem no longer highlighted. there way keep highlighted until select 1 of menu items (or click somewhere else close)? swt uses native widgets of platform runs on. hence, highlighting behavior entirely platforms implementation. i fear there no way highlight tool button while drop-down menu shown.

forms - Lavavel 5.2.36 MethodNotAllowedHttpException in RouteCollection.php line 218: -

hi new laravel , trying implement post request simple form. have been following youtube tutorial series ( laravel 5 | section 3 | part 4 routing post requests ) @ 5:46mins in, there notification method applicable versions prior laravel 5.2. i have tried edit verifycsrftoken.php method protected $except = ['api/']; makes no difference. my routes.php code snippet: route::post('/form-handler', function(\illuminate\http\request $request){ if(isset($request['option']) && $request['firstname']) { if(strlen($request['firstname']) > 0){ return view('forms.formresults', ['action' => $request['option'], 'name' => $request['firstname']]); } return redirect()->back(); } return redirect()->back(); // return user page came })->name('form-handler'); my welcome.blade.php code snippet: <div class="form-group">

angularjs - Connect/read BluetoothLE devices with password in ngCordova/Ionic -

i'm using https://github.com/randdusing/cordova-plugin-bluetoothle/ firstly scan devices , later connect/read/write data in them. the devices have connect password protected there no input or parameter include it. i made connection devices (without password) , seems ok attempt read data different devices imposible. read data encoded (base64) , after converting string result " " hint this? connection: $rootscope.connect = function(addressparam) { var params = {address: addressparam}; $cordovabluetoothle.connect(params).then(null, function (obj) { console.log("conexión error " + obj.status + " con dirección: " + obj.address); $rootscope.close(addressparam); }, function (obj) { console.log("conexión success " + obj.status + " con dirección: " + obj.address); $rootscope.iscon(addressparam); if(obj.status==="disconnected" || obj.status==="undefined" ){ $rootscope.connect(addressparam); }

Fancybox modal doesn't work inside iframe -

fancybox modal dialog doesn't work in iphone safari! there reasons? <div class="m39-modal" data-component="m39-modal" id="modal_true"> <button data-trigger="true" class="m39-modal__trigger">modal trigger</button> <div data-content="true" class="m39-modal__container" role="dialog" aria-expanded="false"> <div class="m39-modal__dialog"> <div class="m39-modal__header"> <div class="m39-modal__title">terms &amp; conditions</div> <button data-close="true" class="m39-modal__button--close">close</button> </div> <div class="m39-modal__content"> <p>lorem ipsum dolor sit amet, consectetur adipiscing elit. nullam ut facilisis metus, varius elementum leo. sed ut justo @ magna pulvinar c

html - Mask div using CSS -

ok i'm using follow setup divs: .background contain image. .overlay have semitransparent white background overlay .inner mask out rectangle size of div? background transparent , cuts through overlay div. <div class="background"> <div class="overlay"> <div class="inner"> </div> </div> </div> is possible css? looks can achieve adding thick border opacity (fiddle) . border widths determine size of rectangle desired: <div class="background"> <div class="inner"> </div> </div> and css: html, body { height: 100%; width: 100%; } .background { width: 100%; height: 100%; background: url('http://farm9.staticflickr.com/8242/8558295633_f34a55c1c6_b.jpg'); } .inner { width: 100%; height: 100%; border-top: 130px solid rgba(255, 255, 255, 0.5); border-bottom: 130px solid rgba(255, 255, 255, 0.5); border-le

python - Round columns based on second level of MultiColumn -

Image
i have table looks this: >>> df.head() out[13]: v u init change integral init change foo bar baseline nan 0.025054 0.858122 0.017930 0.048435 1.091943 10.0 0.025042 0.856307 0.017546 0.047815 1.100351 50.0 0.025008 0.856681 0.010052 0.048252 1.056658 b 1.0 0.025045 0.858044 0.015635 0.047135 1.091384 2.0 0.025048 0.855388 0.016115 0.047324 1.087964 now select columns based on label of second level of column, , round them. i can access them using xs : df.xs('init', 1, 1) . however, naturally cannot use xs replace values: >>> df.xs('init', 1, 1) = df.xs('init', 1, 1).round(decimals=3) file "<ipython-input-12-47c16e5011a3&g

c# - Edge of the image is cutted out when conver DIBto ImageSource -

Image
i use below code convert dib scanner twain bitmapsource, found edge of image cutted off. image size different source image. there thing wrong in below code when handel image? /// <summary> /// managed bitmapsource dib provided low level windows hadle /// /// notes: /// data copied source windows handle can saftely discarded /// when bitmapsource in use. /// /// subset of possible dib forrmats supported. /// /// </summary> /// <param name="dibhandle"></param> /// <returns>a copy of image in managed bitmapsource </returns> /// public static bitmapsource formhdib(intptr dibhandle) { bitmapsource bs = null; intptr bmpptr = intptr.zero; bool flip = true; // vertivcally flip image try { bmpptr = win32.globallock(dibhandle); win32.bitmapinfoheader bmi = new win32.bitmapinfoheader(); marshal.ptrtostructure(bmpptr, bmi); if (bmi.bisizeimage == 0) bmi.bisizeimage = (uint)(((((b

Ruby: constant, module, hash -

i'm few months learning ruby, , right i'm trying build south korean/north korean/english dictionary type of thing. i'm feeding text file has words. so far i've got: module dictionary dictionary = [] end class file include dictionary def self.convert(file) readlines(file).each |line| south, north, meaning = line.split(',') dictionary << { :south => south, :north => north, :meaning => meaning } end end end file.convert("dictionary.txt") dictionary::dictionary.sort_by { |word| word[:north] }.each |word| puts "#{word[:south]} #{word[:north]} in north korean. both mean #{word[:meaning]}" end my question is: 1) unnecessary me make separate module array? (i trying experiment mixing in modules , classes) 2) using constant array right move? guess thought process wanted array able accessed outside, honest don't know i'm doing. thanks in advance. since dictionary loade

interface builder - Initial size of the window controller has no effect -

Image
i have window containing horizontal split view , have initial size. despite checking minimum content size checkbox of window metrics tabs, initial size of application smaller that:

sql - Find no of days remaining on current month from given date -

i want calculate number of days remaining given date ex: if date '02/01/2016' remaining days on given month '28' if 03/05/2016 '25' days... i tried below select datepart(dd,'03/05/2016') given me 5 days sqlserver specific since mentioned version well: select datediff(day,getdate(),dateadd(s,-1,dateadd(mm, datediff(m,0,getdate())+1,0))) you need find last date of given month , calculating datediff easy,below expression same dateadd(s,-1,dateadd(mm, datediff(m,0,getdate())+1,0)) on 2012,it easier: select datediff(day,getdate(),eomonth(getdate()))

python - How to run GDB with the results of a script? -

simple, maybe not simple issue. how can run gdb results of script? what mean instead of saying: run arg1 you say: run "python generatingscript.py" which output args. i'm aware find way sleeping program after run args command line, darn convenient if there way kind of thing directly in gdb. just context, use case situation writing crash test cases long strings of hex data. putting them in hand @ command line isn't convenient thing. you can use gdb --args option this: gdb --args your_program $(python generatingscript.py .

go - How to get the size of HTTP Response? -

i want determine size of response. it's easy way contentsize resp.contentlength. but, size combined size of response headers (usually few hundred bytes) plus response body, delivered server. how can size of response headers ? or there anyway size of response directly? you can implement http.responsewriter counts bytes writes. should pretty simple create own, or can use existing library this one .

c# - What is a NullReferenceException, and how do I fix it? -

i have code , when executes, throws nullreferenceexception , saying: object reference not set instance of object. what mean, , can fix error? what cause? bottom line you trying use null (or nothing in vb.net). means either set null , or never set @ all. like else, null gets passed around. if null in method "a", method "b" passed null to method "a". the rest of article goes more detail , shows mistakes many programmers make can lead nullreferenceexception . more specifically the runtime throwing nullreferenceexception always means same thing: trying use reference, , reference not initialized (or once initialized, no longer initialized). this means reference null , , cannot access members (such methods) through null reference. simplest case: string foo = null; foo.toupper(); this throw nullreferenceexception @ second line because can't call instance method toupper() on string reference pointing null .