Posts

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) { ...