Posts

Showing posts from March, 2015

android - Is it ok to use setContentView() once in OnResume() -

i have heard things how bad use setcontentview() pattern "one activity, multiple views": advantages , disadvantages however wondering, unlikely application cause memory leaks, if use setcontentview() once in onresume() method of activity? whenever user opens app, checks see if has been enabled in settings. if has been enabled app uses different screen compared original screen. therefor code looks this: @override protected void onresume() { super.onresume(); inputmethodmanager im = (inputmethodmanager)getsystemservice(input_method_service); string list = im.getenabledinputmethodlist().tostring(); if(stuff true){ setcontentview(r.layout.activityscreen_enabled); } } } would using setcontentview() unlikely cause memory leaks , other such problems? or there better solution? i'm doing android since few years , have never done because stick pattern having setcontentview in oncreate . however, not

android - last item in the listview inside view pager does not appear correctly -

Image
in android application used list view inside viewpager last item not appear full item, scroll befor last item appear shown in screenshot message_item.xml <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" > <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white" android:layout_margintop="7dp" android:layout_marginleft="8dp" android:layout_marginright="8dp" android:layout_marginbottom="1dp" android:elevation="1.4dp" android:foreground="?android:attr/selectableitembackground" > <imageview android:i

amazon web services - Shorten S3 signed url -

i'm creating signed urls , sending them external system later use. unfortunately there length parameters not allow extremely long strings passed along. recently, appears signed urls reformatted , extended subsequently broke app. is there method generating shorter url s3? prefer not rely on third party url shortening service number of reasons (it's request @ url generation , adds point-of-failure). you can build very simple url shortener directly within amazon s3 : turn on static website hosting . give url access bucket, eg: mybucket.s3-website-ap-southeast-2.amazonaws.com create zero-length object in s3 'short name', eg pic1.jpg add metadata zero-length object: key: website redirect location value: long url then, when access zero-length object (eg mybucket.s3-website-ap-southeast-2.amazonaws.com/pic.jpg ) redirect long url stored in metadata. simple, no database required!

php - How to count all records from selected table with empty fields -

assuming have four tables have select 3 tables database named records records 1.cases 2.ballistics 3.chem 4.accounts cases id|year|natureofcase | 0 | |repact 1901a | 1 |2003|repact 1907b | 3 |2004|repact 1902 | ballistics id|year|name |type | 0 |2003| |a-101 | 1 | |silver-a |a-202 | 3 |2005|red cap | | chem id|year|identified | 0 | |h20+c20 | 1 |2001|am | 3 |2009| | so have 6 rows empty tables. want display sum 6 using php. thank you. comments/answers/suggestions highly appreciated. please try this select (select count(*) cases year = '' or natureofcase = '') + (select count(*) ballistics year ='' or name='' or type='') + (select count(*) chem year='' or identified='') total_empty

layout_weight doesn't work on android when I use 0dp layout width -

i want lay map on application add text field , button on top of it. below xml file. after launch application, map shown on screen correctly text field , button not there. not shown when remove map. did miss here? <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:orientation="vertical" tools:context="com.lenovo.mds.lenovopoc.mainactivity"> <com.amap.api.maps2d.mapview android:id="@+id/map" android:layout_width="match_par

angularjs - how to pass ASP.NET MVC view values to angular js controller -

i want pass asp.net mvc view (.cshtml) values angular js controller. familiar angular js, not on mvc. have values in mvc cshtml. want pass value angular controller. please provide me info or demo project or link explains in detail. i want somthing below, get value mvc model , pass cshtml. from cshtml pass value angular js controller , display in angular html page not want use cshtml view. want data cshtml angular controller , display in seperate html using first tutorial pulled grabbed snippet: var awesomeangularmvcapp = angular.module('awesomeangularmvcapp', ['ngroute']); awesomeangularmvcapp.controller('homecontroller', homecontroller); var configfunction = function ($routeprovider) { $routeprovider. when('/listings', { url: 'routesdemo/one' }) .when('/listing', { url: 'routesdemo/two' }) .when('/listings', { url: &

r - How to combine a column from a data table to panel data structure -

Image
i have been working large panel data set. simple data set below. +--------+------+------+-----+-----+--------+ | time | firm | land | lab | cap | gl | +--------+------+------+-----+-----+--------+ | jan-00 | | 25 | 261 | 13 | 161521 | | feb-00 | | 25 | 334 | 15 | 142452 | | mar-00 | | 25 | 156 | 14 | 365697 | | apr-00 | | 28 | 134 | 12 | 355789 | | may-00 | | 28 | 159 | 15 | 376843 | | jun-00 | | 28 | 119 | 12 | 258762 | | jul-00 | | 28 | 41 | 45 | 255447 | | aug-00 | | 28 | 247 | 75 | 188545 | | sep-00 | | 28 | 251 | 41 | 213663 | | oct-00 | | 30 | 62 | 12 | 273209 | | nov-00 | | 30 | 525 | 15 | 317468 | | dec-00 | | 30 | 217 | 16 | 238668 | | jan-01 | b | 42 | 298 | 42 | 241286 | | feb-01 | b | 42 | 109 | 45 | 135288 | | mar-01 | b | 42 | 7 | 24 | 363609 | | apr-01 | b | 42 | 12 | 56 | 318472 | | may-01 | b | 42 | 0 | 12 | 446279 | | jun-01 | b | 45 | 50 |

javascript - Get events from fullcalendar to display on google calendar -

currently, using fullcalendar adding events in web application.then want events in fullcalendar display in google calendar. but have tried search , try this i got error referenceerror: uicalendarconfig not defined . don know how fix problem.i try find solution seems difficult. my fullcalendar this: $('#calendar').fullcalendar({ //.......... }); this code have tried: <script type="text/javascript"> var clientid = '######', scopes = 'https://www.googleapis.com/auth/calendar', calendarid = '#####'; var apikey = '#####'; function handleclientload() { // step 2: reference api key gapi.client.setapikey(apikey); window.settimeout(checkauth,1); } //authorization in google function checkauth() { gapi.auth.authorize( { 'client_id': clientid, 'scope': scopes, 'immediate': true }, handleau

python 3.x - Function if/elif/else syntax error -

i can't figure out why getting syntax error function wrote. occurs @ first elif. when try run it, error in idle says "invalid syntax" highlights 'elif'. the code: def sort(count_dict, avg_scores_dict, std_dev_dict): '''sorts , prints output''' menu = menu_validate("you must choose 1 of valid choices of 1, 2, 3, 4 \n sort options\n 1. sort avg ascending\n 2. sort avg descending\n 3. sort std deviation ascending\n 4. sort std deviation descending", 1, 4) print ("{}{0:27}{0:39}{0:51}\n{}".format("word", "occurence", "avg. score", "std. dev.", "="*51)) if menu == 1: dic = ordereddict(sorted(word_average_dict.items(), key=lambda x:x[1], reverse=false)) key in dic: print ("{}{0:27}{0:39:.4f}{0:51:.4f}".format(key, count_dict[key], avg_scores_dict[key], std_dev_dict[key]) elif menu == 2

java - The Surface Has Been Released Error when I try setDisplay to MediaPlayer -

i trying play video gallery .mp4 format , recorded video camera app. surface has been released error when try setdisplay. have read of forums , sure how handling surfaceview or holders. surface destroyed before call start , don't know how keep created. need communities advice first time this i know gets path of file correctly , when remove attempts play video, audio part worked. maybe has fact see surface on homescreen when start app, xml may not correct think should okay: public class mainactivity extends activity implements onclicklistener, onpreparedlistener, oncompletionlistener, surfaceholder.callback, onbufferingupdatelistener, onvideosizechangedlistener { private static final int select_video = 1; private static final string tag = "mainactivity"; private byte[] videofile; private int mvideowidth; private int mvideoheight; private mediaplayer mmediaplayer; private surfacevie

javascript - jquery ajax call redirects to called url insted of same template -

i have django form : <form class="myform" action="{% url "create" %}" method="post">{% csrf_token %} <div class="results"></div> <label class="input margin-bottom-10">{{form.name}} <div class="name_error"></div> </label> <label class="input margin-bottom-10">{{form.age}} <div class="age_error"></div> </label> <input class="margin-top-10 pull-right" type="submit" value="confirm" > </form> and jquery like: frm = $('.myform') frm.on('submit', function(event){ create(frm); }); function create(frm) { $.ajax({ url : frm.attr('action'), // endpoint type : frm.attr('method'), // http method data: frm.serialize(), // data sent post request // handle successful response success

xcode - IOS Auto Lay out dynamic leading and trailing constraints -

Image
how can set dynamic leading , trailing constraints give dynamic width , height through percentage of screen size. try this add below property in viewcontroller @property (strong, nonatomic) iboutlet nslayoutconstraint *cnstviewleading; @property (strong, nonatomic) iboutlet nslayoutconstraint *cnstviewtrailing; then set outlet leading , trailing ...... and use this // replace value whatever want 0 self.cnstviewleading.constant = 0; self.cnstviewtrailing.constant = 0;

Android minSdk and dependecies -

i read app able run on minimum sdk version, 16 in case: android { compilesdkversion 23 buildtoolsversion "23.0.2" defaultconfig { applicationid "com.github.dht.screenger" minsdkversion 16 targetsdkversion 23 versioncode 1 versionname "1.0" } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } } ... so happen level 23 dependencies when running on api 16 device? dependencies compile 'com.android.support:appcompat-v7:23.2.0' compile 'com.android.support:recyclerview-v7:23.2.0' .... it depends on feature , have used support library or not , cause in case have used feature support library that's backward compatible library takes care of else native behavior kicks in , lets take common scenario, status bar in api leve

c - Request queues in I/O scheduling Linux Kernel -

i searching way find out length of request_queue (that defined structure in linux/include/linux/blkdev.h ). new kernel development , can't figure out actual list of requests processed elevator. there way iterate requests in queue or @ least find number of them? the requests of queue linked struct list_head queue_head . can iterating request using linked list functions, can see examples here: http://lxr.free-electrons.com/source/include/linux/blkdev.h?v=2.4.37#l271

Android: Can't update textview in Fragment from Activity. NullPointerException -

i'm trying update textview in fragment activity. i'm getting nullpointerexception when calling settext method. have tried following, still getting npe. 1. tried accessing fragments textview findviewbyid in activity. 2. tried using method in fragment , calling activity , passing value parameters fraghome activity public class fraghome extends appcompatactivity implements tablayout.ontabselectedlistener { handler bluetoothin; private static textview tmpf, humf, cof; string tempgl, humgl, cogl, devname; double dbltemp, dblco; final int handlerstate = 0; // used identify handler message private bluetoothadapter btadapter = null; private tablayout tablayout; private viewpager viewpager; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_frag_home); //adding toolbar activity toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); //initiali

asp.net - Is there a way to use Telerik radgrid's export to excel on datatable in codebehind -

i trying export datatable excel on asp.net machine without office interop, since i'm using telerik asp.net, there way use radgrid's export excel function on datatable in code behind @ runtime without creating design radgrid in page? please try below code snippet. protected void page_load(object sender, system.eventargs e) { radgrid1 = new radgrid(); radgrid1.id = "radgrid1"; radgrid1.needdatasource += new gridneeddatasourceeventhandler(radgrid1_needdatasource); } protected void radgrid1_needdatasource(object sender, gridneeddatasourceeventargs e) { datatable dt = new datatable(); dt.columns.add("shipper", typeof(string)); dt.columns.add("shippertemp", typeof(string)); dt.rows.add("cshipper1", "1"); dt.rows.add("bshipper2", "2"); dt.rows.add("ashipper1", "1"); dt.rows.add("eshipper1", "2"); dt.rows.add("ds

c++ - Align to the right text from QLabel and QLineEdit -

Image
i have qlabel below qlineedit same size , alignment properties: qlineedit *lineedit = new qlineedit("999"); lineedit->setfixedwidth(100); lineedit->setalignment(qt::alignright); // qlabel *label = new qlabel("999"); label->setfixedwidth(100); label->setalignment(qt::alignright); // qlayout *layout = new qvboxlayout; layout->addwidget(lineedit); layout->addwidget(label); here how rendered: how can have text of bottom label right-aligned text of lineedit ? full award if find solution works on platforms, , works when font sizes different in lineedit , label . unfortunately may not possible, @ least not out of box, right margin not work, 0 when text offset left. reason this offset not determined margins, depends on combination of platform gui style , particular font's metrics that's being used, , value "conveniently" not available in class public interface, there no way it. you can font metrics easily, ca

gray image log transformation in java -

i trying log transformation gray image. whatever c value black image. idea? that method: ///--------------------------------------------------- public static bufferedimage log_trans (int[][] imagedata , int c){ bufferedimage logimage = new bufferedimage(imagedata.length, imagedata[0].length, bufferedimage.type_byte_gray); double temp; (int =0 ; i<imagedata.length ; ++){ (int j=0 ; j<imagedata[0].length ; j++){ int rgb = imagedata[i][j]; rgb = (rgb<<16)|(rgb<<8)|(rgb); temp = math.log10(rgb+1); rgb = (int) (c * temp); logimage.setrgb(i, j, rgb); }} return logimage; } -------------------------------------------------------------- public static int[][] readimage(file filename){ bufferedimage img; try { img = imageio.read(filename); // gray_scaled image output int width = img.getwidth();

css - Can not set the column width on multi row table header -

i have problem setting width of colum on multiple row table header. below table markup example. table{ border-collapse: collapse; table-layout: fixed; width: 100%; } th,td{ border: 1px solid #e3e3e3; padding: 5px 10px; word-break: break-word; } thead{ background: white; } <table class="table--fixed-header"> <thead> <tr> <th rowspan=2>name</th> <th colspan=3>address</th> <th rowspan=2>email</th> <th rowspan=2 style="width:50px">birthday</th> <th rowspan=2>phone</th> </tr> <tr> <th>street</th> <th>city</th> <th style="width:100px">postal</th> </tr> </thead> <tbody> <tr> <td>lucius cotton</td> <td>ap #796-9909 vulputate st.</td> <td>hope</td> <td>4169</td> <

c++ - Arduino - making a ringing tone but its not accurate -

arduino, trying make ring tone (like brrr brrr, brrr brrr, old common telephone ring tone), not close yet. can show me how it? void play_on() { // should play exact telephony ring tone, how? for(int i=0; <50; i++) { tone(2, i+900, i+10); delay(60); notone(2); } }

html5 - Gwt create panel with standard html tags -

i want create web application in gwt need have standard custom tags header, footer, nav etc. problem whenever use panel in gwt java code underneath compiler produces either div element or table element, never produces header or footer or nav. please can suggest me best practice create or have panel standard tags header , footer. 1 approach ui binder not using , want stick basic gwt approach. i tried approach : htmlpanel panel = new htmlpanel(""); it create footer tag footer wrapped under table tag of htmlpanel , have no reference footer java code. please can me on this thanks in advance. you have @ least 2 options: work elements or use htmlpanel. here example each solution: //element element footerelement = document.get().createelement("footer"); document.get().getbody().appendchild(footerelement); //htmppanel htmlpanel footer= new htmlpanel("footer", "hello footer"); rootpanel.get().add(footer)

Convert permute method from Java to JavaScript -

i implemented java code permutation combination string input str= "word1 word2 word3" output as: arr[0]= "word1 word2" arr[1]= "word1 word3" arr[2]= "word1 word2 word3" arr[3]= "word2 word1" arr[4]= "word2 word1 word3" arr[5]= "word2 word3 word1" arr[6]= "word3 word1" arr[7]= "word3 word1 word2" arr[8]= "word3 word2 word1" this java code: private static void permute(string[] ss, boolean[] used, string res, int level, list<string> list) { if (level == ss.length && res != ""){ list.add(res); return; } (int = 0; < ss.length; i++) { // check if string used if (used[i]) { continue; } // check if res empty or single word if(level > 1) list.add(res); used[i] = true; permute(ss, used, res + " " + ss[i], level + 1, lis

c++ - v8::Isolate::New null access violation -

i'm using v8 32-bit version 4.10.253 compiled visual studio 2015. i'm trying run example google has at: chrome v8 - getting started but when try run it, get: exception thrown @ 0x00000000 in v8test.exe: 0xc0000005: access violation executing location 0x00000000. i when following executed: isolate* isolate = isolate::new(create_params); my project settings: to project compile in debug, set runtime library to: multi-threaded debug /mtd. i include v8 include directory under additional include directories. lastly, include following libraries: icuuc.lib icui18n.lib v8_libplatform.lib v8_external_snapshot.lib v8_base_3.lib v8_base_2.lib v8_base_1.lib v8_base_0.lib v8_libbase.lib winmm.lib anyone know i'm doing wrong? in advance. ok, feel stupid. didn't finish reading rest of tutorial. must copy .bin files executable stored. specifically: natives_blob.bin snapshot_blob.bin v8 crash @ isolate::new if not.

ANDROID Studio: Picking up seemingly wrong layout -

Image
this question exact duplicate of: android: imageview different sizes 1 answer apologies folks, posted earlier in wrong head; ignore duplication i new android studio. please excuse if query trivial. problem understanding layouts. my layout , corresponding values folder shown below. problem correct layout not being picked up. example, nexus 4 (4.7inch, 768x1280, xhdpi), in landscape mode, layout being picked 'layout' folder. per understanding (which might totally wrong ) should have been picked layout-sw720dp-xhdpi. suggestions please? sw stands smallest width . if device has width of 320dp in portrait mode , 720dp in landscape mode end device's smallest width 320dp. try use layout-w720dp-xhdpi instead of layout-sw720dp-xhdpi , see if works. edit: according wikipedia "the nexus 7 screen has 1920×1200 pixel resolution (960dp × 600d

php - How to exceed .xls excel drop down cell values length using PHPExcel -

i guys sorry english need using phpexcel library creation of xls file in php. making drop down in xls using code $objvalidation->settype( phpexcel_cell_datavalidation::type_list ); $objvalidation->seterrorstyle( phpexcel_cell_datavalidation::style_information ); $objvalidation->setallowblank(false); $objvalidation->setshowinputmessage(true); $objvalidation->setshowerrormessage(true); $objvalidation->setshowdropdown(true); $objvalidation->seterrortitle('input error'); $objvalidation->seterror('value not in list.'); $objvalidation->setprompttitle('pick list'); $objvalidation->setprompt('please pick value drop-down list.'); $objvalidation->setformula1('"item a,item b,item c,item d,item e,item f"'); its working fine allow enter 250 characters in setformula1 drop down cell if enter more 250 not working. how can enter values more 250 limit have googled couldn't find solution ..... des

c++ - drawing a pixelarray fast and efficient on linux -

how can draw pixel array fast in c++ ? i've seen many questions on stackoverflow, answered with: use gdi (windows) use opengl ... but there must way, how opengl doing it! i'm writing little raytracer , need draw every pixel many times per second . opengl able it, platform independent , fast , how can achieve without opengl ? and "without opengl" dos not mean use sdl (slow) use / library please only suggest platform native methods or library closest that . if possible (i know is) how can this? platform independent solutions preferred . drawing graphics on linux either have use x11, or opengl. (and in near future wayland may option). in linux there no "native" way of doing graphics, because linux kernel doesn't care graphics apis. provides interfaces (drm) using graphics systems implemented in user space. if want splat pixels on screen, without caring windows mmap /dev/fbdev – don't want that, b

Why is my HTTPost in android gives me null on JSP page? -

i building app tracks user latitude , longitude. latitude , longitude has posted server. i build service gives me users current location. this code: myservice.java package com.example.rama.locationtracking; /** * created rama on 4/10/2016. */ public class myservice extends service { private static final string tag = "sri"; private locationmanager mlocationmanager = null; private static final int location_interval = 1000; private static final float location_distance = 0; private double longitude,latitude; private static string url ="http://49.206.9.182:8080/ezomart/latlong.jsp"; private string latitude_str; private string longitude_str; private class locationlistener implements android.location.locationlistener { location mlastlocation; public locationlistener(string provider) { log.e(tag, "locationlistener " + provider); mlastlocation = new location(provider);

How to delete a provisioning file for xcode -

i ever tried create provisioning file , certificate in apple's developer manager web page.and latter on,i want delete them all.i did delete certificate,while failed provisioning file.here issue: i logged in apple's developer manage web page , delete provisioning file.then refresh web page.it seemed successful. i open xcode , click preference menu view provisioning files.and did open directory , deleted provisioning files had downloaded already.and refresh panel.it seemed same web page.i clicked "download all". i closed xcode window , exit. 4.i refreshed web page.the provisioning file want delete appeared again suffix “managed xcode”. so kind guy tell me shit , how delete shit?please,give me help. navigate ~/library/mobiledevice/ and delete profiles there