Posts

Showing posts from March, 2015

android - How to create thumbnails for videos from sd card.? -

i'm new android development, , i'm listing videos storage(my mobile) , want create thumbnail display in custom listview . my problem when creating thumbnail it's taking time, how solve ? please me out. below code create thumbnail @override protected void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); setcontentview(r.layout.video_list); listview videolist=(listview)findviewbyid(r.id.video_list); arraylist<string> videoname = new arraylist<>(); final arraylist<string> videopath = new arraylist<>(); arraylist<bitmap> videothumbnail = new arraylist<>(); string selection =mediastore.video.media._id; string[] columns = { mediastore.video.media.data,mediastore.video.media.display_name}; cursor cursor = getcontentresolver().query(mediastore.video.media.external_content_uri, columns, selection, null, null); while (cursor.movetonext()){ bitmap bmthu

entity framework - Want to update AspNetUser table ,Identity 2.0 -

i want update aspnetuser's fields through entityframework,and code given public customjsonresult saveuser(usereditformmodel userrecord) { if (!modelstate.isvalid) customjson(userrecord); var user = mapper.map<applicationuser>(userrecord); return customjson(userrecord); } //----error: userrecord not mapped applecationuser

combinations - how to omit reciprocal of words in a data.frame using r -

i have been searching answer online cannot seem to anywhere close.. i have set of tickers , used expand.grid() find combinations of them: # tickers <- c("air", "afap", "aal", "cece", "asa", "avx") # find combinations b <- expand.grid(a,a,stringsasfactors=false) so want omit reciprocals, example: row 2 , row 7 reciprocals, , want keep 1 of combinations not both. head(b,10) var1 var2 1 air air 2 afap air 3 aal air 4 cece air 5 asa air 6 avx air 7 air afap 8 afap afap 9 aal afap 10 cece afap using initial output op, can sort 'b' row using apply margin=1 , non-duplicated logical index of 'd1' rows duplicated , , use subset 'b' d1 <- as.data.frame(t(apply(b, 1, sort))) b1 <- b[!duplicated(d1),] head(b1, 10) # var1 var2 #1 air air #2 afap air #3 aal air #4 cece air #5 asa air #6 avx air #8 afap afap #9 aal afap #10 cece afap

javascript - Graph display issue using flot -

i'm totally new in flot. @ first want display 3 chart(d1, d2, d3) data in same page , after when click on new chart button first chart(d1) hide , new chart(d4) insert , 3 chart(d2,d3,d4) show , continuing process. problem graph not displaying. if use random data under function showing graph like this when tried different variables, graph not showing. how can fix problem? here code: <html> <head> <title>graph</title> <style> div.placeholder { width: 400px; height: 200px; } </style> <script type="text/javascript" src="jquery-1.11.3.min.js"></script> <script type="text/javascript" src="jquery.flot.js"></script> <script type="text/javascript"> function getdata(){ var d1 = [[0,1],[1,4],[2,4],[3,8],[4,2],[5,11],[6,19]];

ruby on rails - Why does this delete test not delete my object? -

this spec looks like: "should successfullly destroy user record" expect { delete :destroy, :id => @user1.id }.to change{user.count}.by(-1) end that calls action in userscontroller def destroy @user = user.find(params[:id]) if @user.destroy redirect_to root_path, notice: "you have cancelled account." else redirect_to :back end end but when run spec, this: rspec::expectations::expectationnotmeterror: expected result have changed -1, changed 0 how fix this? edit 1 @user1 being initialized in before_each call @ top of context block it statement lives in. looks this: context "when inviter being deleted , invited has not accepted invitation" before :each @user1 = create(:user, gender: 0) @user2 = create(:user) @member = create(:member, email: @user2.email, first_name: @user2.first_name, last_name: @user2.last_name, bio: @user2.bio, gender: @user2.gender) @membership

azure - Create single push notification channel for multiple apps -

for sending , receiving push notifications want register apps push channel with: var channel = await pushnotificationchannelmanager.createpushnotificationchannelforapplicationasync(); i can send , recieve pushes on channel. the problem channel valid 1 app. if install same app on device receive message on same device sent it. how can push notification devices? the push channel unique each app installation. can use send push 1 installation. if want send push devices running app, have collect push channel info somewhere (your server, etc.) or can use service https://parse.com/ offer targeting multiple devices @ once.

javascript - jquery multiple selector with contains() -

i've lot of <option> s in <select> and , attribute called zip <select id="city"> <option zip="auc 1291 100005" value="1">city 1</option> <option zip=" 1295 100006" value="2">city 2</option> <option zip=" 1299 100008" value="3">city 3</option> </select> now want select option text or zip contains string value, following code doens't work. var val = '1291'; //zip code var x = $('#city option:contains('+val+'), #city zip:contains('+val+')').val(); why? if want select elements attribute, taht value contains requested string, have use: var val = '1291'; //zip code var x = $('#city option[zip*="' + val + '"]').val(); as mentioned: http://api.jquery.com/attribute-contains-selector/ but guys said, better way have html5 data-zip attribute instead of zip

html - Centering a png on a gradient backgound -

Image
i'm trying center png on top of gradient background can't work. html { height: 100%; background-color: red; background: -webkit-linear-gradient(#02747a, #48266c); /* safari 5.1 6.0 */ background: -o-linear-gradient(#02747a, #48266c); /* opera 11.1 12.0 */ background: -moz-linear-gradient(#02747a, #48266c); /* firefox 3.6 15 */ background: linear-gradient(#02747a, #48266c); /* standard syntax */ } #rocket1 { height: 300px; width: auto; margin-left: auto; margin-right: auto; } <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">

postfix mta - How to block sending outgoing mail from other domains in from field -

in postfix mail server, users able send mail on name of different domains using field in mail client software. for eg. using sendemail mail client, , can send emails hdfc.com domain or other too, sendemail -v -f "amit@hdfc.com" -s "test.example.in:25" -xu "amit" -xp "ami*321" -t "xyz@yahoo.co.in" -u "test sendemaili 0255" -m "this sendemail test" this mail goes spam , did not show actual mail address in details header. how can restrict outgoing mails such can send outgoing mails have domain test.example.in? or great if can map user's user can't use other users name. if first case work sufficient me. i searched lot not able this. postfix version 2.11.3-1 on debian jessie. setup have postfix sasl authentication, authentication working fine. -- thanks to block address don't match user email account, below line did magic. add in main.cf smtpd_sender_restrictions = reject_sen

amp html - AMP CLIENT_ID substitution not working -

following amp html url variable substitutions have added amp-pixel client_id(google-analytics) . expect empty string isn't on amp cdn , cookie doesn't exist. text remains client_id(google-analytics) in url. random substituted. full amp-pixel : amp-pixel src="//www.google-analytics.com/collect?v=1&tid=ua-23688336-7&cid=client_id(google-analytics)&t=pageview&dp=%2fnews%2f2016-01-05%2fjekyll-and-hyde-axed-by-itv%2famp&cd1=visitor&cd2=popular%20channels&cd4=sci-fi%2cdrama&cd6=charlie-higson&cd7=jekyll-and-hyde&cd10=amp&z=random" can see wrong or advise please? i think missing cid scope . may review required , optional arguments may pass client_id function. be noted spaces between arguments , values not allowed. cid scope (required) - name of fallback cookie when document not served amp proxy. amp-user-notification id (optional) - optionally make client_id substitution dependent on dismissal of u

c# - Loading the same Assembly twice but with different version -

i have 1 assembly called asm.dll. this assembly has version 1.0.0.0 ( set within assemblyinfo.cs ) then need do code modifications in assembly (still asm.dll), advance version 2.0.0.0 , build again. now, have 2 files named asm.dll differ respect code modifications , version number. how load these 2 files during runtime? addendum: right trying following: var asm1 = assembly.loadfrom("dir1\asm.dll"); var asm2 = assembly.loadfrom("dir2\asm.dll"); var types1 = asm1.gettypes(); var types2 = asm2.gettypes(); type type1 = types1.first<type>(t => t.name.equals("myclassiwanttoinstantiate")); type type2 = types2.first<type>(t => t.name.equals("myclassiwanttoinstantiate")); myobject myobject1 = (myobject1)activator.createinstance(type, new object[] { }); myobject myobject2 = (myobject2)activator.createinstance(type, new object[] { }); but following behavior: the first call activator.createinstance(...) correctly

multithreading - C++/CLI UdpClient multithreaded pool -

i start saying first multi-threaded software, polite :) i have multithreaded application written in c++/cli uses pool of udpclient read from/write external hardware. basically, there 3 threads: receiving thread , manages reception of messages incoming external hardware , puts them in parsing queue, parsing thread checks correctness of received messages , generates proper response put in sending queue, , sending thread continuously checks sending queue send enqueued messages external hardware. as udpclients, use 2 of them: receiving client reception of incoming messages, , sending client send responses: due fact external hardware can change ip address @ runtime, receiving udpclient has listen on ip addresses, while sending client should send datagram specific ip address of external hardware. furthermore, receiving client has timeout value allows control connection status of external hardware. here show example code receiving thread: // receiving thread udpclient^ rece

c - For loop semantics in Bison/Yacc -

i'm trying write own scripting language using flex , bison. have basic parser , add statement similar c language statement. not clear me how code action associated statement suppose have following production 'for' statement: forstatement: '(' expr ';' expr ';' expr ')' statements end; {} it not clear me in action associated production. intuitively understand should something, in action associated previous statement, such : evaluate($3); while(evaluate($5)) { execute($9); evaluate($7); } evaluate($7); where evaluate , execute 2 c functions. so have 2 questions (suppose write c code action associated grammar production): what task of 'evaluate'. mean, how evaluate expression @ every loop considering value of expression potentially changes @ every step of loop? what task of 'execute'. mean, how evaluate statements inside loop considering each statement has different outcome @ every step of loop. the value

c - getting the first value of a null initialized array of strings -

i trying first value of null initialed array of string.i have tried every method can think of no luck. either warning, errors, or segmentation fault. whats correct way print null value , use in if statement? once figured out loop @ end printing strings not equal null. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> int main(int argc, char** argv) { char *strings_line_tokens[503] = {0}; int = 0; strings_line_tokens[0] = malloc(strlen("cookies")+1); strcpy(strings_line_tokens[0], "cookies"); strings_line_tokens[2] = malloc(strlen("foobar")+1); strcpy(strings_line_tokens[2], "foobar"); printf("strings_line_tokens[]: %s\n",strings_line_tokens[0]); printf("-------------------\n"); printf("strings_line_tokens[]: %c %d \n",(char)strings_line_tokens[1], (int)strings_line_tokens[1]); printf("aaaaaaaaaaaaaaaa\n")

PubNub: Publish does not seem to be working for me on 3G network -

Image
i'm using pubnub. there no problem doing publish , subscribe. however, publish not work on slow connection 3g network. wifi ok people 4g has have same problem. know how fix it? what want below. 1. usera opens web page pc , subscribe channel. 2. usera publishes data channel mobile app. pubnub on 3g/4g/lte mobile networks use backfill: true option when invoke pubnub.subscribe(...) method. allows device receive messages on mobile networks. backfill option prevents mobile network latency race conditions. // setup var channel = 'a'+math.random(); var pubnub = pubnub({ ssl : true , "publish_key" : "pub-c-aefb421c-b30a-4afc-bae4-b866c5ea3d69" , "subscribe_key" : "sub-c-76f89e66-c3a9-11e5-b5a8-0693d8625082" }); // receive message pubnub.subscribe({ backfill : true , channel : channel , error : out , connect : publish , message : out }); // send message f

three.js - Morph a cube to coil in three js -

Image
i have tried morph thin rectangular cube coil three.js , tween.js . i've searched questions has been ask none of them guide me. which morph function should use, , how can create coil shape? have tube stored set of n slices you need center point , normal vector each (circle) slice. const int n=128; struct slice { float p[3],n[3]; }; slice mesh[n]; init tube @ start (aligned y axis) for (int i=0;i<n;i++) { mesh[i].p[0]= 0.0; mesh[i].p[1]=-1.0+2.0*float(i)/float(n-1); mesh[i].p[2]= 0.0; mesh[i].n[0]= 0.0; mesh[i].n[1]=+1.0; mesh[i].n[2]= 0.0; } write visualization code such mesh representation you need obtain circumference points of each slice , join them quad_strip or ever primitive using tube surface. top , bottom best triangle_fan around center point. you can obtain points glcircle3d in c++ instead of drawing them store/use them need ... interpolate between tube , helix if above workung can turn centers position , normals helix vari

iis - Access to Sitecore's Update Installation Wizard -

i'm trying upgrade sitecore version, can't access update installation wizard page following url: [site name]/sitecore/admin/updateinstallationwizard.aspx "401 - unauthorized: access denied due invalid credentials. not have permission view directory or page using credentials supplied." i have found following note regarding wizard: "make sure iis configured allow access /sitecore/admin folder. " i have provided full access folder appropriate user, doesn't work anyway. i have solved issue. here solution: find site in iis, move [site]/sitecore/admin folder in tree. click on "admin" folder , double click on "authentication" menu. enable "anonymous authentication".

javascript - How is this if statement working with comma? -

there if statement if ((sliding || "window" == type) && nbcasement % 2 != 1 || sliding || "garage" == type || f({ name: "hinge" }), nbcasement > 0 && !sliding && f({ name: "side" }), d && apiproperty) with && || , , i thought it's same code: f({ name: "hinge" }); f({ name: "side" }); if ((sliding || "window" == type) && nbcasement % 2 != 1 || sliding || "garage" == type || nbcasement > 0 && !sliding && d && apiproperty) but result different thought. how statement working? condition make f({name:xxx}) run? the f defind var e = [] , f = function(a) { d && d.blacklist && d.blacklist[a.name] || e.push(a) }; the comma operator evaluates everything, before returning last value. snippet equivalent to (sliding |

build - Bamboo MsBuild .Net Framework 2.0 -

Image
my project .net framework 2.0 , use visual studio 2012. project build success @ local project build error @ bamboo server solution file error msb5014: file format version not recognized. msbuild can read solution files between versions 7.0 , 9.0, inclusive. you need use version 4 of msbuild in "executable" option determines version of msbuild tools used compile application. not confuse version of .net framework targetting, controlled project files.

swift - Can I redirect to launcher screen from iOs App? -

i newbee in ios app development, , trying create small app using xcode. 1 of views has button close app. when user taps button, have redirect user "launch screen". but don't know how. can guide me? thanks first of there no way can 'close' app programmatically. alternative solution force crash app using exit function. you can use code below: exit(0);

python - What is the best practice to validate a Django DateField at the model level as particular day of the week? -

i have model: class mymodel(models.model): user = models.foreignkey(user) week = models.datefield() my app being built around "weeks ending on saturday", week field accept days saturday. i'd validation happen in model rather in form , i'm going have data input without form in circumstances. i understand overriding model's save() method add full_clean() way go, i'm confused best practice here. what's dryest way? i go providing validator, if need clean db when inputting data without form. if input datetime.date , can use mydate.weekday() day of week. should '5' saturday. something like: def validate_saturday(value): if not value.week.weekday == 5: raise validationerror("date should saturday.") an alternative might specify week number in models instead of datefield.

How to update field value in a Go template -

i have following case, passing struct containing map template: package main import ( "log" "os" "text/template" ) var fns = template.funcmap{ "plus1": func(x int) int { return x + 1 }, } type codec struct { names map[string]string count int } func main() { := map[string]string{"one": "1", "two": "2", "three": "3"} t := template.must(template.new("abc").funcs(fns).parse(`{{$l := len .names}}{{range $k, $v := .names}}{{if ne (plus1 $.count) $l}}{{$k}} {{$v}} {{end}}{{end}}.`)) err := t.execute(os.stdout, codec{a, 0}) if err != nil { log.println(err) } } i increment count field of codec can know how many items of map i've seen. you can define method on struct: type codec struct { names map[string]string count int } func (c *codec) incandget() int { c.count+

php - How to merge multiple images and text into single image? -

Image
i have multiple png images inside div, images png , presents single image user depending on custom options he/she has selected. also, adding text enabled other feature, allows div texts add above of images. now want generate image multiple images , text combined, maintaining font-family & size of text. for eg. image appears on interface combination of images , text. (it's managed appear css positioning) made of 2 images below , text this tried taking images : create-image.php file <?php createimageinstantly(); function createimageinstantly($img1='',$img2='',$img3=''){ $x=$y=1000; header('content-type: image/png'); $targetfolder = '/gw/media/uploads/processed/'; $targetpath = $_server['document_root'] . $targetfolder; $img1 = $targetpath.'img1.png'; $img2 = $targetpath.'img2.png'; $img3 = $targetpath.'img3.png'; $outputimage = imagecreatetruecolor(1000,

Android Studio: GC overhead limit exceeded -

error:execution failed task ':app:transformclasseswithdexfordebug'. > java.lang.outofmemoryerror: gc overhead limit exceeded tried: dexoptions { javamaxheapsize "4g" } that seems solution available online. but still exceeds limit on 2nd build, unless kill studio task , restart, makes work 1st time. definitely not many dependencies in build.gradle build.grade apply plugin: 'com.android.application' android { compilesdkversion 23 buildtoolsversion "23.0.2" defaultconfig { applicationid "com.xxxxx.android" minsdkversion 16 targetsdkversion 23 versioncode 8 versionname "1.3" } dexoptions { javamaxheapsize "4g" } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { c

mysql - SQL order by date descending expression -

i have 2 tables, worker , worker_balance: --------------- ------------------ | worker | | worker_balance | |-------------|<----------|----------------| | | | int workerbid | | ... | | int amount | --------------- | int workerid | | date timestamp | ------------------ and following sql-query: select worker.id, worker.xy, sum(worker_balance.amount) worker join worker_balance on workerbalance.workerid = worker.workerid group worker.id, worker.xy i need results ordered latest timestamp, the oldest must first. worker, last transaction oldest, comes first. you need group by in order aggregate , order by in order sort: select worker.id ,worker.xy ,max(worker.timestamp) last_transaction ,sum(worker_balance.amount) worker join worker_balance on workerbalance.workerid = worker.workerid group worker.id ,worker.xy order la

In android how to close entire application with logout button -

i have activity a, b & c , went a-> c-> b-> @ final activity have 1 logout button, , on click of it, how finish entire application previous activities , stacks. try this, intent intent = new intent(mainactivity.this, loginactivity.class) .setflags(intent.flag_activity_clear_top); finish(); intent.addflags(intent.flag_activity_new_task); intent.addflags(intent.flag_activity_clear_task); startactivity(intent); if have session, please clear session before intent have been called.

django - How many items can be used for list based filtering -

let's doing like user.objects.filter(username=[user1, user2, user3]) what want understand how large list users can be? e.g. think it's ok have 1-100 items there. if end adding 10k or more items? how query work in case? according this answer , maximum elements of python list on 32 bit system 536,870,912 elements. how query work depend on amount of memory, cpu, database used, etc. suggest benchmarking on system you're planning use sample objects.

Creating an AngularJS Directive for jQuery UI Button -

update : fiddle w/ full solution: http://jsfiddle.net/langdonx/vxbhg/ in efforts compare , contrast knockoutjs , angularjs, ran through knockoutjs interactive tutorial , , after each section, i'd rewrite in angularjs using little knew + angularjs reference . when got step 3 of creating custom bindings tutorial, figured time spun on angular directives , write custom tag. failed miserably. i'm against 2 issues haven't been able figure out. created new fiddle try , wrap head around going on... 1 ( fiddle ): figured out scoping issue, but, possible passthrough ng-click ? way work rename jqb-click little annoying. 2 ( fiddle ): applied .button() element, things went weird. guess because both angular , jquery ui manipulating html. wouldn't expect this, angular seems providing own span button (see line 21 of javascript), , of course jquery ui, expect. hacked html looking right, before that, none of functionality works. still have scope issue, , t

angularjs - Angular2 - How is best to do sorting of a pipe list? -

i'm using typescript , angular2. i have pipe filters list of results. now want sort list in alphabetical etc. how this? thanks you implement custom pipe leverages sort method of arrays: import { pipe } "angular2/core"; @pipe({ name: "sort" }) export class arraysortpipe { transform(array: array<string>, args: string): array<string> { array.sort((a: any, b: any) => { if (a < b) { return -1; } else if (a > b) { return 1; } else { return 0; } }); return array; } } and use pipe leveraging pipe chaining: <li *ngfor="list | filter | sort"> (...) </li> it's simple sample arrays string values can have advanced sorting processing (based on object attributes in case of object array, based on sorting parameters, ...). here plunkr this: https://plnkr.co/edit/wbzqddoqn1oahvqmkqrq?p=preview . hope helps you, thierry

hadoop - Spark Streaming - HBase Bulk Load -

i'm using python bulk load csv data hbase table, , i'm having trouble writing appropriate hfiles using saveasnewapihadoopfile my code looks follows: def csv_to_key_value(row): cols = row.split(",") result = ((cols[0], [cols[0], "f1", "c1", cols[1]]), (cols[0], [cols[0], "f2", "c2", cols[2]]), (cols[0], [cols[0], "f3", "c3", cols[3]])) return result def bulk_load(rdd): conf = {#ommitted simplify} keyconv = "org.apache.spark.examples.pythonconverters.stringtoimmutablebyteswritableconverter" valueconv = "org.apache.spark.examples.pythonconverters.stringlisttoputconverter" load_rdd = rdd.flatmap(lambda line: line.split("\n"))\ .flatmap(csv_to_key_value) if not load_rdd.isempty(): load_rdd.saveasnewapihadoopfile("file:///tmp/hfiles" + starttime,

c# - Asp.net search similar to Amazon -

i working on e-commerce website , implement search similar of amazon. have read solr , elasticsearch, wondering if find alternative isn't complex these two. i have following tables: categories, brands , products. tblcategories ------------------------------ id name 1 shoes 2 watch accessories tblbrands ----------------------------------------------------------------- id name 1 puma 2 nike tblproducts ------------------------------------------------------------------ id productname brandname categoryname 1 flip-flop nike shoes 2 running shoes nike shoes i want search on 3 of these tables. using asp.net c#.

php - CodeIgniter caching -

im developing page in codeigniter, suddently having problem caching. when change, there goes 10 minutes before change takes action - properbly because of caching. have added tried add controller constructor out effect: $this->output->set_header("http/1.0 200 ok"); $this->output->set_header("http/1.1 200 ok"); $this->output->set_header("cache-control: no-store, no-cache, must-revalidate"); $this->output->set_header("expires: ". gmdate('d, d m y h:i:s')."gmt"); $this->output->set_header("cache-control: post-check=0, pre-check=0"); $this->output->set_header("pragma: no-cache"); $this->output->cache(0); any know wrong? or have tip? horrible develope this...

android - How can I trace my code step by step like F7 just on project files -

Image
for example when trace step step not jump library files. line line in current class file or projects files. possible? stay in myapp.java , not go dex.java example image: yes, possible. press f8 instead of f7 go directly next line in class.

java - How to determine on login page, if there is some user already logged? -

is there way, how determine, if there logged when using spring 3 mvc + spring security ? security context: <beans xmlns:security="http://www.springframework.org/schema/security" xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> <security:http pattern="/resources/**" security="none"/> <security:http pattern="/login*" security="none" auto-config="true"/> <security:http pattern="/denied" security="none"/> <security:http auto-config="true" access-denied-page="/denied" servlet-api-

c - Is snprintf(NULL,0,...); behavior standardized? -

on linux returns number of characters printed. is standardized behavior? yes. from 7.21.6.5 snprintf function , n1570 (c11 draft): the snprintf function equivalent fprintf, except output written array (specified argument s) rather stream. if n zero, nothing written, , s may null pointer . otherwise, output characters beyond n-1st discarded rather being written array, , null character written @ end of characters written array. if copying takes place between objects overlap, behavior undefined. it's useful method find length of unknown data can first find necessary length , allocate exact amount of memory. typical use case is: char *p; int len = snprintf(0, 0, "%s %s some_long_string_here_", str1, str2); p = malloc(len + 1); snprintf(p, len + 1, "%s %s some_long_string_here", str1, str2);

android - Retrofit post request with parameters -

Image
i using postman extension post request. want make same request android. used retrofit library access goal. can't successful result. mistake in code ? postman : my interface : public interface interfacem { @formurlencoded @post("/login") call<responsebody> getresponse(@field("signin[username]") string username,@field("signin[password]")string password ); } and retrofit usage : retrofit retrofit = new retrofit.builder() .baseurl("http://myurl.com") .build(); interfacem service = retrofit.create(interfacem.class); call<responsebody> result =service.getresponse("myusername","mypassword"); result.enqueue(new callback<responsebody>() { @override public void onresponse(response<responsebody> response) { try {

dictionary - How to Create nested collection map<text,list<text>> type in cassandra database 2.2.1 -

create table tbl_master_values ( dbid int primary key, user_dbid int, reg_dbid int, module_dbid int, fields_value map<text,list<text>>, created_date timestamp, modified_date timestamp); it returns error: invalidrequest: code=2200 [invalid query] message="non-frozen collections not allowed inside collections: map<text, list<text>>" non-frozen collections not allowed inside collections: map> cassandra telling cannot complete operation without using frozen keyword. fields_value frozen<map<text, list<text>>>, keep in mind frozen tells cassandra treat value blob, , prevents individual parts of value being modified. when make change frozen collection serializing , rewriting of items stored. won't solution frequently-changing collection.

jquery - Pass all needed values with Javascript -

Image
i using 2 table print values database. use script select specific cells row. part works well. have created bootstrap modal, , have retrieve values modal , insert values in database. script use select specific cells in different rows. <script> $(".addvalues").click(function () { $('#selection').show(); var $this = $(this), mycol = $this.closest("td"), myrow = mycol.closest("tr"), targetarea = $("#selection"); var qte_input = (' <input type="text" name="kolicina" id="kolicina" placeholder="kg / m" size="10"/>'); targetarea.prepend($("td.data-id", myrow).text() + qte_input +"<hr />"); }); </script> html code <td class='data-id'><?='b-'. $r['id']?> </td> selected values print in div <d

php - WP_Query, using AND with OR -

i have below php:- $args = array( 'posts_per_page'=> -1, 'post_type' => 'jobs', 'order' => 'asc', 's' => $search_field, 'meta_query' => array( 'relation' => 'and', array( 'key' => 'job_salary_from', 'value' => $job_salary_from, 'compare' => '>=', ), array( 'key' => 'job_salary_from', 'value' => $job_salary_to, 'compare' => '<=', ), array( 'relation' => 'or', array( 'key' => 'job_salary_to', 'value' => $job_salary_from,

c++ - Isolating a string of 1's in a character -

i need come function takes char , index of set bit in , isolates string of 1's containing bit. i.e. char isolate(unsigned char arg, int i); for example: isolate(221,2) return 28 (11011101 >>> 00011100) isolate(221,6) return 192 (11011101 >>> 1100000) a lookup table seems clumsy solution require ~256*8=2048 entries. i thinking of examining each individual bit left , right of index: char isolate(char arg, int i) { char result=0; char mask = 1<<i; for(char mask = 1<<i; arg & mask != 0; mask>>=1) result |= mask; for(char mask = 1<<i; arg & mask != 0; mask<<=1) result |= mask; return result; } but seems bit ugly. how can better this? warning: none of tested or relevant*, may interesting. isolating rightmost run of 1s easy, this: x ^ (x & ((x|(x-1))+1)) (explanation below), let's work that. first x|(x-1) smears rightmost 1 right, adding 1 turns bits 0 includin

Lose of data updating PHP and MySQL? -

i have asked 1 of hostings update version of php , mysql , have replied telling me sure have backup of databases of content of page because during update data can lost. is way cover in case of incompetent doing bad job? or can result in potential lose of data reason? i not on mod of downloading site, quite big , thousands of images, , wondering probabilities of suffering lose of data in operation. thanks. this normal procedure of hosting company inform clients perfom backup before touch server. think more technology. things can go wrong regardless of how person trained. advice in addition making backup, have regular backup schedule website in case things go wrong in future.

Create pass for passbook in php -

im trying create dynamically coupons app. have php server create them. don't know why doesn't work on passbook. if create pass terminal works fine. in php php-pkpass. i left code in php below appear in computer pass doesn't add passbook (also if send via e-mail) im 100% sure passtypeidentifier, teamidentifier, certificate , wwdr 100% correctly note: images exists <?php include ("conexion.php"); require('passpk/pkpass.php'); if (isset($_get['cupon']) , $_get['cupon'] != '' , $_get['cupon'] > 0) { $cuponid = $_get['cupon']; $pass = new pkpass\pkpass(); $pass->setcertificate('./certificate.p12'); // 2. set path pass certificate (.p12 file) $pass->setcertificatepassword('*******'); // 2. set password certificate $pass->setwwdrcertpath('./wwdr.pem'); // 3. set path wwdr intermediate certificate (.pem file) // top-level keys http://dev

Generating Vertices in OpenGL ES 2.0 Vertex Shader -

i trying draw triangle 3 vertices a,b,c. typically, have these 3 vertex co-ordinates in array , pass attribute vertex shader. but , possible generate these vertex co-ordinates within vertex shader rather passing attribute (i.e. per vertex co-ordinate value corresponding vertex position). if yes, sample program support ? thanks. you can create variables in vertex shader , pass fragment shader. example: vertex shader precision highp float; uniform float u_time; uniform float u_texturesize; uniform mat4 u_mvpmatrix; attribute vec4 a_position; // passed fragment shader. varying vec2 v_texturecoordinate0; void main() { // create texture coordinate v_texturecoordinate0 = a_position.xy / u_texturesize; gl_position = u_mvpmatrix * a_position; } and fragment shader : precision mediump float; uniform float u_time; uniform float u_pixel_amount; unifor

haskell - Ambiguous type variable when updating two record fields at a time (but not when updating one!) -

the following code fails "ambiguous type variable" error (bottom). however, alternate definition updates record twice works fine: why this? further, "broken" definition below similar 1 in trifecta source . i'm compiling ghc 7.10.3 against trifecta 1.5.2 , parsers 0.12.3. module main import text.trifecta import text.parser.token.style t -- definition causes type error identstyle :: tokenparsing m => identifierstyle m identstyle = t.emptyidents { _stylestart = letter , _styleletter = letter } here working (alternative) definition identstyle :: tokenparsing m => identifierstyle m identstyle = t.emptyidents { _stylestart = letter } { _styleletter = letter } the error generated first definition is: main.hs:10:3: not deduce (tokenparsing t0) arising use of ‘emptyidents’ context (tokenparsing m) bound type signature identstyle :: tokenparsing m => identifierstyle m @ main.hs:8:15-49