Posts

Showing posts from August, 2010

android - Load Only First Tab's Fragment of viewpager -

i using tablayout viewpager , having 3 tabs. using fragmentpageradapter set tabs , it's fragments. i want load first tab's fragment when selected default , want load other tab's fragment in new activity. i have tried return null when getitem method in case of position 1 , 2 gives exception. how can this, can please me here. thanks lot in advanced. when use fragmentpageradapter typically extend , override couple of methods. 1 of them getitemcount() . make return 1 or 3 (or whatever) depending on hosting activity . example, pass hosting activity parameter , check activity class host of tabs in getitemcount() method. you add own method public void setitemcount(int count) change amount of tabs shown (and fragment s loaded). not sure if work.

xml - java - How to check if a Calendar instance was originally a wrong date -

i have calendar instance, parsed xsd datetime via javax.xml.bind.datatypeconverter.parsedatetime method jaxb. at runtime, i'm in web service, , want know if original xsd datetime valid (month < 12, day < 31, 30, 29, 28 according month ...ect) or not. example: valid date: 2015-07-30t09:32:05.543+02:00 , not: 2015-07-35t09:32:05.543+02:00 i tried use setlenient on instance in web service, doesn't seem raise exception when original date wrong. is there way it? guess tell jaxb right way in global.jaxb file, here's 1 use right now: <?xml version="1.0" encoding="utf-8" standalone="yes"?> <jaxb:bindings version="2.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xs="http://www.w3.org/2001/xmlschema" jaxb:extensionbindingprefixes="xjc"> <jaxb:globalbindings> <xjc:simp...

Scala - What is this NoSuchMethodError telling me? -

i nosuchmethoderror when run unit test. scala code compiles, why fail find method during runtime? java.lang.nosuchmethoderror: com.twitter.algebird.analytics$.mean(lscala/function2;)lscala/function1; what (lscala/function2;) , lscala/function1; mean? this indicates using binary incompatible library, e.g. dependencies don't match (you have library version x , library b assumes library version y). if build sbt, can run sbt evicted give warnings possibly incompatible libraries.

r - how to change aspect ratio of the PANEL (grey area) in ggplot2 -

Image
hi i'm plotting pie chart , putting names on there. , text cropped outside panel (grey area). is there way change aspect ratio of panel? i tried theme(aspect.ratio=1.5) , changes pie chart ellipse. want pie chart not change, , want panel wider. , tried adjust size of picture, doesn't change panel (grey area). any help's appreciated. thanks! library(ggplot2) source('piechart.r') df = data.frame('name' = c('long long name one', 'long long name two', 'long long name three', 'long name long four'), 'count' = c(10, 20, 30, 40)) png(width=1000, height=600, file='/users/yuji/onedrive/data/townstate/pie.png') piechart(df, 'name', 'count') dev.off() piechart.r piechart = function (data1, name1, value1){ position = cumsum(data1[[value1]])-0.5*data1[[value1]] ggplot(data = data1, aes_string(x=1, y=value1, fill=name1)) + ...

javascript - Export html to Excel : when try to open file it gives prompt like file is corrupted -

i exporting html table excel using javascript code on browser. done when try open file in microsoft excel gives prompt : "excel cannot open file 'filename.xlsx' because file format file extension not valid. verify file has not been corrupted , file extension matches format of file.do want open file now?" if press yes works fine , data gets displayed in excel. i want remove prompt. my javascript code function fnexcelreport() { var tab_text="<table border='2px'><tr bgcolor='#87afc6'>"; var textrange; var j=0; tab = document.getelementbyid('headertable'); // id of table for(j = 0 ; j < tab.rows.length ; j++) { tab_text=tab_text+tab.rows[j].innerhtml+"</tr>"; //tab_text=tab_text+"</tr>"; } tab_text=tab_text+"</table>"; tab_text= tab_text.replace(/<a[^>]*>|<\/a>/g, "");//remove if u want links in table tab_text= tab_text.re...

java - FTPSClient failing to connect -

i have been trying change working ftp connection ftpclient ftpsclient provided apache. changes made changing class , indicating port application going connect. server connects server within same network. external servers, proxy required. i tried setting constructor true, shows following message: unrecognized ssl message, plaintext connection? final ftpsclient ftp = new ftpsclient( true ); //same results //final ftpsclient ftp = new ftpsclient("ssl", true ); //final ftpsclient ftp = new ftpsclient("tls", true ); ftp.setdefaultport(22); when set false, connection hangs lot of time. shows following message: could not parse response code. server reply: ssh-2.0-openssh_4.1 and tomcat shows following page: proxy error the proxy server received invalid response upstream server. proxy server not handle request post /myapppath/apage.htm. reason: error reading remote server final ftpsclient ftp = new ftpsclient( false ); ftp.setde...

visual studio 2012 - Display chinese characters in console application -

i have following console app in visual studio #include "stdafx.h" #include <iostream> using namespace std; int _tmain(int argc, _tchar* argv[]) { wcout << "displaystringstest_data" << endl; wcout << l"列举" << endl; wcout << "done" << endl; return 0; } but chinese characters output question marks does know how can them output in correct form thanks even though sending correct chinese symbols console. windows setting should changed supports language specific characters. you need change pc language chinese "region , language" section control panel, default english.

How can i get the password of oracle user instance from oracle connection string using C#? -

i want user id , password of oracle db instance connection string have stored in app.config file. here connection string stored in app.config file <add name="myconnection" connectionstring="data source=xe;user id=usmandba;password=root;" providername="system.data.sqlclient" /> i have tried oracleconnectionstring builder not return password of connection string here code: public string conpass() { oracleconnectionstringbuilder builder = new oracleconnectionstringbuilder(); builder.connectionstring = con.connectionstring; return builder.password; } this method return user id not password there missing? or there other way this? kindly me sort out.. connectionstring property never contains password. security measure. in code, password has been lost in line: builder.connectionstring = con.connectionstring; you have devise different approach. example, read connection string co...

Facebook Android - Install App and Engage App campaigns are not delivering deferred link -

Image
i have done in app fetch deferred links ads, never deliver deferred link. applinkdata null: private class deferredapplinkdatacompletionhandlerlistener implements applinkdata.completionhandler { @override public void ondeferredapplinkdatafetched(applinkdata applinkdata) { if (applinkdata != null) { final uri deferredreceiveduri = applinkdata.gettargeturi(); } else { // null } } } i have tested deferred link fetching, using ads helper of link: https://developers.facebook.com/tools/app-ads-helper/?id=1460634867586845 , work: ... don't real ad. what else should do? this known issue , being tracked here https://developers.facebook.com/bugs/393947180805373 . you can subscribe bug follow updates.

java - Naming a json property after a variable value -

i using jackson provider rest service: <jaxrs:server id="services" address="/"> <jaxrs:servicebeans> <bean class="..."/> </jaxrs:servicebeans> <jaxrs:providers> <bean class="org.codehaus.jackson.jaxrs.jacksonjsonprovider" /> </jaxrs:providers> </jaxrs:server> i have class: public class response { private date mydate; private dataobject data; //data related date } and method returning json: @produces("application/json") public response getresp(){ response r = ... return r; } this translates in following json object { "mydate":"20150730", "data":{ "p1":"v1", "p2":"v2" } } is possible obtain this, instead: "20150730":{ "p1":"v1", "p2":"v2" ...

symfony - JMS Serializer serialize object in object with diffrent view -

i'm developing restful service symfony2, jms serializer bundle , fos rest bundle , hateoas bundle . there 2 entities user , company , want to, when serialize company larger detail. but, when serializing user related company show company id , name object or id integer. i have serialize policy below. user acme\userbundle\entity\user: exclusion_policy: xml_root_name: user properties: id: expose: true type: integer company: expose: true type: acme\companybundle\entity\company name: expose: true type: string surname: expose: true type: string picture: expose: true type: string relations: - rel: self href: route: acme_v1_get_user parameters: id: expr(object.getid()) absolute: true company acme\companybundle\entity\company: exclusion_policy: xml_root_name: company properties: id: expose: true...

Linking issue between python script, flask framework, and html -

i having odd issue transferring correct data python script graph (highcharts) in html. using flask web framework , ubuntu server. have 2 identical html webpages in structure differ in data passed them (data originates 2 separate dbs). each webpage have multiple graphs (highcharts), 1 particular graph on second webpage returns incorrect data points. returns data points intended first webpage. issue not show when test on local host, when running on server (yes have correctly copied files server). might not able pinpoint issue, ideas in terms of troubleshooting or reasons why ubuntu server wouldn't refresh welcome. apologize if question unclear, isn't easiest problem convey through text. here example code...i run scripts in python on server , relayed html through flask init file. python script import os, sqlite3, datetime, pandas pd, numpy np project_root = os.path.dirname(os.path.realpath(__file__)) database = os.path.join(project_root, 'folder', 'my....

java - Creating a non-editable pdf document using PD4ml -

i using pd4ml create pdf documents, don't want user able edit documents using ms word 2013. here have tried far pd4ml = new pd4ml(); pd4ml.setpagesize(pd4constants.a4); pd4ml.setpageinsetsmm(new insets(topvalue, leftvalue, bottomvalue, rightvalue)); pd4ml.sethtmlwidth(userspacewidth); pd4ml.enableimgsplit(false); pd4ml.disablehyperlinks(); //some more code pd4ml.render(arrayofurls, bytearrayoutputstream); //some more code then read pd4ml api documentation , added line of code pd4ml.generatepdfa(true); thought problem solved when opened document in adobe reader , saw message " file claims compliance pdf/a standard , has been opened read-only", of course still editable; suggestions on how done in pd4ml, or reference api can use add restriction generated pdf more welcomed. tried this? if documentation way: allowmodify public static final int allowmodify document access permission (bit 4, value = 8). modify contents of document operations other...

ios - Using Facebook API in Swift. "App ID not found"? -

i filled keys in info.plist according facebook's tutorial, when try application, following exception message shown: 'invalidoperationexception', reason: 'app id not found. add string value app id key facebookappid info.plist or call [fbsdksettings setappid:].' i checked app id, , it's right, , don't know reason of error. can me? you might have given facebookappid instead of facebookappid...

html - Jquery lightbox form submitting -

i have form in user can enter fields , click button send submitted data php script adds data database. the issue data isnt being sent. the code: $(document).on("click" ,".save_new_user",function() { var form_data = { "first_name" : $(".first_name").val(), "last_name" : $(".last_name").val(), "email" : $(".email").val(), "username" : $(".username").val(), "auth_level" : $(".auth_level").find(":selected").text() }; console.log(form_data); var request = $.ajax({ method: "post", url: "ajax/create_user.php", data: form_data, }) .done(function( data ) { console.log(data); }); }); the markup: first name: <input type="text" name="first_name" class="first_name"> last name: ...

css - importing custom font in Wordpress theme in function.php -

i want use custom font (@fontface) in custom wordpress. have brought in google fonts in functions.php so wp_enqueue_style( 'lato', '//fonts.googleapis.com/css?family=lato:300,400,700,900', array() ); but want use font fonts folder (theme-name/fonts/...) not sure how this, use @fontface... not sure how works wordpresss edit want bring in in functions.php file import using css so: <link type="text/css" rel="stylesheet" href="http://fonts.googleapis.com/css?family=lato:300,400,700,900'" /> then accessible use: font-family: 'lato', sans-serif;

algorithm - Implement a trie with insert, search, and startsWith methods in C from LeetCode. -

implement trie insert, search, , startswith methods. note: may assume inputs consist of lowercase letters a-z. i have written simple solution implementing trie in c, has passed 16 test cases leetcode. any recommendation or suggestion ? //node structure struct trienode { char value; int count; struct trienode * children[27]; }; static int count =0; /** initialize data structure here. */ //return root pointer struct trienode* triecreate() { struct trienode *pnode = null; pnode = (struct trienode *)malloc(sizeof(struct trienode)); if (pnode) { pnode->value = '\0'; pnode->count =0; memset(pnode->children, 0, sizeof(pnode->children)); } return pnode; } /** inserts word trie. */ void insert(struct trienode* root, char* word) { struct trienode *pcrawl = root; count ++; //check if word not empty if(word){ int index=0, =0; //check if root not empty if (root){ ...

html - checkbox value to mysql/php -

im triyng figure out problem days , have progress im stuck checkbox page. so "project" kind of "online car stand" , im stuck in insert car part. i got html , php insert car sql table. then after car have link insert extras of car, abs,cruise control, gps ...etc... the html this: <?php include "verifica.php"; ?> <html> <head> <link rel="stylesheet" href="styles.css"> <title> stand automovel </title> </head> <body> <form action="extras.php" method="post"> <p class="style2"style2">&nbsp;extras: <div class="style2"> <input type="checkbox" name="chk" value="1">gps<br> <input type="checkbox" name="chk" value="2">abs<br> <input type="checkbox" name="chk" value="3">computador de bordo<b...

Java MySQL DISTINCT for Multiple Columns -

i have 2 columns in db team names in each column. but, team in 1 column, , can in other column. want create list of distinct, unique, names both columns combined. maybe further explanation, i'm trying combine 2 columns , run distinct query on combined data unique names out. thanks! use union distinct list select team1 team your_table union select team2 your_table

Swift 2 - Use case for using break on if statement? -

swift 2's guide mentions can end program execution of if statement. have never used break if-statement. a break statement ends program execution of loop, if statement, or switch statement...when break statement followed name of statement label, ends program execution of loop, if statement, or switch statement named label. in situation 1 using break in if-statement? language feature seems useless. test: if (true) { break test } using break if statement seems bit contrived, , can't think of place style demand it. does, however, save level of indentation when skipping latter portion of if statement in if-else clause, can useful nested loops. in other languages, popular (and/or controversial) idiom use labels handling errors in nested functions. example, 1 might want break out of loop on error, this: func testbreak3() { // doesn't compile!!! let = false, b = true, x = 10, y = 20, err = true if !a { if b && x ...

android - ng-cordova geolocation plugin doesn't show gps icon in notification bar -

i using ng-cordova geolocation plugin functionality work fine except problem display gps symbol in notification bar. any solution display gps symbol in notification bar when user enable gps button mobile device? assuming ng-cordova geolocation plugin, switch on gps location. gps signal should automatically appear in notification bar. standard android os. in case have different launcher installed,it may not show it, thats launcher issue, may not update in real time. if ng-cordova geolocation plugin, doesn't switch gps on need invoke following android code. alertdialog.builder dialog = new alertdialog.builder(context); dialog.settitle(context.getstring(r.string.map_dialog_title)); dialog.setmessage(context.getstring(r.string.map_dialog_msg)); dialog.setpositivebutton(context.getstring(r.string.menu_settings), new onclicklistener() { @override public void oncl...

ios - Transitioning from Newsstand apps to non-Newsstand apps -

in ios9 there won't newsstand app anymore. happen apps using newsstand? there solution, or developers have re-implement apps no-newsstand , count on users update apps before update new ios version? yes, that's true. according ios 9 updates here. updates in ios 9 changes coming newsstand fall ios 9. while publishers can still distribute periodicals on app store auto-renewing subscriptions, newsstand app no longer pre-installed. what expect individual newsstand apps install directly home screen. if customer had newsstand apps installed prior updating ios 9, newsstand become folder titled “newsstand” , existing apps placed in folder. newsstand app icons no longer cover of latest issue. should review , update app icons. you still able update issue preview screenshots , metadata without submitting new binary. background downloads continue , existing subscriptions unaffected. you can refer news app - developer library more in...

Java selenium click element not working -

i want click load more link in page. code below. pageurl="http://www.foundpix.com/category/actor/bollywood-actor/" webdriver driver = new firefoxdriver(); driver.get(pageurl); driver.manage().window().maximize(); javascriptexecutor jse = (javascriptexecutor) driver; jse.executescript("window.scrollby(0,2500)", ""); webdriverwait wait = new webdriverwait(driver, 60); wait.until(expectedconditions.visibilityofelementlocated(by.id("json_click_handler"))); driver.findelement(by.id("json_click_handler")).click(); how can make click link. you can use below xpath click load more button both times:- driver.findelement(by.xpath("//*[@id='blocks-left']/div/div[3]/div[contains(.,'load more')]")).click();

Ruby DBI fetch can't handle all-zero dates in MySQL -

i'm trying access our database simple cgi/ruby , dbi: #!/usr/bin/ruby -w require "dbi" dbh = dbi.connect("dbi:mysql:my:mydb", "xxxx", "xxxx") ... query = "select eta mydb.mytable id = #{someval}" rows = dbh.execute(query) while row = rows.fetch() # stuff ... end that works fine of time, hit record broke error: /usr/lib/ruby/vendor_ruby/dbd/mysql.rb:120:in `parse': invalid date (argumenterror) /usr/lib/ruby/vendor_ruby/dbd/mysql.rb:120:in `parse' /usr/lib/ruby/vendor_ruby/dbi/row.rb:66:in `block in convert_types' /usr/lib/ruby/vendor_ruby/dbi/row.rb:65:in `each' /usr/lib/ruby/vendor_ruby/dbi/row.rb:65:in `each_with_index' /usr/lib/ruby/vendor_ruby/dbi/row.rb:65:in `convert_types' /usr/lib/ruby/vendor_ruby/dbi/row.rb:75:in `set_values' /usr/lib/ruby/vendor_ruby/dbi/handles/statement.rb:226:in `fetch' /usr/lib/cgi-bin/te...

apache spark - Environment issue in moving from protobuf version 2.4 to 2.5 -

i have generated protobuf code using compiler 2.4. , have created application jar. works fine , can run spark job. jars in classpath of spark relevant protobuf mesos-0.18.1-shaded-protobuf.jar, protobuf-java-2.5.0-spark.jar but when use same generated code in sbt unit testing failing [info] org.apache.spark.sparkexception: job aborted due stage failure: task 0 in stage 2.0 failed 1 times, recent failure: lost task 0.0 in stage 2.0 (tid 2, localhost): java.lang.unsupportedoperationexception: supposed overridden subclasses. [info] @ com.google.protobuf.generatedmessage.getunknownfields(generatedmessage.java:180) from google search found need change protoc compiler version 2.5 , unit testing works fine . application not able run in spark . exception java.lang.verifyerror: class xxx.xxx.xx.. overrides final method getunknownfields.()lcom/google/protobuf/unknownfieldset; the machine a...

Hive date based partitions -

i have data in following form on hdfs:- /basedir/yyyymmdd/fixedname/files where yyyymmdd date folder , files list of files added in directory. need table in hive pick data yyyymmdd/fixedname directory. should work when added new date. e.g. add on 5th march 2013 files added on day go 20130305/fixedname folder. on 6th march 2013, files go 20130306/fixedname folder. how alter hive table pickup data changing date fixed folder within it? do have partitioned table? let's have partitioned table column date , want add new data. in case, have add data new directory , tell hive table (specifically metastore) has new partition using alter table add partition command . let's have not created table yet. in case have create partitioned table , insert data table queries . magic comes when set these 2 flags: set hive.exec.dynamic.partition=yes set hive.exec.dynamic.partition.mode = nonstrict; these flags allow dynamic partitions (for more details read here ). remem...

difference list (Prolog)(Logic Programming) -

i have problem solving difference list problem paper-pencil not helping of swi prolog ( in these days preparing logic programming exam). here question: q(x) :- p(x - []). p([x|y] - y). p([x|y] - z) :- p(y - [x|z]). explicitly give set of ground terms t query ?- q(t). succeeds. state formal definition of set in closed form (i.e., not use recursive definition). answer : {[t1, . . . , tn−1, tn, tn−1, . . . , t1] | n > 0, ti ground term ∈ {1, . . . , n}} i used [1,2,3,2,1] , gave me true expected answer. i not understand steps in order solve this? let t = [t1,t2,t3, ... , tn] list. q(t). succeed if p(t - []). succeeds. p(t - []). succeeds if p([t2,t3,...,tn] - [t1]). succeeds (third rule). p([t2,t3,...,tn] - [t1]). succeeds if p([t3,...,tn] - [t2,t1]) succeeds, etc. this end succeeding if @ 1 point second rule gets applied (otherwise end calling p([] - _). not match rule available), if have p([ti,ti+1,...,tn] - [ti+1,...,tn]). . the...

ios - Typhoon : Obtain a Typhoon-built instance of a class without depending on Typhoon -

with typhoon storyboard integration, necessary dependency injection use auto-injection macros or assembly methods on class injected. however elsewhere, necessary ask typhoon build instance us. there way obtain instance, without having class depend on typhoon? yes, in spirit of dependency injection, typhoon designed not necessary user classes have direct dependency on typhoon. let's wish obtain instance of viewcontrollerb viewcontrollera within typhoon application. this, create our definition viewcontrollera such assembly injected, , ask assembly build instance. shown in sample application , detailed in user guide here . the next step, if wish decouple application classes typhoon, assemblies protocol, , inject that. in way, application sees provider interface class view controller needs in order job. here's tutorial on how this .

WPF usercontrol property binding to Inotifypropertychanged, update only when value changed -

i found difference on property binding between usercontrol , normal control. for example, assuming markup contains following usercontrol: <myctrl:democontrol level="{binding alarm.alarmlevel}" /> " level " int dependency property created in " control ". " alarm " object of type inotifypropertychanged, field alarmlevel. public bool alarmlevel { { return this._alarmlevel; } set { this._alarmlevel = value; notifypropertychanged("alarmlevel"); } } inside usercontrol, did following: levelproperty = dependencyproperty.register("level", typeof(int), typeof(democontrol), new uipropertymetadata(0, islevelchanged)); the strange thing when assign alarmlevel value, if value changes, usercontrol property got updated. while if value remains same, no update. but in both cases, "notifypropertychanged" gets called ! for example, if alarmlevel==1, alarm.alar...

WebApi ASP.NET Identity Facebook login native -

basically followed answer questions: webapi asp.net identity facebook login i'm using native ios8 facebook sdk receive fb access token, send api/account/facebooklogin , managed create user, add claims etc. , validate fb token against graph api. cant signin user token produced in facebooklogin method ... here's code moment: api/accountcontroller.cs // post api/account/facebooklogin [httppost] [allowanonymous] [route("facebooklogin")] public async task<ihttpactionresult> facebooklogin([frombody] facebookloginmodel model) { if (!modelstate.isvalid) { return badrequest(modelstate); } if (string.isnullorempty(model.token)) { return badrequest("no access token"); } var tokenexpirationtimespan = timespan.fromdays(14); applicationuser user = null; string username; // fb access token , make graph call /me endpoint v...

How do I access generic type in Macro Annotation in Scala? -

i have following code: @compiletimeonly("enable macro paradise expand macro annotations") class typedtable[t] extends staticannotation { def macrotransform(annottees: any*): table = macro tablegenerator.impl[t] } object tablegenerator { def impl[t](c: whitebox.context)(annottees: c.expr[any]*): c.expr[table] = { import c.universe._ val tpe = weaktypeof[t] // doesn't work ... } } and can't seem figure out how access typetag 't' in macro annotation. i've seen other posts make vague reference how can accessed can't seem figure out how i'm supposed access in context. macro annotations don't typecheck arguments, means can trees these arguments, not types. in order obtain trees represent type arguments of macro annotation, call c.macroapplication , destructure appropriately.

php - Bootstrap responsive table -

i'm trying make non responsive table responsive using bootstrap in joomla. table generated php diplaying events. i apply bootstrap classes table , container. output not responsive. here code using (take @ line 808 ). added , solved. table, thead, tbody, th, td, tr {display: inline-block;}

How to find min and max of multiple y-axes in FLOT -

i using flot plot charts, , not providing max or min value y-axis. getting auto-scaled. want min , max value of y-axes. following code works first y-axis, want multiple axes. var min = plot.getaxes().yaxis.min; loop through yaxes array in options: var yaxes = plot.getoptions().yaxes; var min = yaxes[0].min; var max = yaxes[0].max; (var = 1; < yaxes.length; i++) { if (yaxes[i].min < min) { min = yaxes[i].min; } if (yaxes[i].max > max) { max = yaxes[i].max; } }

java - How can I generate an API version from source? -

i coding api interface in java, , add method client use check if version used server same. i add thing final string version = "v1.2.3"; want sure version date. i want prevent fact filed may not updated. i searching class hash compute @ runtime (or @ compilation time in maven may generated resource file hash). as using git, maybe git can update special tag in file commit hash , @ runtime return hashcode every source involved api? how can ? create class similar this: package com.company; import java.io.ioexception; import java.util.properties; public class versionhelper { static properties versionprops=new properties(); static { try { versionprops.load(versionhelper.class.getresourceasstream("/version.properties")); } catch (ioexception e) { system.err.println("version von "+versionhelper.class.getname()+" kann nicht ermittelt werden"); ...

go - How can I convert string to integer in golang -

i want convert string integer in golang. don't know format of string. example, "10" -> 10 , "65.0" -> 65 , "xx" -> 0 , "11xx" -> 11, "xx11"->0 i searching , find strconv.parseint() . can not handle "65.0" . have check string's format. is there better way? i believe function looking strconv.parsefloat() see example here but return type of function float64. if don't need fractional part of number passed string following function job: func strtoint(str string) (int, error) { nonfractionalpart := strings.split(str, ".") return strconv.atoi(nonfractionalpart[0]) }

ruby on rails - How to handle a file_as_string (generated by Prawn) so that it is accepted by Carrierwave? -

i'm using prawn generate pdf controller of rails app, ... respond_to |format| format.pdf pdf = generatereportpdf.new(@object, view_context) send_data pdf.render, filename: "report", type: "application/pdf", disposition: "inline" end end this works fine, want move generatereportpdf background task, , pass resulting object carrierwave upload directly s3. the worker looks this def perform pdf = generatereportpdf.new(@object) filestring = ??????? document = document.new( object_id: @object.id, file: filestring ) # file field used carrierwave end how handle object returned prawn ( ????? ) ensure format can read carrierwave. filestring = pdf.render_file 'filename' writes object root directory of app. i'm on heroku not possible. file = pdf.render returns argumenterror: string contains null byte filestring = stringio.new( pdf.render_file 'filename' ) returns typeerror: ...

java - How does a thread know that there is a join method ahead -

below sample code, when a.start() called should create thread , print "run" immediately. why called after printing "begin" 20 times. how thread "a" decide doesn't have call run() immediately. public class jointest implements runnable { public static void main(string[] args) throws interruptedexception { thread = new thread(new jointest()); a.start(); (int = 0; < 20; i++) { system.out.print("begin"); } thread.sleep(1000); a.join(); system.out.print("\nend"); } public void run() { system.out.print("\nrun"); } } output: beginbeginbeginbeginbeginbeginbeginbeginbeginbeginbeginbeginbeginbeginbeginbeginbeginbeginbeginbegin run end i little confused behavior of thread. in opinion "run" should printed before "begin" because printed before join() method called, , @ time of join method called thr...

How do I update list after delete row by jquery ajax in asp.net mvc? -

my problem when deleted row , after delete row it'll hidden in list , when use ie , f5 refresh page row still display. chorme , firefox work fine. listview : @model ienumerable<pg.admin.models.timesheetheaders.timesheetheaderviewmodel> @{ viewbag.title = ""; layout = "~/views/shared/_layout.cshtml"; } @scripts.render("~/scripts/jquery.unobtrusive-ajax.js") <div id="unobtrusive"> @html.partial("_timesheetlist", model) </div> _listtimesheet (partial view) @model pagedlist.ipagedlist<pg.admin.models.timesheetheaders.timesheetheaderviewmodel> @using pagedlist.mvc; <table class="table table-striped"> <tbody> <tr> <th> @html.displaynamefor(model => model.first().date) </th> <th> @html.displaynamefor(model => model.first()....

php - Wordpress redirect post_id urls to full post url -

i using wordpress on website, using permalinks like site.com/%post_id%/%postname%/ if visitor visit site.com/%post_id%/ not redirect full post url. i have no idea how can that. edit: using nginx try ?p=%post_id% why use post_id , postname ? why not postname this: site.com/custom/%postname% ?

git - android source code building -

i have complete source code of android 4.0. how can bring git can compile , build through ubuntu 14.04 lts? want build custom rom. is there other way of compiling , building it? you not need put android source code git, in order build it. aosp set of projects (hundreds) in own repos, @ github or other hosts. you should follow build instructions aosp rom. example here cyanogenmod built samsung galaxy s4 mini lte (serranoltexx) https://wiki.cyanogenmod.org/w/build_for_serranoltexx if you'll customizing rom , want put changes git, think right fork changed repos , modify repo manifest use forked repos.

ios - Set view controllers of UITabBarController in Swift -

i trying programatically set view controllers of custom tabbarcontroller: import uikit class tabbarviewcontroller: uitabbarcontroller, uitabbarcontrollerdelegate { var cameraviewcontroller: uiviewcontroller? var profileviewcontroller: uiviewcontroller? override func viewdidload() { super.viewdidload() self.delegate = self //self.viewcontrollers = [cameraviewcontroller, profileviewcontroller] as! [anyobject]? let controllers: [uiviewcontroller?] = [cameraviewcontroller, profileviewcontroller] self.setviewcontrollers(controllers as! [anyobject], animated: true) } but line self.viewcontrollers = [cameraviewcontroller, profileviewcontroller] as! [anyobject]? i error cannot convert [uiviewcontroller] [anyobject?] and line self.setviewcontrollers(controllers as! [anyobject], animated: true) i error saying: cannot invoke 'setviewcontrollers' argument list of type '([anyobject], animated: bool)' my problem anyobject , typecasting...

php - wp_list_pages as text not link -

im doing follow children of page im administrating: $args = array( 'depth' => 0, 'child_of' => get_the_id(), 'title_li' => '', 'echo' => 0, ); wp_list_pages($args); the output title of subpages , linked, wish serperate title , link output " http://thelink.com title". is possible? regards, emil here go, enjoy if $post->id , get_the_id() same use $post->id global $post; $currentpageid = $post->id; $childpages = get_pages('sort_column=menu_order&hierarchical=0&parent=' . $currentpageid . '&exclude='); foreach ($childpages $page){ echo "child page id: ".$page->id ."<br>"; echo "child page name: ".$page->post_title ."<br>"; }

database design - Moving from rational style modeling to NoSql/Cassandra style -

i trying change rational modeling cassandra modeling , need model following structure : have stores, promotions , prices . price list include items in specific store prices. promotion list include promotion details (e.g discount) , items included in promotion , relevant consumer clubs (e.g vip etc') stores id contain chain id, sub chain id, store id how lists items (per store): <root> <chainid>7290027600007</chainid> <subchainid>001</subchainid> <storeid>001</storeid> <items count="2"> <item> <itemcode>11210000094</itemcode> <itemprice>12.80</itemprice> </item> <item> <itemcode>11210000216</itemcode> <itemprice>29.40</itemprice> </item> </items> </root> this how items list promotion : <root> <chainid>7290027600007</chainid> <subchainid>001</su...

html - class*="span" not working -

i'm trying apply css style classes contain text "span", reason style isn't being applied elements! :s here css: [class*="span"] { float: left; min-height: 1px; margin-left: 20px; } here html: <div class="point span4"> <h2>quick , reliable</h2> <div class="hidden-phone"> <img alt="quick , reliable" src="images/point0.gif" /> </div> </div> any ideas i'm going wrong? turns out can't use <!-- --> comments in css code, causing issue, guys!

Android Youtube API V3 cast exception when Release+Proguard ON -

i have android app utilises youtube.search.list method. application works fine when in "debug" , when proguard disabled in "release". when proguard turned on (minifyenabled true), following exception when iterate list of searchresult class com.google.api.client.util.arraymap cannot cast com.google.api.services.youtube.model.searchresult i set following rules in proguard-rules (according advice in comments in question " android proguard makes youtube api oauth disabled? ") -keep class com.google.api.** { *; } the following code segment retrieves list < searchresult > . part works fine (searchresultlist.size() returns 25). youtube = new youtube.builder(new nethttptransport(), new jacksonfactory(), request->{}) .setapplicationname("youtube-search") .build(); search = youtube.search() .list("id,sn...

c# - Custom serialization of enums in MongoDB -

referencing so question custom serialization of strings enums , vice versa in json.net, decorating enum members using enummember attribute - there way mongodb perform same feat? i have refactored string fields enums , wondering if there way instruct mongo read enummember values when (de-)serializing , avoid me having go through database , update current text values.