Posts

Showing posts from June, 2013

delphi - Firemonkey: How can I detect the X position of a character in a memo -

i'm trying develop method justify text in memo/label. need take x position of character. possible? if not, how can justify texts in firemonkey? know possible on desktop using vlc library, found nothing firemonkey. i haven't found getting x coords of chars. can create array of widths of characters font , make method count absolute x , y of characters, this: for y := 0 memo.lines.count - 1 x := 0 memo.lines[y].length - 1 begin absolutex := absolutex + charwidths[memo.lines[y][x]]; absolutey := absolutey + charheights[memo.lines[y][x]]; // careful, crossplatform using should use copy(), not string[n] end; for text align can use this(for label have vertextalign) memo.textalign := ttextalign.trailing; // right justify memo.textalign := ttextalign.center; // center justify memo.textalign := ttextalign.leading; // default left justify

php - Dynamic href when generating buttons? -

i have table displaying data user , each row in table has unique id, in table generating button each row more information on content in row. however, need generate unique href each button based on unique id of data in row. way have done it correctly goes link in href without passing unique id. <tbody> <?php while($row = $query->fetch()) { ?> <tr> <td><?php echo $row['car_id']; ?></td> <td><?php echo $row['car_make']; ?></td> <td><?php echo $row['car_model']; ?></td> <td><?php echo $row['number_available']; ?></td> <td><?php echo $row['rent_cost_per_day']; ?></td> <td><a class="btn btn-default" href="cars.php?"<?php $row['car_id']; ?>>view</a></td> </tr> <?php } ?> </tbody> an...

excel - Export Google sheet as xlsx to company network drive -

this function triggered when sheet changed. function exportasxlsx() { var spreadsheet = spreadsheetapp.getactivespreadsheet(); var spreadsheetid = spreadsheet.getid() var file = drive.files.get(spreadsheetid); var url = file.exportlinks[mimetype.microsoft_excel]; var token = scriptapp.getoauthtoken(); var response = urlfetchapp.fetch(url, { headers: { 'authorization': 'bearer ' + token } }); var blobs = response.getblob(); var folder = driveapp.getfoldersbyname('\\gbc1234.fs1.util.xxint.com\shared\projects\test_google2excel'); if(folder.hasnext()) { var existingplan1 = driveapp.getfilesbyname('testgoogle2excel.xlsx'); if(existingplan1.hasnext()){ var existingplan2 = existingplan1.next(); var existingplanid = existingplan2.getid(); drive.files.remove(existingplanid); } } else { folder = driveapp.createfolder('\\gbc1234.fs1.util.xxint.com\shared\projects\test_google2exc...

mongodb - Create unique indexes for document's objects stored in an array -

how 1 create unique indexes document's objects stored in array? { _id: 'documentid', books: [ { unique_id: 1, title: 'asd', }, { unique_id: 2, title: 'wsad', } ... ] } one thing can think of autoincrementing. or there mongo way so? if remove _id field doc, mongo automatically add 1 you, is: guaranteed unique contains timestamp of creation lots of other features. see here: https://docs.mongodb.com/v3.2/reference/method/objectid/ looking @ example object again, referring ids in books array? if so, can assign them objectids well, in document root's _id field: doc.books.foreach(x => { x.unique_id = new objectid() } );

java - Android take multiple photos and return them in a list with delete button -

Image
i working on app have choose 2 values spinner, give them description , take photo (which multiple photos). have simple app needs changes. when press take photo button go camera activity, , after accepting taken photo automatically send photo sever instead return previous activity , see taken photo in list view (under description in main activity) , have possibility remove photo list view. want send data (and photos) after pressing send button. can suggest me guys how possible or links similar examples? have searched not find this. thank you! here java code: oncreateview() @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { db = new sqlitehandler(getactivity().getapplicationcontext()); db.deletezones(); db.deletepoints(); //adding zones database try { new addzonestodatabase().execute().get(); } catch (interruptedexception e) { e.prints...

c# - Why is there no built-in type for DateTime? -

this question has answer here: why there no “date” shorthand of system.datetime in c#? 3 answers most common datatypes have built in type: int32 has int , boolean has bool , string has string , etc. why there no built-in type datetime? first thought it's because datetime has properties , public functions, int . can shed light on this? what's criteria type have built-in equivalent? the clr defines basic building blocks: minimal data types necessary define others. types given alias. since datetime collection of longs , integers, packed in struct, there no need create new data type in clr it. can build data types defined in clr. no need aliasing it.

c++ - c# udpClient sent packets don't exist the router -

using following code: udpclient sender = new udpclient(); try { sender.send(encoding.ascii.getbytes(msgout), msgout.length, ip); } i trying send reply previous request same ip/port. while working on same computer, work if customize values localhost, not work when state own computer ip in nat. 2 facts it: 1) same ip/port values work fine on c++ version of it. (even across globe) next code: sockaddr_in si_custom; int s_custom; //create socket if ((s_custom = socket(af_inet, sock_dgram, ipproto_udp)) == socket_error) { //socket fail return false; } //setup address structure memset((char *)&si_custom, 0, sizeof(si_custom)); si_custom.sin_family = af_inet; si_custom.sin_port = htons(stoi(port)); si_custom.sin_addr.s_un.s_addr = inet_addr(ip.c_str()); //send message if (sendto(s, msg.c_str(), msg.size(), 0, (struct sockaddr *) &si_custom, slen) == socket_error) { closesocket(s_custom); return false; } closesocket(s_...

Ruby on Rails Secrets.yml -

i want make sure i'm not misinterpreting if using environment variables in config/secrets.yml file should still concerned pushing public repo? see many posts adding file git-ignore protect credentials if they're passed in environment variables shouldn't problem correct? if passed environment variables, there's no problem @ all, because thing can see in file contents variable name, , it's not secret. can pushed repo without fears.

c++ - Why there are two signatures of std::forward? -

as stated @ cplusplus.com , std::forward has 2 signatures: template <class t> t&& forward (typename remove_reference<t>::type& arg) noexcept; template <class t> t&& forward (typename remove_reference<t>::type&& arg) noexcept; the typical use of std::forward preserve rvalueness while passing arguments other functions. let's illustrate example: void overloaded(int &) { std::cout << "lvalue"; } void overloaded(int &&) { std::cout << "rvalue"; } template <typename t> void fwd(t && t) { overloaded(std::forward<t>(t)); } when call fwd(0) , t deduces int ( t has type int && ). call std::forward<int>(t) . result of call expression of type int && second version of overloaded function selected , program prints "rvalue" standard output. when call fwd(i) (where int variable), t deduces int& ( t has type int & )....

xaml - x:Bind in resource dictionary doesn't work -

i'm struggling grip of compiled databinding concept. have 1 view (mainpage) contains listbox , 1 data template (itemtemplate) used listbox. mainpage has mainpageviewmodel contains observablecollection of itemviewmodels. itemviewmodel contains 1 property name. mainpage: <page x:class="testapp.mainpage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:testapp"> <page.resources> <resourcedictionary> <resourcedictionary.mergeddictionaries> <resourcedictionary source="itemdictionary.xaml" /> </resourcedictionary.mergeddictionaries> </resourcedictionary> </page.resources> <grid background="{themeresource applicationpagebackgroundthemebrush}"> <listbox itemssource="{x:bind viewmodel.i...

c# - Get function name from text file base on line of code -

Image
i got c++ source called 'mycpp.cpp', locates in: c:\mycpp.cpp ... 5 string cpluspluswarningfunction() 6 { 7 int = 69; 8 int b = + 1; 9 = b; 10 b = 69; 11 return "42 answer"; 12 } ... now want write c# function this void codeanalyzer() { string path = @"c:\mycpp.cpp"; int line = 11; ienumerable<string> loc = file.readlines(path); string code = loc.elementat(line-1);//yes, 'return "42 answer";', job! string functionfullname = "???";//this suppose string 'cpluspluswarningfunction()', how it??? messagebox.show(string.format("the code {0} @ line {1} in function {2}",code,line,functionfullname)); } how can function name replace string "???" in c# code above? i know can done because ms' fxcop can it, sort of (fxcop analyzes compiled object code, not original source code). if compiled object code can done, why not original source code. and visual studio...

java - Javamail Send email work with wifi connection but not with data mobile -

i'm new in android. i'm learning javamail create app can send email notification. follow tutorial https://www.simplifiedcoding.net/android-email-app-using-javamail-api-in-android-studio/ it's working in emulator android. can receive email. tried install app in android device wifi connection, it's working well. when use data mobile connection (not wifi) email not sent. can tell me why? thanks advance. solution @agung comments add code <uses-permission android:name="android.permission.access_network_state" /> in androidmanifest.xml file...

c++ - const member function mutable -

as given understand, const specifier @ end of member function means class's members cannot modified, within function, unless declared mutable. having said have following: mns::list::list linked list implementation of mine functions not const. template<typename t> class hashtable{ private: std::vector<mns::list::list<t> * > * hashtable; long long int size; public: hashtable(int _size){ hashtable = new std::vector<mns::list::list<t> * >(_size, null); size = _size; } .... bool insert(t _value) const { long long int hash_value = gethash(_value); if (hashtable->at(hash_value) == null) hashtable->at(hash_value) = new mns::list::list<t>(_value); else if (hashtable->at(hash_value)->find_forward(_value) == -1) hashtable->at(hash_value)->push_top(_value); } .... } and have function in main: void testhash...

android - How to add a TextView between Buttons -

i'm trying on button click dynamically add textview comments associated button. have button , b. want(when click on a) add text/textview in between button , b. here xml file: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <button android:id="@+id/a" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margintop="5dp" android:text="a" /> <button android:id="@+id/b" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/a" android:layout_margintop="5dp" andr...

c++ - double free or corruption (out) when trying to delete Nodes in a Binary tree -

i'm trying make recursive function delete nodes in binary tree, p->left , p->right pointers next level in tree. gives following error message: * error in `./test.out': double free or corruption (out): 0x00007ffdf0cb3650 * struct node { int key; double data; node * right; node * left; }; void delete_tree(node * & p){ if (p->left){ delete_tree(p->left); } if (p->right){ delete_tree(p->right); } delete p; }; int main(){ node * currentnod = new node; currentnod->key = 5; node * newnode = new node; newnode->key = 3; node * newnode2 = new node; newnode2->key = 6; delete_tree(currentnod); std::cout << currentnod->key << "\n"; std::cout << newnode->key << "\n"; std::cout << currentnod->left->key << "\n"; return 0; i've searched online , realize there can problems when have recursive functions pointers, delet...

c# - Use shared_ptr of unsigned char array in SWIG -

i'm using swig make c++ code available in c#. 1 of tasks exchange data via std::shared_ptr<unsigned char> representing array of unsigned chars. size given separately. think suitable representation in c# byte[] . unfortunately not able manage "translation". here examplary swig interface file: %module example %include <stdint.i> %include <std_pair.i> %include <std_shared_ptr.i> %include <arrays_csharp.i> // result in compile error: "error c2679: binary '=' : no operator found takes right-hand operand of type 'unsigned char *' (or there no acceptable conversion)" //%apply unsigned char input[] {std::shared_ptr<unsigned char>} //%apply unsigned char output[] {std::shared_ptr<unsigned char>} %apply unsigned char input[] {unsigned char*} %apply unsigned char output[] {unsigned char*} %apply unsigned int {std::size_t} %template (mydatapair) std::pair<std::shared_ptr<unsigned char>, std::s...

java - JSTL fn:length() Function with byte[] -

this code in jsp file in spring web model-view-controller (mvc) framework. version of spring web model-view-controller (mvc) framework 3.2.8, deployed in weblogic server version: 12.1.2.0.0. using jstl-1.2 <c:if test="${not empty form.attachment}"> ${fn:length(form.attachment.bytes.length)} </c:if> where private multipartfile attachment; but have error: java.lang.numberformatexception: input string: "length" @ java.lang.numberformatexception.forinputstring(numberformatexception.java:65) @ java.lang.integer.parseint(integer.java:492) @ java.lang.integer.parseint(integer.java:527) @ javax.el.arrayelresolver.tointeger(arrayelresolver.java:378) @ javax.el.arrayelresolver.getvalue(arrayelresolver.java:198) @ javax.el.compositeelresolver.getvalue(compositeelresolver.java:188) @ com.sun.el.parser.astvalue.getvalue(astvalue.java:138) @ com.sun.el.parser.astvalue.getvalue(astvalue.java...

ruby - Rails - params not saving to database -

i'm building events app using rails , trying grips booking confirmation process. @ moment mvc seems on place. here's new booking form free events purely requires quantity of spaces user requires - new.html.erb <%= simple_form_for [@event, @booking], id: "new_booking" |form| %> <% if @booking.errors.any? %> <h2><%= pluralize(@booking.errors.count, "error") %> prevented booking saving:</h2> <ul> <% @booking.errors.full_messages.each |message| %> <li><%= message %></li> <% end %> </ul> <% end %> <div class="form-group"> <p>please confirm number of spaces wish reserve event.</p> <%= form.input :quantity, class: "form-control" %> </div> <p> free event. no payment required.</p> <div class="panel-foot...

wordpress - Automatic Update all posts at once -

i made changes in plugin creates meta boxes, added tome default code "value" of meta box. data being sent outside. problem need press "update" on every woocommerce product permanently saved , sent. have 1500 products. i have tried bulk updating general admin area, shawn here: https://bobwp.com/bulk-edit-posts-wordpress/ it didn't work. tried code: $args = array( 'posts_per_page' => 1000, 'post_type' => 'product' ); $the_query = new wp_query( $args ); if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); $casa_id = $post->id; update_post_meta($post->id, 'casa_id', $casa_id); } } and this: function woo_zap_update_product_name() { if ( ! is_admin() ) { return; } $zap_query = new wp_query( array( 'post_type' => 'product', 'posts_per_page' => -1 ) ); if ( $za...

reactjs - Robust way to handle app errors inside mapStateToProps? -

i'm looking advice on robust , reliable way handle errors within mapstatetoprops, , if it's advisable attempt @ level within react+redux app. for example, if use react-redux 's connect component , mapstatetoprops : function mapstatetoprops(state, ownprops) { throw error('some unfortunate error.'); return { // data } } i want catch error , maybe display error component in place of rendering component. not make attempt recover - pick , move on. at moment i've noticed stalls react completely, , page need reloaded: uncaught typeerror: cannot read property 'gethostnode' of null i handle exception regular data since connect still expect props pass them component. i'd this: function mapstatetoprops(state, ownprops) { try { // code return { // data } } catch (e){ return { error: e } } } and have component props.error , display error message.

group by - Creating realized trades and unrealized trades table from trades data using mysql -

consider have table this ccode | stockname | tradedate | transactiontype| qty 2089 | 'abc' |'2012-09-1' | 'buy' | 200 2089 | 'def' |'2012-09-5' | 'sell' | 500 3412 | 'abc' |'2012-07-12'| 'buy' | 1200 2089 | 'abc' |'2012-09-7' | 'buy' | 200 2089 | 'abc' |'2012-09-8' | 'sell' | 100 3412 | 'def' |'2012-06-5' | 'buy' | 200 3412 | 'abc' |'2012-08-4' | 'buy' | 400 2089 | 'def' |'2012-09-5' | 'buy' | 500 3412 | 'def' |'2012-09-1' | 'sell' | 70 3412 | 'def' |'2012-09-2' | 'sell' | 80 3412 | 'def' |'2012-09-3' | 'sell' | 50 2089 | 'abc' |'2012-10-2' | 'sell...

textbox - UWP - How to apply CharacterSpacing to PlaceholderText -

Image
i want know there way apply characterspacing placeholdertext in textbox? i tried edit textbox template , noticed contentpresenter showing placeholdertext, tried use characterspacing on it, did not work. also, tried fontstretch , again no result. i tried edit textbox template , noticed contentpresenter showing placeholdertext, tried use characterspacing on it, did not work the placeholdertext presented inside contentcontrol when use default style . , plaseholdertext value of content property. type of content property object , in meanwhile, charaterspacing property attribute string. seems reason why charaterspacing doesn't take effects. find controls text property such textbox , autosuggestbox , textblock can take effects on charaterspacing property since type of text property string . how apply characterspacing placeholdertext if want apply charaterspacing placeholdertext here, can use textbox control instead of contentcontrol placehol...

dictionary - From JSON to Typescript interface -

i'm going crazy. i have json: { 'name': 'help me', 'filters': { 'filter1': { 'filter_id': 'wow', 'filter_query': 'maw', }, 'filter2': { 'filter_id': 'wow', 'filter_query': 'maw', } } } and i'm trying in way: export interface myobject { name: string; filters: filters; } export interface filters { [key: string]: queryfilter; } export interface queryfilter { filter_id: string; filter_query: string; friendly_filter_query: string; } or in way: export interface myobject { name: string; filters: map<string, queryfilter[]>;} but in first case got error message: property 'filters' missing in type '{ 'name': string; ...'. and in second case got this: property 'clear' missing in type '{ 'filter1': ...

I'm trying to make a header for my table in Python but the numbers that identify each column won't align with the columns in my table -

Image
this program simple. in program, i'm making power table based on number of rows number of columns user puts in. instance, if user puts in 5 amount of rows, , 6 amount of columns, table appear headers telling how many rows there , how many columns there are, this: with code have now, power table works header columns @ top not aligned, though made them same spacing. plus, need underscores under column headers shown above. here code: def main(): inputrows= 0 inputcolumns= 0 while (inputrows < 2) or (inputrows > 12): inputrows= int(input("enter integer value rows between 2 , 12: ")) while (inputcolumns < 2) or (inputcolumns > 12): inputcolumns= int(input("enter integer value columns between 2 , 12: ")) powertable= buildtable(inputcolumns, inputrows, inputcolumns) in range(inputrows): print(i, end="|") j in range(inputcolumns): powertable[i][j]= i**j ...

Python Curses windows are not shown properly every time I run the program -

i have wierd problem ncurses in python 3.4 trying make windows layout application , code looks this: import curses import time class presentator(): def __init__(self, device_db, address_db): self.curses_windows = {} def update_all_windows(self): wins in self.curses_windows.values(): wins.noutrefresh() curses.doupdate() def update_all_windows(self): wins in self.curses_windows.values(): wins.noutrefresh() curses.doupdate() def create_windows(self): max_height = curses.lines - 5 max_width = curses.cols - 5 self.curses_windows["border"] = curses.newwin(max_height, max_width, 0, 0) self.curses_windows["border"].border() self.curses_windows["title"] = curses.newwin(3, max_width, 0, 0) self.curses_windows["title"].border() title_msg = "ip monitoring" self.curses_windows["title"].adds...

scala - Throttle or debounce method calls -

let's have method permits update date in db: def updatelastconsultationdate(userid: string): unit = ??? how can throttle/debounce method won't run more once hour per user . i'd simplest possible solution, not based on event-bus, actor lib or persistence layer. i'd in-memory solution (and aware of risks). i've seen solutions throttling in scala, based on akka throttler , looks me overkill start using actors throttling method calls. isn't there simple way that? edit : seems not clear enough, here's visual representation of want, implemented in js. can see, throttling may not filtering subsequent calls, postponing calls (also called trailing events in js/lodash/underscore). solution i'm looking can't based on pure-synchronous code only. this sounds great job reactivex -based solution. on scala, monix favorite one. here's ammonite repl session illustrating it: import $ivy.`io.monix::monix:2.1.0` // i'm using ammonite...

c# - Update claims in ClaimsPrincipal -

i using adal azure active directory , need add claims via custom owinmiddleware. when add claims principal, able access them in current request. after page refresh, claim gone. i thought owin handled serialization of claims , put cookie itself, doesn't seem case. i add claims follows: var claimsidentity = (claimsidentity) claimsprincipal.current.identity; if (!claimsidentity.isauthenticated) return; var identity = new claimsidentity(claimsidentity); var currenttenantclaim = gettenantclaim(); if (currenttenantclaim != null) claimsidentity.removeclaim(currenttenantclaim); claimsidentity.addclaim(new claim(claimtypes.currenttenantid, id)); context.authentication.authenticationresponsegrant = new authenticationresponsegrant (new claimsprincipal(identity), new authenticationproperties {ispersistent = true}); any ideas on how persist new claims cookie? i've added claims wrong identity. ...

ios - What is CGFloat.random(min: CGFloat, max: CGFloat) of swift 2 in swift 3? -

im trying generate cgfloat random not know how done in swift 3. cgfloat.random(min: cgfloat, max: cgfloat) of swift 2 equivalent in swift 3? , can find changed swift functions swift 2 swift 3? from https://stackoverflow.com/a/28075467/2383604 use this: public extension cgfloat { /// randomly returns either 1.0 or -1.0. public static var randomsign:cgfloat { { return (arc4random_uniform(2) == 0) ? 1.0 : -1.0 } } /// returns random floating point number between 0.0 , 1.0, inclusive. public static var random:cgfloat { { return cgfloat(arc4random()) } } /** create random num cgfloat - parameter min: cgfloat - parameter max: cgfloat - returns: cgfloat random number */ public static func random(min: cgfloat, max: cgfloat) -> cgfloat { return cgfloat.random * (max - min) + min } } cgfloat.random cgfloat.random(min: 0.1, max: 0.2)

generate histogram in R for employee -

Image
below dataset containing records of employee attendance date intime outtime 2 02/11/2015 10:21:27 17:58:12 3 03/11/2015 10:13:09 18:52:44 4 04/11/2015 10:11:52 18:40:36 5 05/11/2015 10:31:42 18:16:57 6 06/11/2015 10:13:13 18:36:15 10 10/11/2015 10:03:20 18:07:52 11 11/11/2015 09:40:20 18:42:20 12 12/11/2015 10:38:56 18:37:20 13 13/11/2015 10:45:26 18:09:54 16 16/11/2015 10:13:13 18:36:15 17 17/11/2015 10:11:43 18:36:15 18 18/11/2015 10:13:13 18:36:15 19 19/11/2015 10:13:13 18:36:15 20 20/11/2015 12:14:25 20:25:08 23 23/11/2015 10:08:08 17:57:35 24 24/11/2015 14:30:32 18:36:15 the total time served employee in hours : total_time <- with(newdata, sum(pmin(newdata$outtime, "18:00:00") - pmax(newdata$intime, "08:00:00") )) total_time <- 24*floor(as.numeric(total_time)) "total time served employee : 96 hours" i want generate histogram each employee showing hours served on monthly basis having...

c# - Constructor chaining with class as parameter -

question chaining constructor class parameter. i have form list box. form debug purpose. when instanciate object (class) want them write in list box happened. pass debug class parameter other class (class) listbox. pass text delegate callback write each class listbox debug. problem others want call classes (not debugger) , want send me string. i'm trying use chained constructor when instanciate classes debugger class in parameter , when call classes string parameter. code there: public delegate void del_setstringvalcbk(string value); public partial class form1 : form { public debugger debugconsole; internal otherclass anotherclass; internal otherclass anotherclassforstring; public del_setstringvalcbk setstringvalcbk; private string mytexttopass; public form1() { initializecomponent(); mytexttopass = "hello world"; debugconsole = new debugger(); debugconsole.show(); setstringvalcbk = new del_...

html - Is it possible to use CSS to have distinct styling for greyscale printers and color printers? -

using media print, , modern versions of html/css, possible or without javascript auto-select different stylesheet greyscale, b&w , color printers? the idea use syntax highlighting , on omnipresent greyscale laserprinters rendered greyscales of colors make text less legible.

c# - Error for PUT,POST and DELETE RestAPI -

only method working time getting error put,post , delete. tried updating handler mapping thru web.config under iis site too. getting error status code 405 method not allowed. when changed handler mapping <system.webserver> <handlers> <remove name="extensionlessurlhandler-integrated-4.0" /> <remove name="optionsverbhandler" /> <remove name="traceverbhandler" /> <remove name="webdav" /> <remove name="extensionlessurlhandler-integrated-4.0" /> <add name="extensionlessurlhandler-integrated-4.0" path="*." verb="*" type="system.web.handlers.transferrequesthandler" precondition="integratedmode,runtimeversionv4.0" /> <remove name="extensionlessurl-integrated-4.0" /> <add name="extensionlessurl-integrated-4.0" path="*." verb="get,head,post,debug,delete,put...

Image URL to create Bitmap android -

i have small problem, convert url image bitmap. url string obtained through json download volley, , need bitmap able give personalized icon marker. i think can use picasso library here, , show image given url dynamically. there more benefits of using picasso. try if helps you. and there no need download image user. saves images cache show image if user returns in particular time-gap.

c# - Server returns 421 HTTP error when Fiddler is not running -

i'm building api pixiv , far i've managed complete login process , searching tags works well. now want download image on selected webpage. @ first getting certificate errors. fixed temporarily ignoring certificate validation. then interesting thing happened... if fiddler running in background - response received , able download image. no problems, whatsoever. but when fiddler not running, remote server returned 421 error code . things i've tried: closing every response manually , using "using" statement enforced keep-alive header. explicitly declared use of http/1.1 changing proxy settings on httpwebrequest object my image request code looks this: httpwebrequest imagerequest = (httpwebrequest)webrequest.create(imglink); imagerequest.host = $"i.pximg.net"; imagerequest.useragent = user_agent; imagerequest.accept = "image/webp,image/*,*/*;q=0.8"; imagerequest.referer = post.postlink; imagerequest.headers.add("accept...

polymer - Adding <th>'s to Vaadin Grid Dynamically -

when adding columns dynamically how can set <th> 's in grids header. <vaadin-grid id="grid"> <table> <colgroup> </colgroup> <thead> <tr> <th>adfdfa</th> <th>adfdfa</th> </tr> </thead> </table> </vaadin-grid> _addcols: function() { var inputs = this.selectedform.inputs; var grid = this.$.grid; grid.columns = []; for(var = 0; < inputs.length; i++) { var input = inputs[i]; grid.addcolumn({name: input.$key}, i); } }, no matter found in docs. grid.header.getcell(0, 0).content = 'project name'; documentation

LINQ SelectMany equivalent in Scala -

i have quite simple .net logic i'm transplanting scala codebase, , don't know first thing scala. includes linq query groups collection of tagged objects making use of anonymous type projection flatten , join, followed grouping, eg: var q = things.selectmany(t => t.tags, (t, tag) => new { thing = t, tag = tag }) .groupby(x => x.tag, x => x.thing); in scala looks flatmap might of use, can't figure out how combine groupby via anonymous. is kind of thing lot more complicated in scala, or missing simple? update: i ended going with: things.flatmap(t => t.tags.map(x => (x,t))).groupby(x => x._1) and of course later on when access value in map need do: .map(x => x._2) to groups out of tuple. simple when know how! seems me want like. case class tag(tag:string) case class thing(tags : seq[tag]) val things :seq[thing] = seq(thing(seq(tag("")))) val q = things.map { thing => new { val thin...

android - Adding SlidingTab inside tab -

Image
i using library sliding tab smarttablayout - ogaclejapan . want add 1 more sliding tab inside 1 tab of parent sliding tab. when can't see second sliding tab. refer image here mainactivity contains parent sliding tab. <?xml version="1.0" encoding="utf-8"?> <relativelayout 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" xmlns:app="http://schemas.android.com/apk/res-auto" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" android:id="@+id/root" tools:context="com.virtualsquadz.letsgo.mainactivity"> <relativelayout android:layout_wi...

How to finish this Ender's Game script in Processing? -

/* draw laser beam start point in direction of end point have stop if bumps rock.*/ int lasercolor = color(255, 0, 0); int rockcolor = color(0, 255, 0) ; int startx = (1); int starty = (1); int laserx = (10); int lasery = (20); int laserdx = (30); int laserdy = (40); float r = 100; float g = 150; float b = 200; float = 200; float f = 100; float diam = 20; float dim = 70; float x = 100; float y = 100; float z = 20; int t = 100; int s = 100; int w = 60; int h = 60; int eyesize = 16; void setup() { size(400, 400); background(239, 276, 238); } void draw() { drawplayer(); drawrocks(); drawwall(); drawbeam(); background(255); if (mousepressed) { a--; fill(0); text("score" + a, 325, 10); } { void drawplayer(){ // draw player's head fill(255); ellipse(x,y,w,h); // draw player's eyes fill(0); ellipse(x-w/3+1,y,eyesize,eyesize*2); ellipse(x+w/3-1,y,eyesize,eyesize*2); } void drawrocks(){ //draw rocks ...

django - Form stopped saving to database after TextField was changed to HTMLField -

i had working input form model, included textfield called 'opis'. instances of model saved database. however, wanted give users more options when writing -- , storing -- particular bit of text. installed tinymce, changed textfield htmlfield , discovered this, putting <head> {{ form.media }} </head> at beginning of template enough input field rendered tinymce widget. is, kept old modelform, , displayed changed, thought nice , convenient. however, when user submits form, nothing happens -- seems form valid, database not updated. in models.py: from tinymce.models import htmlfield class kurs(models.model): [skipping...] opis = htmlfield() [skipping rest] in forms.py: class kursform(modelform): class meta: model = kurs fields = "__all__" in views.py: def createcourse(request): if request.method=='post': form = kursform(request.post) if form.is_valid(): form.save() ...