Posts

Showing posts from March, 2011

Android Publisher API returns 404, when getting subscription, but it exists -

last 2 days encountering issues android publisher api, using determine, if user has paid app, or not. 100% sure, transaction paid, api returns 404, concretely: { "code" : 404, "errors" : [ { "domain" : "global", "location" : "token", "locationtype" : "parameter", "message" : "the purchase token not found.", "reason" : "purchasetokennotfound" } ], "message" : "the purchase token not found." }

c# - Convert Quickbooks IPP API from legacy QBD v3 to QBO -

we have built working integration between our web app , quickbooks desktop using legacy quickbooks api v3 qbd ( https://developer.intuit.com/docs/95_legacy/qbd_v3 ). we want add new adapter our web app support new qbo api ( https://developer.intuit.com/docs/0050_quickbooks_api ). the c# sdk ( https://developer.intuit.com/docs/0100_accounting/0500_developer_kits/0010.net_tools ) qbo seems same 1 using qbd. true? what changes need make our current qbd adapter work qbo? i.e. when using c# sdk differences when using qbd vs qbo? for example, seems when create servicecontext, specify data source either intuitservicestype.qbd or intuitservicestype.qbo. easy or other changes need make...here additional thoughts on potential changes may or may not have do: do need create new app in intuit app center new version of connecting? or can continue use existing intuit app created qbd interface? i believe supported entities , formats (properties) of entities different, if sdks same , he...

ios - exc-bad-instruction code=i386_invop -

Image
i'm getting error in latest version of xcode using swift 2 on line let s = linktxt.text text in linktxt appears button "pastefromclipboard" let s = linktxt.text let u = nsurl(string: s!) let file = u?.lastpathcomponent what reason of , how fix it? update : the problem appears in function savedata() calls when file downloading finished. calls nsurlsessiondatatask function. more interesting, in start-downloading-button there same lines filename generating , there no such error on it. fixed these issues declaring variables, writing text's values them , use these variables in savedata() except textobject.text; had delete lines nsuserdefaults savedata() because got same error. did understand nothing >_< update 2 : it's bug. i've deleted line , wrote again - problem fixed linktxt.txt returning nil , nsurl(string: s!) try forcefully unwrap it. let s = linktxt.text if let s = linktxt.txt { let u = nsurl(stri...

sql - How to place value in column A if it exist in another table, otherwise, place in column B -

i got lookup list table of valid state abbreviations , source table: states lookup , source tables respectively +-------+ +-----------------+ |states | |id | location | +=======+ +=================+ | ak | | 1 | madrid | --------- ------------------- | al | | 2 | ak | --------- ------------------- | ar | | 3 | ar | --------- ------------------- | ... | | ..| ... | --------- ------------------- how create insert statement target table such if location valid state, placed in state column , if it's not, placed in other locale column? expected target table output +------------+----------------- |id | state | other locale | +============+================= | 1 | | madrid | ------------------------------- | 2 | ak | | ------------------------------- | 3 | ar | | ------------------------------- | ..| ... | ... ...

Bash- if clause doesn't work correctly -

this question has answer here: why should there space after '[' , before ']' in bash? 4 answers i want make shutdown script , doesn't work intended. wrote. echo "wanna shutdown (y/n)?" read answer if [ $answer=="y" ] sudo shutdown -p else printf "something...." whatever press shuts down. why? you need put spaces around == operator. otherwise test expression single word, , non-empty words test successfully. in addition, if wish portable, should use = instead of == . , wise double quote variable expansions because [ won't you. if [ "$answer" = y ]; on other hand, if using bash (or ksh or zsh) use more forgiving [[ conditional expression: if [[ $answer = y ]];

android - Why does "wrap_content" doesn't work for any ...Layout in XML file using support.design.widgets? -

i here first time , have question. have xml file in android project. <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.drawerlayout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout_schedule" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/mainbackground" android:fitssystemwindows="true"> <android.support.design.widget.coordinatorlayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.appbarlayout android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.v7.widget.toolbar android:id="@+id/toolbar_schedule" ...

how to make sure a link is clicked with watir-rails -

i using watir perform functions i need show link clicked watir-driver, i'm trying put somthing console if link clicked follow: puts "profile clicked" if click_my_profile_link(browser) and: def self.click_my_profile_link(browser) browser.div(class: "topbar").when_present .link(class: 'my-profile').click end but nothing gets printed console when link gets clicked. behaviour same everywhere have click action. example is: puts "next button clicked" if browser.input(id: 'next', value: 'next').fire_event :click how can kind of log when there click action fired this? thanks procedural methods called action/side-effect , shouldn't expected have response. if didn't error, watir found element , sent click command it. so maybe sufficient expect {click_my_profile_link(browser)}.to_not raise_error typically write tests verify result of link. in case expect(browser.title == "my prof...

ruby on rails - How do I select which attributes I want for active model serializers relationships -

i using jsonapi format along active model serializers create api rails-api . i have serializer shows specific post has many topics , currently, under relationships, lists topics. lists id , type. want show title of topic well. some use include: 'topics' in controller, don't need full topic record, title. question : how specify attributes want show topics? what have "data": { "id": "26", "type": "posts", "attributes": { "title": "test title 11" }, "relationships": { "topics": { "data": [ { "id": "1", "type": "topics" } ] } } } what want "data": { "id": "26", "type": "posts", "attributes": { "title": "test title 11" }, "relationships...

How do you change specific values (like 7) in a column to NA in R? -

i working on project did not know recorded 7 in column , refused answer recorded 9. trying find easy way convert these values na. you can use simple logic assign na, in following simple example. column <- c(1,2,1,3,7,7,1,2,9) column[column %in% c(7,9)] <- na > column [1] 1 2 1 3 na na 1 2 na basically, can operate on column of data frame using $ operator. treats column vector. using logical operator on vector returns vector of true or false back, can used select elements of vector change na. i caution might not want that. using na instead of values in r can have annoying side effects because operation against na returns na. edited add: per gregor , should mention data frame allows select single columns out of using $ operator. instance, in data frame df.example , if columns a, b, , c, df.example$a extract column vector. in contrast, [ operator not create vector subsets, , used select multiple columns of data frame smaller data frame. instance, g...

Programmatically change Telerik GridEditCommandColumn EditText per row in RadGrid -

Image
i have radgrid grideditcommandcolumn. i'd have edittext property of each row change based on contents of row. eg, change edittext 'edit' 'edit product' or 'edit bundle' based on contents of row. i tried using databinding syntax got error saying doesn't support databinding. is there event can hook change value of edittext programmatically per row? is want? anyway can find , edit through onitemdatabound... put in uniquename on edit command column.. find control it. .aspx <asp:scriptmanager id="sm" runat="server"></asp:scriptmanager> <telerik:radgrid id="radgrid1" runat="server" autogeneratecolumns="false" onitemdatabound="radgrid1_itemdatabound"> <mastertableview> <columns> <telerik:grideditcommandcolumn buttontype="linkbutton" uniquename="grideditcommandcolumn"></telerik:gride...

html - Media Queries acting weirdly -

Image
i using dream weaver create responsive me page site (using default me template). when use dream weaver on-device previewing system, page responsive , on iphone resizes fine this: however, when upload code website, page no longer becomes responsive. looks same on laptop (as shown below) why issue occurring? the html page this . if need me post code here well, please tell me. appreciated :) for media queries work on small screens, need include viewport meta element in head of document. e.g.: <meta name="viewport" content="width=device-width, initial-scale=1">

javascript - Zurb Foundation 5 + Rails 4 : toggle-topbar won't work -

i have tried in knowledge (however little there is), can not make top bar menu render on small screens. want menu reduce down clickable menu item on small screens, responsive behaviour menu. apparently following code alone should make work, doesn't. <header> <div class="row"> <div class="large-12 large-centered small-12 small-centered columns"> <nav class="top-bar" data-topbar role="navigation"> <section class="top-bar-section"> <ul class="title-area"> <li class="toggle-topbar menu-icon"><a href="#"><span></span></a></li> </ul> <ul class="left"> <li><%= link_to('link', {:controller => 'controller', :action => 'action'}) %></li> ...

css - Find images with different sizes for web development and design test purposes -

i have searched , searched on google, find either websites provide fancy images, or other sites allow upload image , resize it, or google search results can filter images size (which doesn't work of time). i need have fancy images (not fancy) prototyping purposes projects difference sizes, example dummy logo specific size, or pictures of laptops (to view products) specific sizes. is there website out there provides service? there number of options. a few include: lorem pixel - http://lorempixel.com/ - access images of whatever size specify. placehold.it - https://placehold.it/ - generate placeholder images of size. every stock photo - http://www.everystockphoto.com/ - 1000s of free stock images.

After fiddler shutdown my internet stops working -

when shut down fiddler browser not able access website. when restart fiddler, starts working again. after shutting down fiddler checked proxy settings on ie , made sure reverted "automatically detect proxy settings." i restarted machine , didn't help. else can try? this problem reproducible when press f12 , stop capture of traffic in fiddler. from command prompt use inetcpl.cpl launch internet options, check in connections->lan settings if proxy enable, disable unchecking "use server proxy lan"

php - Yii2 Executes the view twice -

Image
i've changed index action login action , view executes twice why happend ? can me ? this layout: <?php /* @var $this \yii\web\view */ /* @var $content string */ use yii\helpers\html; use app\assets\loginasset; loginasset::register($this); ?> <?php $this->beginpage() ?> <!doctype html> <html lang="<?= yii::$app->language ?>"> <head> <meta charset="<?= yii::$app->charset ?>"> <meta name="viewport" content="width=device-width, initial-scale=1"> <?= html::csrfmetatags() ?> <title><?= html::encode($this->title) ?></title> <?php $this->head() ?> </head> <body class="fixed-header"> <?php $this->beginbody() ?> <div class="login-wrapper"> <?= $content ?> </div> <?php $this-...

vb.net - File attributes slow -

using vb.net download files using sftp set attributes normal. file.setattributes(downloadedfile, attr) where attr fileattribute. later set attributes readonly file.setattributes(downloadedfile, fileattributes.readonly) the problem having there appears delay between file being downloaded , attributes being set os(win7). result .normal attribute doesn't set later readonly attribute does. possible wait until os has finished whatever doing? i've looked around , seen various articles changing indexing , folder used store none of these suggestions has worked. don't expect come "you need this" pointer in right direction great help.

ruby - Save Rails array with outer quotes -

is possible save following array without outer quotes? or possible access array without outer quotes? e.hours = "5:30am", "6:00am", "6:30am" # => ["5:30am", "6:00am", "6:30am"] e.save (0.2ms) begin transaction sql (1.6ms) update "brands" set "hours" = ?, "updated_at" = ? "brands"."id" = ? [["hours", "[\"5:30am\", \"6:00am\", \"6:30am\"]"], ["updated_at", "2015-09-30 00:35:25.117927"], ["id", 1]] (6.8ms) commit transaction # => true e # => #<brand id: 1, name: "starbucks", created_at: "2015-09-23 22:59:08", updated_at: "2015-09-30 00:35:25", hours: "[\"5:30am\", \"6:00am\", \"6:30am\"> this migration looks like: add_column :brands, :hours, :string, array: true, default: [] when try access array ...

c - symbol lookup error: ./libobjdata.so: undefined symbol: bfd_map_over_sections -

when compiled getsections_dl.c file, output error, mean have not linked library? my compile command is: gcc getsections_dl.c -l. -ldl -lbfd -o getsections_dl my getsections_dl.c: #include <stdlib.h> #include <string.h> #include <bfd.h> #include <unistd.h> #include <dlfcn.h> extern void dump_sections(bfd *abfd); #define rdtsc(x) __asm__ __volatile__("rdtsc \n\t" : "=a" (*(x))) // following function tweaked version of itoa functions // can found in either objsym.c or objsect.c char* lltoa(long long int val, int base) { if (val == 0x0) { static char zero[] = "0"; return &zero[0]; } static char buf[64] = {0}; int = 60; for(; val && ; --i, val /= base) buf[i] = "0123456789abcdef"[val % base]; return &buf[i+1]; } int main(int argc, char *argv[]) { bfd *obj; void *handle; unsigned long long start, finish; void (*func)(bfd *); bfd_init(); obj = bfd_op...

excel - Showing index of duplicated values -

tim 9/22/2015 joe 9/22/2015 joe 3 tim 2 frank 9/22/2015 tim 9/22/2015 tim 1 frank #n/a joe 9/21/2015 karl 9/22/2015 karl #n/a joe 1 tim 9/21/2015 kim 9/22/2015 kim #n/a tim #n/a luke 9/22/2015 james 9/22/2015 james #n/a luke #n/a i trying index of duplicate name in other table. example, third table shows joe located third in first table, tim first, no karl, no kim, , no james. i used match(name looking for, names in other table, 0). the problem tim available twice in table #1, table #3 showing index 1. i trying create schedule check , date overlapping. function other match?

multithreading - Not working OpenMP in C -

i use function multithread process in while. code runs fine other times stops. have identified problem in multithread process. im newbie multithread , openmp... if have tip solve that... i'll grateful. xp void paralelsim(petrinet *p, matrix *mconflit, int steps){ matrix ring; choicesring(p, mconflit, &ring); clock_t t; t = clock(); while((ring.row!=0) && ((steps>0) || (steps == continue))){ omp_set_dynamic(0); omp_set_num_threads(ring.col); #pragma omp parallel shared(p) { firethread(p, ring.m[0][omp_get_thread_num()]); } if(steps != continue){ steps--; } choicesring(p, mconflit, &ring); } t= clock() - t; printf("%f seconds.\n",t,((float)t)/clocks_per_sec); printf("m:\n"); showmatrix(&p->m); printf("steps: %d\n", p->steps); } too many information missing on code snippet sur...

Python scikit learn pca.explained_variance_ratio_ cutoff -

guru, when choosing number of principal components (k), choose k smallest value example, 99% of variance, retained. however, in python scikit learn, not 100% sure pca.explained_variance_ratio_ = 0.99 equal "99% of variance retained"? enlighten? thanks. the python scikit learn pca manual here http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.pca.html#sklearn.decomposition.pca yes, right. pca.explained_variance_ratio_ parameter returns vector of variance explained each dimension. pca.explained_variance_ratio_[i] gives variance explained solely i+1st dimension. you want pca.explained_variance_ratio_.cumsum() . return vector x such x[i] returns cumulative variance explained first i+1 dimensions. import numpy np sklearn.decomposition import pca np.random.seed(0) my_matrix = np.random.randn(20, 5) my_model = pca(n_components=5) my_model.fit_transform(my_matrix) print my_model.explained_variance_ print my_model.explained...

Can't figure out if/else syntax in Python -

i've decided learn how program, , because it's recommended first, i've started working out python. i've learned think basics, figuring out if/else statements. thought little challenge might try apply things i've learned , whip little program did something. i'm trying make script can read file or find if specific word in file, giving user choice. here's code wrote, , isn't working. print "hello, read file or find whether or not text in file?" choice = raw_input("type 'read' or 'find' here --> ") if choice == "read": readname = raw_input("type filename of file want read here -->" print open(readname).read() elif choice == "find": word = raw_input("type word want find here --> ") findname = raw_input("type filename of file want search here --> ") if word in open(findname).read(): print "the word %r in file %r" % (wo...

Error testing Webview component using Espresso on Android -

i'm trying test values of webview component using espresso. here chart's android hierarchy inspector image . and here chart's html inspector image . i'm trying access grid using code snippet: onwebview().withelement(findelement(locator.class_name, "concept-5089")); considering there row class element contains concept-5089 . but when try execute code, application stops response. what missing ? if more information need, please, let me know can post here thank in advance.

xslt 2.0 - Replace nbsp with another tag -

in xml file have tag this(within p tags have nbsp;) now want replace nbsp tag(as example within p tag want insert tag called s <s/> ) is possible do.please help first note tree on xslt operates never contains character or entity reference, contains unicode character. match on , replace unicode character element can use analyze-string : <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="2.0"> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* , node()"/> </xsl:copy> </xsl:template> <xsl:template match="p//text()"> <xsl:analyze-string select="." regex="&#160;"> <xsl:matching-substring> <s/> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:value-of select="."/> </xsl:non-matching-substring> ...

python - How to efficiently fetch objects after created using bulk_create function of Django ORM? -

i have insert multiple objects in table, there 2 ways that- 1) insert each 1 using save() . in case there n sql db queries n objects. 2) insert of them using bulk_create() . in case there one sql db query n objects. clearly, second option better , hence using that. problem bulk__create not return ids of inserted objects hence can not used further create objects of other models have foreign key created objects. to overcome this, need fetch objects created bulk_create . now question "assuming in situation, there no way uniquely identify created objects, how fetch them?" currently maintaining time_stamp fetch them, below- my_objects = [] # timestamp used fetching created objects time_stamp = datetime.datetime.now() # creating list of intantiated objects obj_data in obj_data_list: my_objects.append(mymodel(**obj_data)) # bulk inserting instantiated objects db mymodel.objects.bulk_create(my_objects) # using timestamp fetch created objects mymodel.obj...

css - Selected menu Highlight ASP.Net Web Forms -

Image
i have code on truckdata page: <!-- begin sidebar --> <div class="left side-menu" style="background: #99ccff"> <div class="body rows scroll-y" style="background: #99ccff; margin-top: 50px; padding-top: 40px"> <!-- sidebar menu --> <div id="sidebar-menu"> <ul> <li> <asp:hyperlink id="hyperlink_truckdata" runat="server" text="truck data" navigateurl="~/view/truckdata.aspx" font-underline="false" style="font-size: 18px; color: black"> <i class="glyphicon glyphicon-info-sign" style="color:black; background: #e8d73e"></i> truck data</asp:hyperlink> </li> <li> <asp:hyperlink id="hyperlink_mai...

How to get any text between an opening and closing node with xpath? -

i want specified text in example when used strong[3] returns airport: normally. how can airport name section xpath? code: <tr> <td> <strong>icao: </strong>kbos <strong>&nbsp;&nbsp;iata: </strong>bos &nbsp;&nbsp; <strong>airport:</strong> general edward lawrence logan international airport </td> </tr> the part need: general edward lawrence logan international airport the solution /tr/td/text()[3]

android - Tap and hold to record video like Vine -

i want make app record video, seems vine, hold record, release stop, hold record , keep end. i have used mediarecorder, record once time, if start record again, app crashed. please tell me there way this? edited code: public class videorecordingactivity extends appcompatactivity implements view.ontouchlistener, view.onlongclicklistener { private context mycontext; private boolean hascamera; private boolean onrecording; private camera mcamera; private camerapreview mpreview; private mediarecorder mediarecorder; private boolean camerafront = false; private int cameraid; private int videonumer; private boolean isactiondown = false; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_video_introduction_recording); initui(); initialize(); } private linearlayout lncamerapreview; private imagebutton btn_recording; private void initui() { lncamerapreview = (linearlayout) findviewbyid(...

android - How to select any file from recent and upload it on server? -

i wanna upload files on server android app. user can pick file recent image, doc or pdf in android app , upload on server. so please tell me how open recent activity , select file , how upload on server. please me important me. you can use */* open files in android. intent intent = new intent(); intent.settype("*/*"); intent.addcategory(intent.category_openable); intent.setaction(intent.action_get_content); startactivityforresult(intent.createchooser(intent, getstring(r.string.perform_action_with)), attachmentchoice); note:where attachmentchoice constant .

vim - Vundle not installing properly -

it seems not plugins installing properly. have following log file: [2015-09-30 14:58:32] plugin user/l9 |~ [2015-09-30 14:58:32] $ git clone --recursive 'https://github.com/user/l9.git' '/home/sachin/.vim/bundle/n|~ ewl9' |~ [2015-09-30 14:58:32] > cloning '/home/sachin/.vim/bundle/newl9'... |~ [2015-09-30 14:58:32] > remote: repository not...

ruby on rails - I got the MissingTemplate error but not knowing the reason -

i access page https://lazyair.co/specials/2015-09-25-02 correctly, and have template specials.html.haml but still show me actionview::missingtemplate how happen ? direction ? thanks controller def specials @specials = special.all end exception an actionview::missingtemplate occurred in welcome#specials: missing template welcome/specials, application/specials {:locale=>[:"zh-tw", :zh], :formats=>["image/webp", "image/*"], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :haml, :jbuilder]}. searched in: ------------------------------- request: ------------------------------- * url : https://lazyair.co/specials/2015-09-25-02 * http method: * parameters : {"controller"=>"welcome", "action"=>"specials", "token"=>"2015-09-25-02"} * process: 7573 because question lacks of finer details, here's i'd do: #app/con...

r - Unable to install dplyr package on windows vista -

i'm trying install dplyr package on windows vista machine (through r studio). have latest version of r installed (3.22) , preview version of r studio installed. i've had no issues in past installing packages, when try install one, got error: > install.packages("dplyr") installing package ‘c:/users/user/documents/r/win-library/3.2’ (as ‘lib’ unspecified) installing dependency ‘bh’ trying url 'http://cran.stat.sfu.ca/bin/windows/contrib/3.2/bh_1.58.0-1.zip' content type 'application/zip' length 13846694 bytes (13.2 mb) downloaded 13.2 mb trying url 'http://cran.stat.sfu.ca/bin/windows/contrib/3.2/dplyr_0.4.3.zip' content type 'application/zip' length 2552598 bytes (2.4 mb) downloaded 2.4 mb i tried installing devtools package install dplyr package straight github. however, devtools package gave me trouble on installation: > install.packages("devtools") installing package ‘c:/users/user/documents/r/win-librar...

Python requests to get Yahoo finance data -

this question has answer here: python requests.exception.connectionerror: connection aborted “badstatusline” 2 answers i'm trying use yahoo finance api python 2.7 , requests. entering in url returns data need without issue. url - http://chartapi.finance.yahoo.com/instrument/1.0/bhp.ax/chartdata;type=quote;range=1d/csv returns timestamp,close,high,low,open,volume 1443571254,21.8800,21.8900,21.8400,21.8550,773600 1443571319,21.9000,21.9000,21.8400,21.8800,63900 1443571379,21.9200,21.9200,21.8700,21.8800,68800 1443571436,21.9350,21.9500,21.9000,21.9200,16700 but, when try same python eg. import requests r = requests.get('http://chartapi.finance.yahoo.com/instrument/1.0/bhp.ax/chartdata;type=quote;range=1d/csv') print r i connectionerror. i can't understand how browser return result, when requests times out. ok, simple answer usi...

javascript - Using Local Storage to set a class for user preference -

please see "latest update" below - niel s has found local storage solution view mode part of question - still need find solution local storage work sort function. my question started off like: please take @ fiddle as can see: 1) sort by: i've got option of sorting child elements either price or pax. 2) view mode: child elements default viewed 3 column layout (default view) ... , i've given user option of switching view 1 column layout (alt view) if prefer. great, works 100% fine problem these choices or preferences can't saved or carried throughout entire session surfing website. in other words, if user decides display listings in: a) price lowest highest b) alt view ... , click on page 2 (where there more of these listings), layout , order go normal making user have re-click on preferences had chosen before on first page - means facility pretty stupid (if cannot remember). so know local storage solution battling implement no succes...

javascript - How to pass extra data content on yii activeform's ajax parameters? -

i trying set ajax request when radio button clicked. here code trying for. <?php echo $form->dropdownlistrow($model, 'page', $pages, array('class' => 'span5', 'prompt' => '-- page --')); ?> <?php echo $form->radiobuttonlistinlinerow($model, 'for', array('desktop'=>'desktop', 'mobile'=>'mobile'), array('ajax' => array( 'type'=>'post', 'url'=>yii::app()->createurl('/admin/adv/loadpositions'), //or $this->createurl('loadcities') if '$this' extends ccontroller 'update'=>'#adv_position', //or 'success' => 'function(data){...handle data in way want...}', 'data'=>array('for'=>'js:this.value', 'page' => 'xxxxxxxx'), ))); ?> i want pass its's value it's upper field's value ajax action....

python - How to interpret the result of format(n, 'c') beyond ASCII? -

consider following example: format(97, 'c') format(6211, 'c') the first outputs 'a' correct; however, second outputs 'c' don't understand why. the string format specification states that: 'c': character. converts integer corresponding unicode character before printing. so shouldn't 6211 mapped unicode character 我 in chinese? related sysinfo: cpython 2.7.10, on fedora 22. you seeing issue 7267 - format method: c presentation type broken in 2.7 . the issue format(int, 'c') internally calls int.__format__('c') , , returns str value (bytes in python 2.x) , hence in range (0, 256) . hence value 256, goes round 0 . example - >>> format(256,'c') '\x00' according issue, fix use python 3 , strings unicode , , issue not there in python 3.x . the workaround can think of use unichr() instead - >>> unichr(0x6211) u'\u6211' >>> print(unich...

c++ - Is undefined behavior in given code? -

what return value of f(p,p), if value of p initialized 5 before call? note first parameter passed reference, whereas second parameter passed value. int f (int &x, int c) { c = c - 1; if (c==0) return 1; x = x + 1; return f(x,c) * x; } options are: 3024 6561 55440 161051 i try explain: in code, there 4 recursive calls parameters (6,4), (7,3), (8,2) , (9,1). last call returns 1. due pass reference, x in previous functions 9. hence, value returned f(p,p) 9 * 9 * 9 * 9 * 1 = 6561. this question competitive exam gate, ( see q.no.-42 ). answer key given gate "marks all" (means there no option correct.) key set-c, q.no.-42 . somewhere explained as: in gate 2013 marks given same code in c/c++ produces undefined behavior. because * not sequence point in c/c++. correct code must replace return f(x,c) * x; with res = f(x,c); return res * x; but given code works fine. gate's key wrong?...

android - MenuItem's onclick method is not called if menu item showAsAction="always" -

Image
im having trouble menu items. i have search view in menu, , set onmenuitemclicklistener on item in onprepareoptionsmenu . and menu xml: showasaction attribute set "always" however, if click search icon, nothing happen, toast did not show up. strange thing if set showasaction="always|collapseactionview", if work, search icon gone , replaced "search" text. it works, toast shown. but icon gone ********************edit**************************************** you using wrong syntax menu. kindly replace menu inflater/handler code this. @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.youractivity_menu, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify paren...

c++ - maximum consecutive repetition in an array -

i want count maximal consecutive trues in array. in follows, return me 4. seems trues in array added up. what's wrong work? here code. int main() { int maxcount = 0; bool list[7]; list[0] = true; list[1] = true; list[2] = false; list[3] = false; list[4] = true; list[5] = true; list[6] = false; (int = 0; < 6; i++) { int count = 0; if (list[i]==true) { count++; (int j = + 1; j < 7; j++) { if (list[j]== list[i]) { count++; } } } if (count > maxcount) { maxcount = count; } } cout << maxcount << endl; } the way implementing wrong. adding true entries in array, without accounting false in between. do this: int currentcount = 0, maxcount = 0; (int = 0; < 7; ++i) { // arr name of array if(arr[i]) ++currentcount; else currentcount = 0; // resetting 0 if false encountered maxcount = ( (currentcount > ma...

Scala traits exposing protected members? -

given class like: class myclass { protected object myobj { ... } } is possible write trait permit exposing myobj . e.g. inheritance following: class testmyclass extends myclass { val getmyobj = myobj } but want via trait, following doesn't typecheck: trait exposemyobj { val getmyobj = myobj // super.myobj/this.myobj don't work } and use like: class testmyclass extends exposemyobj is possible reproduce functionality in testmyclass trait expose protected object, , if how? if know trait mixed in instance of myclass (or subclass), can enforce expectation self-type, , access object: trait exposemyobj { self: myclass => val getmyobj = myobj } edit : example of using trait: class testmyclass extends myclass exposemyobj val test = new testmyclass test.getmyobj // accesses myobj defined in myclass. edit 2 : attempting address @jbrown's comment (re: testing queries within repos) - @ doing following - first, in ea...

json - Could not able to set and get cookies in jquery -

i trying set , cookies in jquery cant read them. var objdata = {}; objdata.username = username; objdata.password = password; var urls = "gallries.aspx/checkuser"; alert(username + password); $.ajax({ type: "post", url: urls, data: "{'username':'" + username + "','password':'" + password + "'}", contenttype: "application/json; charset=utf-8", datatype: "json", success: function (response) { if (response.d == true) { alert(username); $.cookie("loggedinuser", username); alert($.cookie("loggedinuser")); alert('login success'); _loginmsg.addclass("success").removeclass("error"); _loginmsg.html("login successful!"); $('.user_login').animate({ 'top': '-165px' }, 800); $('#mod...

bash - Where is the bash_profile in SUSE Linux -

i not find bash profile running automatically after login. i checked /home/(username) ls -a. i sure there bash profile because when echo $somethings, response. could me ? check ~/.bash_profile , ~/.bash_login , ~/.profile or maybe ~/.bashrc , isn't "profile", might run after login (see invocation in man bash understand when , in order bash reads startup files). if file doesn't exist, can create it. there're system-wide /etc/profile , /etc/bash.bashrc .

symfony - Default to blank string in Twig template if translation is not found -

is there way default blank string rather translation key in event translation has not been found in twig template? i attempting sort of thing using default twig filter alongside trans filter not work: {{ 'crmpicco.general.course.opening_hours_weekend'|default('')|trans }} you can overwrite translation extension own, trans , transchoice filter behave want: <?php // src/appbundle/twig/emptytranslationextension.php namespace appbundle\twig; use symfony\bridge\twig\extension\translationextension; class emptytranslationextension extends translationextension { public function trans($message, array $arguments = [], $domain = null, $locale = null) { $value = parent::trans($message, $arguments, $domain, $locale); return ($message === $value) ? '' : $value; } public function transchoice($message, $count, array $arguments = [], $domain = null, $locale = null) { $value = parent::transchoice($message,...