Posts

Showing posts from April, 2010

assembly - __pv_stub(x, t, "add", __PV_BITS_31_24)... why __PV_BITS_31_24 is 0x8100_0000? -

the function __virt_to_phys(unsigned long x) which boils down __pv_stub(x, t, "add", __pv_bits_31_24); __pv_stub macro expands add t, x, 0x8100_0000 apart inserting pointer instruction in .pv_table section, can used patch add instruction during bootup. question regarding constant __pv_bits_31_24. there reason use value 0x8100_0000 it. as per understanding value makes 12 bit immediate encoding field of add instruction 481 hex. @ run time during bootup function __fix_pv_table changes 4c0 hex(assume start of first mem bank @ 0x8000_0000). value 0x8100_0000 common such people have decided use default value during compilation , if different anyway it'll fixed during bootup ? or there different reason unable understand ? in short, because has bits 31 , 24 set, results in appropriate instruction encoding patching msb of offset. remember immediate constants in arm instructions formed 8-bit value rotated 1 of 16 positions in 32-bit word. assembling i

html - Horizontal textarea scrollbar can't be grabbed in Chrome when border-radius is applied -

https://jsfiddle.net/h4myo11l/4/ <textarea wrap="off" rows="5" style="border-radius: 4px">aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaabbbbbbbbbaaaaaaaaaaabbbbbbbbbaaaaaaaaaaabbbbbbbbbaaaaaaaaaaabbbbbbbbbaaaaaaaaaaabbbbbbbbb aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaabbbbbbbbb aaaaaaaaaaabbbbbbbbb aaaaaaaaaaabbbbbbbbb </textarea> scroll middle of textbox try grab horizontal scrollbar mouse you can't, text cursor , blinks behind bar! remove border-radius style , repeat: can grab horizontal scrollbar. starts working once scroll bottom. works fine in firefox. use wrap attribute instead of css because it's cross-browser compatible way including ie11 ( html textarea horizontal scroll ). using css resulted in return key being pressed in ie11 produce space instead of newline. is there way fix in chrome? edit: bug fixed in chrome 52 • option 1: i have faced exact

java - Stuck on the prisoner dilema -

Image
i have classic prisoner's dilema java code. here instructions: table: ask user input going do: stay silent or betray. must use joptionpane drop down lists. look , use java random number generator determine friend going do. print message showing results. results include each of did (stayed silent or betrayed) , sentence each person. message should sentence or more – no codes s or b actual words. use joptionpane input , output this have far: import javax.swing.*; public class rich04 { public static void main (string[] args) { string[] ddlist = {"betray", "stay silent"}; object selectedvalue; int code; selectedvalue = joptionpane.showinputdialog( null, "choose one", "prisoner's dilema", joptionpane.question_message, null, ddlist,

jquery - Displaying inputs based on previous selection -

i have page several select inputs take following form <div class="row"> <div class="col-md-12"> <div class="form-group"> <div class="col-sm-7"> <select class="selectpicker" name="producttype" id="producttype"> <option value=""></option> <option value="cereal">cereal</option> </select> </div> </div> </div> </div> what trying display select inputs when previous select has been selected. doing $( "#producttype" ).change(function() { if($(this).val() != '') { $('#yearrow').css('display', 'block'); } else { $('#yearrow').css('display', 'none'); } }); i have set working jsfiddle although have works, h

Select values of a column in an object json then convert it to array AngularJs -

this object want select value of quantity , type don't know how if have make matrix place every value in martix cell begginer in angularjs , thank [ { id: 15, nom: "azerty", type: "azerty", quantity: 456, prix: 25296 }, { id: 21, nom: "sdqs", type: "qsdqsd", quantity: 102, prix: 52 } ] try this var x = [ { id: 15, nom: "azerty", type: "azerty", quantity: 456, prix: 25296 }, { id: 21, nom: "sdqs", type: "qsdqsd", quantity: 102, prix: 52 } ]; var type = []; var quantity = []; x.foreach(function(item, index) { type.push(item.type) quantity.push(item.quantity) if(index == x.length-1){ console.log("type: ",type); //type: ['azerty','qsdqsd'] con

Narrow Eclipse Refresh using native hooks or polling scope to specific project -

while checking refresh using native hooks or polling (from window->preferences->general-workspace) eclipse searching changes on files on whole workspace (all projects under workspace). is there way narrow scope 1 project workspace? i'm editing .css/.js/.html files using sublimetext (3rd party application), , want see changes on server eclipse managed, have 10 projects under workspace , eclipse keep searching updates on them also. no, automatic refresh entire workspace. you can manually refresh single project using 'file > refresh' project selected.

java - How to use Jetty IPAccessHandler to whitelist IPv6 addresses? -

i want jetty server handle requests coming localhost. attempting by: servletcontexthandler context = new servletcontexthandler(servletcontexthandler.sessions); context.setcontextpath("/webapi"); ipaccesshandler ipblockinghandler = new ipaccesshandler(); ipblockinghandler.addwhite("127.0.0.1|/*"); ipblockinghandler.sethandler(context); final org.eclipse.jetty.server.server jettyserver = new org.eclipse.jetty.server.server(8080); jettyserver.sethandler(ipblockinghandler); though, works ipv4 , if add ipblockinghandler.addwhite("127.0.0.1|/*"); not work. this doable overriding ipaccesshandler , manually parsing adddresses: ipaccesshandler ipblockinghandler = new ipaccesshandler(){ @override protected boolean isaddruriallowed(string addr, string path){ return addr.equals("127.0.0.1") || addr.equals("0:0:0:0:0:0:0:1"); } };

Batch: How to find and get file name -

i'm trying find files contains string , print file names , without extension. very important, files located sub-folders of main folder , know path of main folder . this returns 'full path' , extension of files containing word string : findstr /s /m "string" c:main folder\*.txt >list.txt desired output: only file name cheers, andy @echo off setlocal /f "delims=" %%a in ('findstr /s /m /i "string" "c:main folder\*.txt" ') ( echo full %%a echo name %%~na echo nameext %%~nxa ) goto :eof i added /i case-insensitivity. choose filename version want , redirect @ will.

javascript - Website won't fully load without fragment identifier in URL -

this first time posting here , won't give u info work with, i'll try. i've tested website locally , works perfectly. uploaded server , doesn't work without "#" in url (it doesn't load background picture, background color). i cant find problem in code impossible copy-paste 100 000 lines of code here, can give u working , nonworking link here link of website: arminmuzaferija.ba arminmuzaferija.ba/# (working one) note: website links set "#" because still under construction.a the bug in path pictures used in slider (which not loading without fragment identifier in url). javascript expected full path. wrong: <img src="images/picture.png"> right: <img src="http://arminmuzaferija.ba/images/picture.png">

php - Get a dom file content as multidimensional array -

i have xml file named fonts.xml <fonts> <font> <name>abeezee</name> <category>sans-serif</category> </font> <font> <name>abel</name> <category>sans-serif</category> </font> </fonts> now want multidimensional array array = ( 0 => array( name => azeebee category => sans-serif ), 1 => array( name => abel category => sans-serif ) ); i have tried $doc = new \domdocument(); $doc->load( '/fonts/font.xml' ); $nodelist = $doc->getelementsbytagname( "font" ); $list = array(); foreach ($nodelist $n) { $value = $n->nodevalue; $list[] = $value; } if (count($list) > 0) { echo $list[0]; } how can mul

Zip Excel sheet generated through gem axlsx rails -

i'm facing issue of how zip excel sheet generated through gem 'axlsx_rails'. example: class samplecontroller < applicationcontroller::base def export if params[:zip] xxxx else render xlsx: 'export', filename: filename, disposition: 'attachment' end end end in above example, right end user able download excel sheet if end user requests zip file of excel sheet, how can that. because of code in 'else' block end user able download excel sheet. have if user wants excelsheet zipped before download. if need further info, plz let me know. thanks this untested code, try using zip::zipoutputstream : def export if params[:zip] compressed_filestream = zip::zipoutputstream.write_buffer |zos| content = render_to_string xlsx: 'export', filename: filename zos.put_next_entry(filename) zos.print content end compressed_filestream.rewind send_data compressed_filestream.read

swift - Calling a function inside itself -

i have function, , in cases want used 2 times in row, there way call function inside something like, function lot longer , being abel save lot of time func thefunc() { count++ if count < 4 { thfunc() } } that's called recursion , , it's legal: var count = 0 func thefunc() { print(count) count += 1 if count < 4 { thefunc() } } thefunc() // 0 1 2 3 the trick not recurse deeply, risk running out of resources, , don't forget put sort of "stopper" (such if count < 4 ), lest recurse forever, resulting in (oh irony) stack overflow. [extra experts: there languages, such lisp, optimized recursion, , recursion preferred looping! swift not 1 of those.]

core data - Coredata fetch request using NSPredicate -

i want phone number search in sqlite db. phone table have number field holds string value (eg: +1 (2-34)56-78 ). if user enters search text "234", need fetch phone numbers digits(eliminating other alphabets or special characters in string stored) using nspredicate , compare entered string. shall using predicate in fetch request? i tried following predicate , doesnt return me expected result: nspredicate *predicate = [nspredicate predicatewithformat:@"contactname != null , subquery(phonelist, $phone, $phone.number contains[c] %@).@count > 0",searchtext]; is there way done? can use regular expression nspredicate this? nspredicate doesn't support kind of matching. core data model should include data app requires filtering-- might mean fields not visible users. if need match numbers without regard non-numeric characters, should add field contains data. if actual string +1 (2-34)56-78 , add secondary field store 12345678 . use field in predic

c# - Azure Mobile Service in xamarin forms existing code -

i'm working on android app development. using non-secure service end point, using below method post request:- public static t get<t>(webrequest request, string requestdata=null) { string result=string.empty; request.contenttype = "application/json"; request.headers ["zumo-api-version"] = "2.0.0"; try { webresponse webresponse = task.factory.fromasync<webresponse> (request.begingetresponse, request.endgetresponse, null).result; using (var streamreader = new streamreader (webresponse.getresponsestream ())) { result = streamreader.readtoend (); } var typ = typeof(t); if ( typ == typeof(string) || typ == typeof(float) || typ == typeof(decimal) || typ == typeof(int16) || typ == typeof(int32) || typ == typeof(int64) ) { return

Email Validation not working eventhough javascript is enabled and jquery validation working in some cases -

i have issue puzzling me. have created web page on click of button opens bootstrap modal window contains form , form used jquery validation. strange part getting invalid email submissions like: hgchjf kdf surb. j;e563@gamil .com 991199 hcvjh cds zm mnbv42768 ali@hzhsbvxbs ئؤؤللاااتتتن 7حع9ه7908غ7898خح8ح9هع9 assuming javascript not enabled, 1 cannot see form submission out of question. the jquery validation working correctly , have tested several different scenarios. validation script follows <script type="text/javascript"> $(document).ready(function(){ $("#contact-us-form").validate({ rules:{ emailaddress:{ minlength: 5, maxlength: 255, required: true, validemail: true } }, ignore: '', highlight: function(

r - Final row with the sum of the previous results -

this question has answer here: how add row data frame totals? 9 answers i want generate result includes final row find sum of previous results. have following scenario. input data: group <- c("a","s","a","t","a","s") id <- c(25, 34, 28, 52, 3 ,5) dataframe <- data.frame(group, id) dataframe current function: result = group_by(dataframe,group) %>% summarise(q = n()) %>% mutate (freq = round(q / sum(q), 3)) result current result: group q freq (fctr) (int) (dbl) 1 3 0.500 2 s 2 0.333 3 t 1 0.167 dessired result: group q freq (fctr) (int) (dbl) 1 3 0.500 2 s 2 0.333 3 t 1 0.167 total 6 1 how can generate total row? thank much. the closest in r this: list(as.data.frame(result),"

rust - Return local String as a slice (&str) -

there several questions seem same problem i'm having. example see here , here . i'm trying build string in local function, return &str . slicing isn't working because lifetime short. can't use str directly in function because need build dynamically. however, i'd prefer not return string since nature of object going static once it's built. there way have cake , eat too? here's minimal non-compiling reproduction: fn return_str<'a>() -> &'a str { let mut string = "".to_string(); in 0..10 { string.push_str("actg"); } &string[..] } no, cannot it. there @ least 2 explanations why so. first, remember references borrowed, i.e. point data not own it, owned else. in particular case string, slice want return, owned function because stored in local variable. when function exits, local variables destroyed; involves calling destructors, , destructor of string frees memory

SQL Server: Assign a dynamic column name using current DATENAME as column name -

i using following query return dates in current month in m/d/yyyy format: select distinct format(findetail.endtime, 'm/d/yyyy') position join findetail on position.position = findetail.position join product on position.product = product.product month(findetail.endtime) = month(getdate()) , year(findetail.endtime) = year(getdate()) order format(findetail.endtime, 'm/d/yyyy') this returns single column every date current month column not named. | (no column name) | _|__________________|_ | 2/1/2016 | | 2/10/2016 | | 2/11/2016 | | 2/12/2016 | | 2/13/2016 | | ... | for gins, wondering if there way use current date's datename column name in query isn't hard coded? ocd purposes only, isn't accomplishing curious if possible. using following query date name: select datename(month, dateadd(month, month(getdate()), 0) -1) returns february . have gathered way accomplish using dynamic sql have

android - GET YOUTUBE KEY_VIDEO_ID -

how youtube key_vedio_id please me find-out problem. code please , correct me if wrong where. public class youtubeactivity extends youtubebaseactivity implements youtubeplayer.oninitializedlistener { private static final int recovery_dialog_request = 1; public static final string key_video_id = "key_video_id"; private string mvideoid; @override protected void oncreate(bundle bundle) { super.oncreate(bundle); setcontentview(r.layout.activity_youtube); final bundle arguments = getintent().getextras(); if (arguments != null && arguments.containskey(key_video_id)) { mvideoid = arguments.getstring(key_video_id); } final youtubeplayerview playerview = (youtubeplayerview) findviewbyid(r.id.youtubeplayerview); playerview.initialize(getstring(r.string.developer_key_you_tube), this); } @override public void oninitializationsuccess(youtubeplayer.provider provider, you

Why does each child process generate the same "random" number when using rand() in c? -

i trying spawn n child processes, let each child process request random number of resources. however, each child requests identical number of resources, though number changes each time run program. /* create appropriate number of processes */ int pid; for(int = 0; < numberofprocesses; i++){ pid = fork(); if(pid < 0){ fprintf(stderr, "fork failed"); exit(1); } else if(pid == 0){ time_t t; srand((unsigned) time(&t)); printf("child (%d): %d.", i+1, getpid()); /* generate random number [0, max_resources] of resources request */ int requestnum = rand() % (max_resources + 1); printf(" requesting %d resources\n", requestnum); exit(0); } else{ wait(null); } } update: following seems have solved issue. thank help, commented! time_t t; srand((int)time(&t) % getpid()); you seeding random number generator current time. it's same ti

java - Spring 4.3.0 RELEASE - auto login not redirect to home page aftre regestration -

i build web application login & regestration from: after login (username , password) - directing working but after registration "auto login" , redirect user home page isn't working. why happening? usercontroller: @controller public class usercontroller { @autowired private userservice userservice; @autowired private securityservice securityservice; @autowired private uservalidator uservalidator; @requestmapping(value = "/registration", method = requestmethod.get) public string registration(model model) { model.addattribute("userform", new userentity()); return "registration"; } @requestmapping(value = "/registration", method = requestmethod.post) public string registration(@modelattribute("userform") userentity userform, bindingresult bindingresult, model model) { uservalidator.validate(userform, bindingresult); if (bindin

perl - Why doesn't date.format() from Template::Plugin::Date return the duration I expect? -

i have duration in seconds i'm trying convert hh:mm:ss format template toolkit plugin template::plugin::date : [% use date %] [% set tseconds = 478966 %] [% date.format(tseconds ,'%h:%m:%s') %] this returns 13:02:46, expected return 133:02:46 (478966 seconds equal 133 hours, 2 minutes, , 46 seconds). there other way convert duration in seconds hh:mm:ss format using template toolkit? there isn't plugin that, can write own function , pass in information hash, this use strict; use warnings 'all'; use time::seconds; use template; $vars = { format_hms => \&format_hms, }; $tt = template->new; $tt->process(\<<end_template, $vars); [% set tseconds = 478966 %] [% format_hms(tseconds) %] end_template sub format_hms { $t = time::seconds->new(shift); $h = int $t->hours; $t -= $h * one_hour; $m = int $t->minutes; $t -= $m * one_minute; $s = int $t->seconds; sprintf "%d:%02d:%

java - How to name properties of compex @RequestParams in @RestController? -

is possible rename parameters used inside webservice in spring? search.limitresults in following example: localhost:8080/firstname=test&search.limitresults=10 you idea. can achieved? @restcontroller public class myservlet { @requestmapping(value = "/", method = requestmethod.get) private string test(restparams p) { } } @xmlrootelement @xmlaccessortype(xmlaccesstype.field) public class restparams { private string firstname; private string lastname; //is possible nest? @xmlelement(name = "search") private mycomplexsearch search; public mycomplexsearch getsearch() {return search;} public void setsearch(mycomplexsearch) {this.search = search;} @xmlrootelement(name = "search") @xmlaccessortype(xmlaccesstype.field) public class mycomplexsearch { private int limitresults; //some more } } the request not work code above. instead 1 have use mycomplexsearch objects name. local

xamarin.android - Reading Sim Number in Dual Sim Phone Xamarin.Form -

Image
im getting error of java.lang.securityexception: getline1numberfordisplay: neither user 10710 nor current process has android.permission.read_sms. if added read_sms in androidmanifest.xml mycode: public string getnumber() { telephonymanager telephonymanager = (telephonymanager)getsystemservice(telephonyservice); return telephonymanager.line1number; } thanks in advance , day :d this really simple runtime permission request example. i highly recommend reading xamarin blog post , android doc linked below should show user "why" requesting permission before system dialog shows up. [activity(label = "runtimepermissions", mainlauncher = true, icon = "@mipmap/icon")] public class mainactivity : activity { const int permissionsmsrequestcode = 99; protected override void oncreate(bundle savedinstancestate) { base.oncreate(savedinstancestate); setcontentview(resource.layout.main); button button = f

pubnub pushnotification working in android but notification throw all subscribed channels -

am new in andriod , working in chat app using pubnub. required pushnotification format of pn_gcm.data. sending map<> data punub server. , testing gcm receiver http://apns-gcm.bryantan.info/ working fine getting notification web app server. when publish message pn_gcm punbub not getting notification gcm. thing wrong pls me subscribe notification: //callbackmethod { final taskcompletionsource<boolean> task = new taskcompletionsource<>(); this.vinepub.pubnub.addpushnotificationsonchannels() .channels(channels) .deviceid(gcmregid) .async(new pncallback<pnpushaddchannelresult>() { @override public void onresponse(pnpushaddchannelresult result, pnstatus status) { // handle response if (!status.iserror()) { logger.info("channels registered push notifications" + channels); taks.setresult(boolean.true); } else { logger.info("failed registered

javascript - how to mock providers specified in @component meta data in angular-2.0.0-rc-4 -

since, overrideproviders not supported in angular-2.0.0-rc-4. i tried using beforeeach(() => { addproviders([ testcomponentbuilder, feedslistcomponent, { provide: feedsservice, useclass: mockfeedsservice } ]); }); i able mock service if provided @ bootstrap phase. if it's provided @componet level below @component({ ... providers: ['feedsservice'] }) class feedslistcomponent { } even if used provide it's not taking mockedservice. so, there alternative way mock services specified in @component meta data instead of overrideproviders you need use overrideproviders testcomponentbuilder https://angular.io/docs/ts/latest/api/core/testing/testcomponentbuilder-class.html

java - Why does android studio warn me about generic array creation for typed entry -

i have adapter in android project takes in reusable map , simplicity keeps array of data use. private entry<string, string>[] mdata; public myadapter(@nonnull map<string, string> data) { mdata = (entry<string, string>[]) data.entryset().toarray(); } now wanted make little more efficient , rid of unchecked warning, changed using specific array type mdata = data.entryset().toarray( new entry<string, string>[ data.size() ] ); however new entry<string, string>[ data.size() ] part flagged " generic array creation " no further information. why illegal? i understand java has type erasure , generics result in different types (such explained here ), above line of code still seems should legal me. why illegal? because arrays covariant. suppose able compile following code: entry<string, string>[] array = new entry<string, string>[ isomap.size() ]; object[] objarray = array; // not throw arraystoreexception

html - Display data in a from using PHP with ODBC -

i'm trying pull data db html form, have managed table in while loop, not form. here code: if(isset($_post['search'])){ $quote = $_post['quote']; } $stmt = "select * dbo.tblversions2 quotenumber '".$quote."'"; $result = odbc_exec($conn, $stmt) or die('odbc error: ' . odbc_errormsg($conn) ); while (odbc_fetch_row($result)) // while there rows { // out here? know echo "<td>" . odbc_result($result, "quotenumber") . "</td>"; // display tabular data, how form?? } ?> i've tried declaring variable in while loop, such $address1 = -'address1]; declaring in form value=" doesn't seem work, please help!

.net - c# stored procedure launch: Procedure or function expects parameter, which was not supplied -

i've got stored procedure: alter procedure [dbo].[sp_xnet_backup] @backuppath nvarchar(4000) = null, @rc int out begin set @rc = 0 ... ... launched c# project in way: sqlparameter[] paramters = new sqlparameter[2]; byte = 0; string sp = "dbo.sp_xnet_backup"; using (sqlconnection conn = dbmanager.createadoconnmaster()) { conn.open(); sqlcommand cmd = new sqlcommand(sp, conn); cmd.commandtype = commandtype.storedprocedure; paramters[i++] = new sqlparameter("@backuppath", completepath); paramters[i] = new sqlparameter("@rc", sqldbtype.int); paramters[i].direction = parameterdirection.inputoutput; foreach (sqlparameter param in paramters) cmd.parameters.add(param); cmd.executenonquery(); ... ... but gives me error: procedure or function 'sp_xnet_backup' expects parameter '@rc', not supplied. rather using parameterdirection.inputoutput , us

javascript - Reusable factory -

i have such simple code, want have reusable factory can use across multiple ng-app . var app1 = angular.module("xxx", []) .factory("yyy", function () { console.log("yyy"); }); var app = angular .module("operations", ["ngroute", "ui.bootstrap", "cgbusy", "xxx"]) .config(carsappconfig) .constant("events", events) .run(function ($rootscope){ $rootscope.handleerrors = handleerrors; }); carsappconfig.$inject = ["$httpprovider", "$locationprovider", "$routeprovider", "yyy"]; function carsappconfig($httpprovider, $locationprovider, $routeprovider, yyy) { $httpprovider.defaults.transformresponse.push(function (responsedata) { convertdatestringstodates(responsedata); return responsedata; }); but complains cannot create operations module because cannot find yyy dependency. usin

Bootstrap: Having navigation with DIVs (or other elements) instead of UL > LI -

i want have own markup <nav> <my-list class="nav-justified"> <item class="nav-item">text 1</item> <item class="nav-item">text 2</item> </my-list> </nav> i cannot right because bootstrap targetting lis inside element name , not class for example .nav-justified { width: 100%; > li { float: none; > { text-align: center; margin-bottom: 5px; } } any ideas? in case, have add css or change existing one. as i'm using sass lot, thinking extending class/selector — using less need the equivalent :extend(.class) -method . so add less-file in project , in there set markup , extend existing bootstrap-styles: my-list:extend(.nav-justified) {...} .nav-item:extend(.nav-justified > li) {...} (something in direction, depending on needs // code untested) by extending existing selectors , working in separate file project should stay clean , re

matplotlib - how to plot a line in python with an interval at each data point -

Image
using python: have sequence of data points means , list standard deviation each mean. plot means points connected solid line , standard deviation halo around line using same color, changed opacity , width of halo indication of size of std. there 1 plot looks this: time series plot in seaborn , continuous error bars in plotly : data model in first not suitable data far can see , output solution of second suboptimal me. haven't found simple solution in matplotlib. solve plotting data points lines point point , std series of tetragons different opacity. maybe there more comfortable solution out there. in advance! ps: data looks this: means = [3, 5, 1, 8, 4, 6] stds = [1.3, 2.6, 0.78, 3.01, 2.32, 2.9] just : plt.plot (means) plt.fill_between(range(6),means-stds,means+stds,alpha=.1) for

javascript - PHP sendmail form is sending blank e-mail, how can I fix java script? -

i had problem day sendmail.php. first had proble not receive e-mail fix start receive e-mail blank. undestand problem wasn't php code or html code, problem java script wich attached contact-form. var form = $('#main-contact-form'); form.submit(function(event){ event.preventdefault(); var form_status = $('<div class="form_status"></div>'); $.ajax({ url: $(this).attr('action'), beforesend: function(){ form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> email sending...</p>').fadein() ); } }).done(function(data){ form_status.html('<p class="text-success">thank contact us. possible contact you</p>').delay(3000).fadeout(); }); }); this code sending blank e-mail. read answer similar problem , understand should use this; var form = $('.contact-form'); form.submit(functio

amazon web services - AWS CloudWatch to start/stop EC2 instances -

just looking way start/stop aws ec2 instance in case of cpu utilization increase or decrease on ec2 instacne. know there service available auto scaling in aws have scenario can't take advantage of service. so looking if possible or can me on this. just detailing concern suppose have 2 ec2 instance on aws account name ec21 , ec22. default, ec22 instance stopped. now need setup cloudwatch or other service check if load/cpu utilization increase on ec21 instance 70% need start ec22 server , if load decrease on ec21 instance 30% stop ec22 server. please advice! when cloudwatch alarm triggered, notify sns topic. can have sns topic invoke lambda function, can start ec2 instance. create aws lambda function starts ec2 instance. configure sns topic invoke lambda function when receives messages. can read here: invoking lambda functions using amazon sns notifications finally, ensure cloudwatch alert sends messages sns topic.

python - Multiple foreign key fields in abstract Django class -

i have abstract base class declares 2 foreign key fields user model: class basemodel(models.model): updated = models.datetimefield(null=true) updated_by = models.foreignkey(settings.auth_user_model, null=true, related_name="updated_by") created = models.datetimefield(null=true) created_by = models.foreignkey(settings.auth_user_model, null=true, related_name="created_by") class meta: abstract=true i have multiple classes inherit class. when run makemigrations , following error each possible class-pair , both created_by , updated_by : myapp.classa.updated_by: (fields.e305) reverse query name 'classb.updated_by' clashes reverse query name 'classb.updated_by'. hint: add or change related_name argument definition 'classa.updated_by' or 'classb.updated_by'. even though have related_name set. works fine 1 of 2 foreign key fields declared. is possible have 2 foreign key fields same model i

php - laravel how to send request o a controlle with parameter -

i working on laravel 5 this controller <?php namespace app\http\controllers; use app\user; use app\http\controllers\controller; class requestcontroller extends controller { public function sendrequest($endpoint, $body) { return view('response', "d"); } } ?> and in route handle this: route::post("/request/send", 'requestcontroller@sendrequest'); then in html do <form method="post" action="/request/send"> <textarea id="code" contenteditable="true" name="body"></textarea> <input type="text" value="d" name="endpoint" /> <input type="button" id="formattcode" value="format"/> <input type="submit" value="send"/> </form> as see, have body , endpoint in html however getting error errorexception in requ

java - Enabling and disabling of FieldEditors -

i have doubt related usage fieldeditors in plugin development. have preference page consists of stringfieldeditors, booleanfieldeditors, radiogroupfieldeditors etc. the problem i'm facing follows: i have booleanfilededitor called "full details". code follows: booleanfieldeditor fulldetails = new booleanfieldeditor("fulldetails", "full details", org.eclipse.swt.swt.none, getfieldeditorparent()); addfield(fulldetails); once user checks boolean field, stringfieldeditors follow booleanfieldeditor should enabled. otherwise should remain disabled. code other stringfieldeditors follows: stringfieldeditor machinename = new stringfieldeditor("machinename", "host name", getfieldeditorparent()); addfield(machinename); stringfieldeditor ipaddress = new stringfieldeditor("ipaddress", "ip address", getfieldeditorparent()); addfield(ipaddress); stringfieldeditor cpuinfo = new stringfieldeditor("cpuinfo

mysql - Problems updating current user information PHP PDO -

i'm working on user profile system... i'm stuck @ stage user updates information. i'm checking whether users newly chosen email address exists in database. i'm echoing out current email address input value in form. the validation error received preventing user updating other information if email remains same in db.... guidance appreciated. $signedin = $_session['username']; function userexists($db, $email) { $userquery = "select * members email = '$email' , email != '$signedin'"; $stmt = $db->prepare($userquery); $stmt->execute(array(':email' => $email)); return !!$stmt->fetch(pdo::fetch_assoc); } $email = $_post['email']; $exists = userexists($db, $email); if($exists) { header("location: memberaccount.php?action=email_in_use"); } else { //submit form data where start? you're putting variables right query you not use markers although 2, tr

json - Recursive search values by key -

i have json this: { "a": { "error": null }, "b": { "c": {"error": "error string"}}, "c": { "d": {"error": null}}, "d": { "error": "err str"} } end want find values of error keys not null . for example should return "error string" "err str" how can it? possible jq ? use .. iterate recursively, , .error values. if they're null , remove them: jq '.. | .error? // empty' alternatively, instead of using empty can select elements strings strings : jq '.. | .error? | strings'

php - AES - The encrypted string is not decrypting. -

Image
i have 3 php file 1 index.php original string there, encrypt.php encrypt original string , lastly decrypt.php decrypt problem when try decrypt result still encrypted not same encrypt it's different. can me decryption? here picture click encrypt here encrypted. here decrypted problem output should "fwf2" it's different here code index.php <!doctype html> <html> <head> <title></title> </head> <body> <form method="post" action="encrypt.php"> original string <input type="text" name="text"> <input type="submit" name="encrypt" value="encrypt" href="encrypt.php"> </form> </body> </html> here encrypt.php <?php $secret_key = "thisismykey12345"; $iv = mcrypt_create_iv(mcrypt_get_iv_size(mcrypt_rijndael_256, mcrypt_mode_ecb), mcrypt_rand); if(isset($_post['encrypt'])){ $

c++ - What is the best way for creating a fullscreen app in Android NDK which renders in half resolution? -

when initializing egl\gles context, use fullscreen. application rendered in half resolution , blitted screen using simple draw. however, performance reasons, possible initialize context in arbritary resolution (for example half full resolution) , have driver\hardware handle blit fullscreen? you can use android hardware scaler this. the way use depends if initialize egl java or native c++ code: // java surfaceview.getholder().setfixedsize(1280, 720); // native int32_t ret = anativewindow_setbuffersgeometry(window, 1280, 720, 0); using hardware scaler gives better rescaling quality, better performance , less energy usage using render target.

asp.net mvc - MVC Ajax BeginForm validation -

i have bootstrap modal makes insert. using ajax beginform , have problem validation. normal validation like: required fields works great. problem have server validation , when goes controller , not pass custom validation tried return partialview model or json not able trigger validation on modal. googled lot , not able solve problem. here code public class contactdto { public decimal idcontact{ get; set; } public decimal? counterpartyid { get; set; } public string name { get; set; } public string address { get; set; } public string city { get; set; } } controller: [httppost] [validateantiforgerytoken] public jsonresult editcontact(contactdto contact) { if (customvalidation(code) && modelstate.isvalid) { _dbmanager.createcode(code); //return redirecttoaction("details", "counterparties", new { id = code.codecounterpartyid }); return json(new { data = "ok" }, jsonrequestbehavior.allow

One of two same (size and configuration) Android devices not recognized when debug mode activated -

i have 2 android tablets same i.e. hardware, same android version: 5.1 , each has activated debug mode. the first 1 recognized adb , can work , push app second 1 recognized usb device windows when debug mode deactivated. cannot use second tablet on android studio , can't find hint on problem source. fyi: no-brand devices cpu : mtk6582 android version : 5.1 android studio thank verry help. edit : used usbdview software info, here screenshot showing results of 2 devices. vendorid value 0000 in debug mode 0e8d when deactivated same value first device's (cf. bottom). click view screenshot make sure install driver of each device correctly if dosent work restart adb adb kill-server adb start-server hope

asp classic - Data Not Filtering in Jquery Autocomplete -

Image
i've followed examples http://jqueryui.com/autocomplete/ but instead of fixed array wanted dynamic array database i've got working type won't filter results , if type letter doesnt exist in array, still shows full list. search.asp <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>jquery ui autocomplete - default functionality</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css"> <link rel="stylesheet" href="/resources/demos/style.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://co

R Integration to Tableau simple correlation error -

i new in integrating r tableau , trying duplicate work of bala deshpande showing pearson correlation coefficient of mtcars variables. article of deshpande in link. http://www.simafore.com/blog/bid/120209/integrating-tableau-and-r-for-data-analytics-in-four-simple-steps i have checked rserve connection , in processes. have checked connection in tableau , said has connected r. code have written calculated field written below. script_real("cor(.arg1,.arg2)",([variable 1]),([variable 2])) but, when try put correlation calculated field in color marks, shows warning states "an error occurred while communicating rserve service" , when click show details, shows, "error in cor(.arg1,.arg2): 'x' must numeric" i have seen other posts , did not see helpful. have checked null or missing values there none. can help? thanks.

php - Can I download file from my Amazon S3 account without using S3 API? -

i know how download file using php. regarding amazon s3's api; want download using own code. api great, in case want create own set of code. know have set bucket "public". is possible? - download without api; haven't tried yet. yes possible. aws provided way it. please refer below 2 documents. 1) signing , authenticating rest requests 2) get object hope :)

Java While Loops -

i working on while loop stop while variable less 100. have currently, output stops @ 128 - not sure why prints 128 when last output should 64. pointers? import java.util.scanner; public class insectgrowth { public static void main (string [] args) { int numinsects = 0; numinsects = 8; system.out.print(numinsects + " "); while (numinsects < 100) { numinsects = numinsects * 2; system.out.print(numinsects + " "); } system.out.println(); return; } } the last value printed 128 because execute numinsects = numinsects * 2; before system.out.print(numinsects + " "); therefore loop stops when numinsects 64, multiplies 2 before printing, hence why see 128.

How to create an object of a class only once in a Multi Step form PHP -

i have class formhandller <?php include "config.php"; class formhandller { var $dbinstance; var $lastinsertedid;//the id basic information tabel function __construct(){ $this->connectdb(); } function pdomultiinsert($tablename, $data, $pdoobject){ //will contain sql snippets. $rowssql = array(); //will contain values need bind. $tobind = array(); //get list of column names use in sql statement. $columnnames = array_keys($data[0]); //loop through our $data array. foreach($data $arrayindex => $row){ $params = array(); foreach($row $columnname => $columnvalue){ $param = ":" . $columnname . $arrayindex; $params[] = $param; $tobind[$param] = $columnvalue; } $rowssql[] = "(" . implode(", ", $params) . ")"; } //construct our sql statement $sql = "insert `$tablename` ("

android - Image is not loading from web inside viewHolder's ImageView -

i trying make swipeable card app tinder. have used sample . it working fine when getting images drawable resources, viewholder.cardimage not getting set when setting image web in it. viewholder.cardimage not appearing @ all, although flingcontainer's events calling when called functions onbutton click. not getting cue going wrong. following code: public class matchesfragmentplay extends fragment implements flingcardlistener.actiondowninterface { private static final string tag = "matchesfragmentplay"; public static final string[] names = new string[] { "emily rose", "cherry", "anderson", "laius" }; public static final int[] ages = new int[] {20, 22, 25, 18 }; public static final int[] ratings = new int[] {8, 7, 7, 6 }; public static final integer[] images = { r.drawable.lady, r.drawable.lady2, r.drawable.lady3, r.drawable.lady4 }; public static final integer[] likes = { 0, 0, 0, 0 }; public static final integer[] dot