Posts

Showing posts from September, 2014

swift2 - swift 2.0 healthkit requestAuthorizationToShareTypes - Type of expression is ambiguous without more context -

after converting swift 1.2 2.0 following error: type of expression ambiguous without more context when request authorisation follow: healthkitstore.requestauthorizationtosharetypes(writetypes: healthkittypestowrite, readtypes: healthkittypestoread,completion: { success, error in if success { print("success") } else { print(error.description) } }) any ideas? i fixed problem, , not sure has error message itself. 1) healthkittypestoread , write: removed [ ] set ( [ ] ) 2) created new completion duple 3) changed call follow bellow example: let healthkittypestoread = set( arrayliteral: hkobjecttype.characteristictypeforidentifier(hkcharacteristictypeidentifierdateofbirth)!, hkobjecttype.characteristictypeforidentifier(hkcharacteristictypeidentifierbiologicalsex)!, hkobjecttype.workouttype() ) let newcompletion: ((bool, nserror?) -> void) = { (success, er

seo - Schema.org setup for related products? -

i setup schema.org markup related products. i have tried code have doubt in mind: itemprop="isrelatedto" itemscope itemtype="http://schema.org/product" my product page https://www.amigotrekking.com/everest-base-camp-trek.html if it’s "functionally similar" product, use issimilarto property. if it’s "consumable" product, use isconsumablefor property. if it’s "accessory or spare part" product, use isaccessoryorsparepartfor property. if it’s "somehow related" product, use isrelatedto property. so related product, microdata example be: <article itemscope itemtype="http://schema.org/product"> <aside> <article itemprop="isrelatedto" itemscope itemtype="http://schema.org/product"></article> </aside> </article>

javascript - listen loaded event of each resource (all scripts, css, images, etc) -

i working page loaded percentage bar based on every single resource in page loading: mean monitoring every image, or script, css, etc , use "loaded event" increase general page loaded percentage i have readed in posts difficult monitor loaded event of elements, question how using javascript / jquery? strategy can use achieve result? i tried this, not working well function calc(element){ console.log(element.outerhtml); progress++; var loadingstatus = ( progress * 100 / totallength ); console.log(loadingstatus); document.getelementbyid('loadingbar').style.width = loadingstatus+'%'; } document.onreadystatechange = function(){ if(document.readystate == "interactive"){ progress = 0; var styleelements = document.queryselectorall('style'); var linkelements = document.queryselectorall('link'); var scriptelements = document.queryselectorall('script[src]'); var

javascript - Update data on mysql using ajax -

i'm trying send id of image when user click on using ajax. in update.php file i'd update id of image. i'm new on ajax, i'm not able figure out error. $(document).ready(function(){ $('.show_people_image .love').on('click', function() { var id = $(this).attr('id'); var idpage = "<?php echo $id ?>"; var svar1 = encodeuricomponent(id); var svar2 = encodeuricomponent(idpage); var svar3 = "<?php echo $_session['aaa'] ?>"; var svar4 = "<?php echo $_session['bbb'] ?>"; if (svar1 == svar2) { $.ajax({ type: "post", url: "update.php", data: {lid:svar1, ml:svar3, mem:svar4}, success: function(data) { alert(data); }, error: function () { alert('error'); } }); } }); }); the update.php file is: if (isset($_post['lid']) ,

sql - Temp Table cannot load content without timing out -

when trying load page times out after time , have no idea how edit query , fix problem. the sql follows: <createtemptable nml-type="string"> declare global temporary table temp_tdt (subject_id_num bigint) on commit preserve rows not logged replace </createtemptable> the dataset not long @ still times out. there has never been problem having no index in past, loaded data no problem, instead of loading data times out first time , goes loading fast. sql written in websphere in xlm file. looking more efficient way. we're missing lot of detail here. either temporary table created every user (every new connection) or every app restart, plus there no indexes on temp table. do timeouts occur on first invocation or after while? best change proper table indexed , if timeouts, analyse queries run against it.

java - Add something after an argument? -

okay writing simple little stringbuilder, curious how add after arguments. example if do: args[0] = "how" args[1] = "do" args[2] = "i" args[3] = "google" how make output this: "how+do+i+google", without plus @ end of last argument? this have far. stringbuilder sb = new stringbuilder(); (int = 0; < args.length; i++){ sb.append(args[i]).append(" "); } string allargs = sb.tostring().trim(); with pre-jdk8 can use guava's joiner : return joiner.on("+").skipnulls().join(args); for jdk8, @chengpohi seems enough, little correction: return string.join("+", args); to extend op code: stringbuilder sb = new stringbuilder(); (int = 0; < args.length; i++){ sb.append(args[i]); if(i != (args.length - 1)) { sb.append('+'); } } string allargs = sb.tostring().trim();

XML Deserialization C#, newline character \n is replaced with \\n -

i trying deserialize simple xml document. <?xml version="1.0" encoding="utf-8"?> <data> <somedata> data1\ndata2\n </somedata> </data> this function. public class datatry { public static string deserialize() { xmlserializer deserializer = new xmlserializer(typeof(data)); textreader reader = new streamreader(@"d:\myfile.xml"); object obj = deserializer.deserialize(reader); data xmldata = (data)obj; reader.close(); return xmldata.somedata; } [serializable, xmlroot("data")] public class data { [xmlelement("somedata")] public string somedata { get; set; } } } the result data1\\ndata2\\n. don't want newline character \n replaced \\n. this behaving expected. your string data1\ndata2\n . \n here not newline character, literal string \n . when @ in debugger, see in escaped form \\n . if wa

c# - Reading cookie from Chrome -

i'm using visual studio 2015, coding in c# , i'm trying read cookie chrome. i have found httpcookie class , have added statement "using system.web;" in top of document, visual studio still doesn't seem recognize this, i'm not able use classes in system.web-namespace. i'm quite sure there easy fix this, kind of problem seems haunt me :-( if may ask silly question have left comment if had priledges, sorry if isn't answer. have got reference system.web.dll in project?

osx - Error importing MySQL package for Python -

i'm trying import mysql module python, more flask, though receive error. i'm using virtual environment application. here error: traceback (most recent call last): file "../myapp/application.py", line 9, in <module> flask.ext.mysql import mysql file "/users/pavsidhu/documents/web-development/app/env/lib/python2.7/site-packages/flask/exthook.py", line 81, in load_module reraise(exc_type, exc_value, tb.tb_next) file "/users/pavsidhu/documents/web-development/app/env/lib/python2.7/site-packages/flaskext/mysql.py", line 3, in <module> import mysqldb file "/users/pavsidhu/documents/web-development/app/env/lib/python2.7/site-packages/mysqldb/__init__.py", line 19, in <module> import _mysql importerror: dlopen(/users/pavsidhu/documents/web-development/app/env/lib/python2.7/site-packages/_mysql.so, 2): library not loaded: /library/python/2.7/site-packages/_mysql.so referenced from: /users/pavsi

eclipse - Create a web service with Tomcat 5.5.30 and Jersey -

i strugging make hello world jersey web service on tomcat 5.5.30 . using eclipse galileo . not using maven . created dynamic web module in version 2.4 created new package com.company.webservice in java resources: src folder of eclipse project added following libraries project, jaxrs-ri-2.19 : javax.ws.rs-api-2.0.1.jar jersey-client.jar jersey-common.jar jersey-container-servlet.jar jersey-container-servlet-core.jar jersey-media-jaxb.jar jersey-server.jar aopalliance-repackaged-2.4.0-b25.jar asm-debug-all-5.0.3.jar hk2-api-2.4.0-b25.jar hk2-locator-2.4.0-b25.jar hk2-utils-2.4.0-b25.jar javassist-3.18.1-ga.jar javax.annotation-api-1.2.jar javax.inject-2.4.0-b25.jar javax.servlet-api-3.0.1.jar jaxb-api-2.2.7.jar jersey-guava-2.19.jar org.osgi.core-4.2.0.jar osgi-resource-locator-1.0.1.jar persistence-api-1.0.jar validation-api-1.1.0.final.jar here web.xml : <?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi=&

python - Django assertTemplateUsed() throws exception with Jinja templates -

when try run test: from django.test import testcase django.core.urlresolvers import reverse django.test import client class statistictest(testcase): def setup(self): self.client = client() def test_schedule_view(self): url = reverse('schedule') response = self.client.get(url) self.assertequal(response.status_code, 200) self.asserttemplateused(response, 'schedule.html') i assertionerror: no templates used render response. it's view: class schedule(view): def get(self, request): games = add_team_info(query.get_current_schedule()) if games not []: available_schedules = generate_schedule_list(games[0]["season_type"], games[0]["week"]) is_available = true else: available_schedules = [] is_available = false return render_to_response("schedule.html", {"games&qu

django - Model.add() in multiple database configuration -

the related manager has a method called add that, "adds specified model objects related object set." for example, can do: b = blog.objects.get(id=1) e = entry.objects.get(id=234) b.entry_set.add(e) # associates entry e blog b. when call add , automatically save. how pass keyword arguments save method calls? in case, want pass using='my-other-db', force_insert=true save method, since in multi-database environment. any ideas?

php - Head content appears in the body tag (Wordpress) -

my head content(metas, scripts etc.) appears in body tag. have header php code <!doctype html> <html <?php language_attributes(); ?>> <head> <meta charset="<?php bloginfo('charset'); ?>"> <meta name="viewport" content="width=device=width"> <title<?php bloginfo('name'); ?></title> <?php wp_head(); ?> </head> <header class="header"> <h1 id="logo"><a href="<?php echo home_url(); ?>">|||</a></h1> <h4 id='title' ><?php the_title(); ?></h4> </header> <body> and footer.php closing this. ` <?php wp_footer(); ?> </body> </html>` already tried changing encoding utf-8 utf-8 without bom using notepad++, , still same ,, website if wanna see inspect [website] website . ideas ? :s your html broken: <title>

php - Search for whitespaces failing Regex -

so trying include spaces search string new using regex need bit o guidance: if(preg_match("/^[a-za-z]+(\s[a-za-z]+)*$/", $_post['name'])){ i know \s meant providing me can search strings not characters? if (preg_match("^(?i)[a-z\s]+$", $_post['name'])) { $name = $_post['name']; $q = "select * users first_name '%" . $name . "%' or last_name '%" . $name ."%' or email '%" . $name ."%'"; $r = mysqli_query($dbc, $q); while($row = mysqli_fetch_array($r)) { $firstname = $row['first_name']; $lastname = $row['last_name']; $email = $row['email']; $extension = $row['extension']; $id = $row['user_id']; echo "<ul>\n"; echo "<li>" .$firstname . " " . $lastname . " &quo

angularjs - How to hide the menu icon when back button is shown? -

i have side menu with: <ion-side-menus enable-menu-with-back-views="true"> so accesable each view of app. when there view have icon , menu icon in top left nav-bar. how can disable menu-icon when there back-icon? the method here : $scope.$on('$ionicview.beforeenter', function (e, data) { if (data.enableback) { $scope.$root.showmenuicon = false; } else { $scope.$root.showmenuicon = true; } }); is not working! because never called! maybe $ionicview.beforeenter not exist anymore? @ least never fired. i solved problem code in each view controller $scope.$on('$ionicview.beforeenter', function () { $ionicsidemenudelegate.candragcontent(false); }); $scope.$on('$ionicview.leave', function () { $ionicsidemenudelegate.candragcontent(true); }); hope helps don't forget add $ionicsidemenudelegate controller

javascript - How to stop calling a delayed function if some other event happens in that period? -

after event happens, have function (rightmenu) triggers 1.5s delay. however, challenge figure out how check if leftmenu called during period stop settimeout function call rightmenu. var leftmenu = function() { // code here } var rightmenu = function() { // code here } $('#leftmenu').on('click', function() { leftmenu(); }) $('#rightmenu').on('click', function() { rightmenu(); }) if (...) { leftmenu(); } else { settimeout(function() { rightmenu(); }, 1500); } i'm not 100% sure if you're asking, can clear intervals. example: function asyncfun() { // code } settimeout(asyncfun, 5000); // run after 5 seconds var asynchandle = settimeout(asyncfun, 10000); cleartimeout(asynchandle); // cancels function call i feel you're asking... if not, other interpretation have want temporarily remove event handler #leftmenu , #rightmenu when you're in other menu. this,

ios - UIPickerView showing empty grey box Swift -

Image
i haven't whole lot of code, might copy here. class viewcontroller: uiviewcontroller, uipickerviewdelegate, uipickerviewdatasource{ var buildings = ["bankbuilding", "cinema" , "cornershop", "greg's house"] @iboutlet weak var buildtext: uitextfield! var buildpickers:uipickerview = uipickerview() override func viewdidload() { super.viewdidload() buildpickers = uipickerview() buildpickers.delegate = self buildpickers.hidden = true; buildtext.inputview = buildpickers buildtext.text = buildings[0] } func numberofcomponentsinpickerview(pickerview: uipickerview) -> int{ return 1 } func pickerview(pickerview: uipickerview, numberofrowsincomponent component: int) -> int{ println("count: \(buildings.count)") return buildings.count } func pickerview(pickerview: uipickerview, titleforrow row: int, forco

linux - how to configure Jenkins on Unix and deployment in a remote machine windows -

i have issue jenkins.i used freestyle project not maven project because it's nodejs project. the workflow below : jenkins trigger gitlab acceptation merge event. jenkins execute build testing integration. execute shell command (linux) in actual linux os. jenkins deploy project after test success remote windows machine. so want how deploy remote windows machine jenkins , git in same machine (linux). , deployment in remote machine windows. you can plan use deployment automation solution xebialabs xl deploy/ibm udeploy/ca nolio specialised products take care of lot of use cases related deployment out of box , not have create scripted solution in jenkins.

asp.net mvc - Getting Data to Show up in My view -

i've got model , controller working, model not showing data inside view. ideas on doing wrong? i have single model trying pass couple variables inside it. i trying use html.viewdata.model.(variable name here). keep getting null exception though have hardset values in model. any ideas model using system; using system.collections.generic; using system.linq; using system.web; using system.collections.generic; using system.componentmodel.dataannotations; using microsoft.aspnet.identity; using microsoft.owin.security; namespace stuff { public class bacnetmodel { private string _rmnum = "room number"; public string rmnum { { return _rmnum; } set{_rmnum = value;} } private string _avres = "70"; public string avres { { return _avres; } set {_avres = value;} } private string _bvres = "t"; public string bvres { { return _bvres; } set { _bvres = value; } } private string _mvres = &

responsive design - Div re-order with CSS -

Image
does know of examples or tutorials on how achieve below: on desktop layout be: on mobile layout change to: as can see, want box 2 , box 3 re-order , swap positions on mobile does have tips or advice? depending on browsers need support use flex-box . using media query screen size set order of second , third boxes switch below screen width. i've done pen short example. i'd recommend css tricks complete guide flexbox talks how use flex far better can. edit: the basic principle set parent element (e.g., container) display: flex ; generates flexbox , allows set different parameters children. using following html: <div class="container"> <div class="box first"> box 1 </div> <div class="box second"> box 2 </div> <div class="box third"> box 3 </div> </div> if set display:flex on .container , can set whether content should display in row

ios - Swift- How do I choose what cells go into what section (UITableView)? -

i have made this: var data = ["apple", "apricot", "banana", "blueberry", "cantaloupe", "cherry", "clementine", "coconut", "cranberry", "fig", "grape", "grapefruit", "kiwi fruit", "lemon", "lime", "lychee", "mandarine", "mango", "melon", "nectarine", "olive", "orange", "papaya", "peach", "pear", "pineapple", "raspberry", "strawberry"] var months = ["january","february","march","april","may","june","july","august","september","october","november","december"] override func numberofsectionsintableview(tableview: uitableview) -> int { // #warning potentially incomplete

mongoose - $all type of operator for subdocuments in mongodb -

mongo document {"objects": { 1 : { type: "a"}, { 2 : { type: "b"}, { 3 : { type: "c"}, { 4 : { type: "a"} } desired result: { 1 : { type : "a"}, 4 : { type : "a"} } how query above mongo document above desired result ? looks went standard mongodb newbie trap assuming have json structure fundamental definition of mongodb used for.. looks can't query follow document structure in mongodb elements:{ 1 : { type : "a"}, 4 : { type : "b"} } this how final document looked like: elements: [ {id: 1, type: "a"}, {id: 4, type: "b"} ] the above document can queried in mongodb way: {"elements.id":1}

ember.js - Build application with client custom theme -

i've application default theme ( less files defined in app/sytles , included in app.less ) , reachable @ main website (for example http://www.example.com ) now need build same application different clients. each client has own style customization ( client.less file) , own assets (images, fonts, ...). site deployed at, example, http://client1.example.com . my idea customize build process passing additional flag ember build --environment production command , customize build process adding client.less file when needed. ember build --environment production --theme client1 far can see there isn't possibility pass flags build command. missing something? there better way achieve that? appreciate, wouldn't maintain 1 project each client.

r - How to handle null entries in SparkR -

i have sparksql dataframe. some entries in data empty don't behave null or na. how remove them? ideas? in r can remove them in sparkr there problem s4 system/methods. thanks. sparkr column provides long list of useful methods including isnull , isnotnull : > people_local <- data.frame(id=1:4, age=c(21, 18, 30, na)) > people <- createdataframe(sqlcontext, people_local) > head(people) id age 1 1 21 2 2 18 3 3 na > filter(people, isnotnull(people$age)) %>% head() id age 1 1 21 2 2 18 3 3 30 > filter(people, isnull(people$age)) %>% head() id age 1 4 na please keep in mind there no distinction between na , nan in sparkr. if prefer operations on whole data frame there set of na functions including fillna , dropna : > fillna(people, 99) %>% head() id age 1 1 21 2 2 18 3 3 30 4 4 99 > dropna(people) %>% head() id age 1 1 21 2 2 18 3 3 30 both can adjusted consider subset of col

java - HttpSession variable null after being set in the Servlet -

here's environment. windows 7, tomcat 8.x , java 7.x i'm writing application, has entry point in servlet, opposed jsp. in servlet create session, assign variable it, , redirect user jsp page. here's java code: httpsession session = request.getsession(); logger.debug("session id: "+session.getid()+ "new session? "+session.isnew()+ "created: "+new java.util.date(session.getcreationtime())); session.setattribute("implementation", simplementation); session.setattribute("requestid", srequestid); response.reset(); response.sendredirect(request.getcontextpath()+"/jsp/productselection.jsp"); in jsp page redirected try retrieve session attribute set in servlet , value comes null, first time use jsp page. if call again resubmitting url in browser works. :o :( here's relevant jsp code, value of simplementation null first time jsp hit. <% system.out.println("session id: "+session.getid()+

Does SQL Server 2008 R2 offer referential integrity across databases? -

i have database user authentication information , business data. possible declare referential integrity constraints on columns in 1 database in another? i using microsoft sql server 2008 r2. referential integrity across tables (somewhat simple rules) maintained use of foreign key constraints. more complex business rules (cross database referential integrity) handled triggers. ideally relational data should kept in 1 database yet complex business requirement can change this, triggers come handy in situation.

r - ggplot2 - Change `geom_rect` colour in a stacked barplot -

Image
i trying plot stacked barplot using ggplot2::geom_bar backgroud shading (using ggplot2::geom_rect() ) according categorical variable follows: shading <- data.frame(min = seq(from = 0.5, = max(as.numeric(as.factor(diamonds$clarity))), = 1), max = seq(from = 1.5, = max(as.numeric(as.factor(diamonds$clarity))) + 0.5, = 1), col = c(0,1)) ggplot() + theme(panel.background = element_rect(fill = "transparent")) + geom_bar(data = diamonds, mapping = aes(clarity, fill=cut)) + geom_rect(data = shading, aes(xmin = min, xmax = max, ymin = -inf, ymax = inf, fill = factor(col), alpha = 0.1)) + geom_bar(data = diamonds, mapping = aes(clarity, fill=cut)) + guides(alpha = false) how change colours of shading? have tried scale_fill_manual(values = c("white", "gray53")) , seems multiple scale aesthetics not possible in ggplot2 ( https://github.com/hadley/ggplot2/issues/578 ).

python - Duplicating Values based on Series input -

i'm trying write custom function extends replace functionality (with domain specific concerns) have series looks like: 0 1 1 2 2 4 3 4 4 4 and return values function (which can't modify unfortunately cause it's coming source) looks either series like: 1 2 b 4 c or dataframe looks this cola colb colc 1 t f 2 b f f 4 c t t i'm trying return output either looks like 0 1 b 2 c 3 c 4 c or cola colb colc 0 t f 1 b f f 2 c t t 3 c t t 4 c t t depending on type returned function. i'm able write script performs iteratively, feel there must more efficient, more pandas specific way of performing operation, before generate hideous nested monstrosity figured i'd check if there's well-supported way! i don't know how data looks may need modify code following works using map : in [32]: s.map(s1[1]) out[32]: 0 0 1 b 2 c 3 c 4

java - How to send multiple functions/options to more than one list item? -

in profile.java class have listview , registered context menu , passed 2 items in profile.xml file named general , silent. want is, when user click on general, must show activate option , when user select silent, should show deactivate. activate , deactivate options in context_menu.xml file. i giving of files. profile.java activity activity; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.profile); activity = this; //list items listview lv = (listview) findviewbyid(android.r.id.list); registerforcontextmenu(lv); setlistadapter(new arrayadapter<string>(this, android.r.layout.simple_list_item_1, getresources().getstringarray(r.array.profile))); } @override public void oncreatecontextmenu(contextmenu menu, view v, contex

android - Google Play services crashes(gapps) -

in device got following error unfortunately process com.google.process.gapps has stopped after app crashing. put acra cash logs. not added in acra. using play store library gcm , map. is device specific issue?

python - How to plot a point-to-point alignment between two sequences of datapoints? -

Image
i'm working on time series dynamic time warping. need plot alignment between datapoints of 2 sequences: t=[t1,t2,t3,...,tx] s=[s1,s2,s3,...,sy] the length of both sequences may vary. have points match, say: [(1,1),(1,2), (2,2), (3,3), (4,3), (4,4)] this read as: t[1] matches s[1] t[1] matches s[2] t[2] matches s[2] ... t[4] matches s[4] what want achieve this: or better, (i.e. nothing 2 sequences , alignment): i'm aware of existence of dtw pacakge though doesn't seem include method plot alignment. i'm new plotting using python i'm still in dark when comes matplotlib , numpy, or @ least i'm not sure best approach go using them. summarizing, need know how plot both sequences, 1 on top of other (subplots might help, believe?) , draw line between each datapoint using python. you should able plot s , t plt.plot. doing lines between them little trickier. i'm assuming x-axis corresponds xth element of both s , t. in

yii2 - How to access gii using homestead -

i using homestead dev environment yii2 tutorial , problem cannot configure lines below access gii in http://hostname/index.php?r=gii 'gii' => [ 'class' => 'yii\gii\module', 'allowedips' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'] ], i have gii working config in conf/web.php if (yii_env_dev) { // configuration adjustments 'dev' environment $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = [ 'class' => 'yii\gii\module', 'allowedips' => ['192.168.56.1'], ]; } using yii 2.0.4 look yii_env_dev in web.php file forgot mention. if you're using vagrant, can share bootstrap.sh file creates yii2 enviroment ubuntu precise. not homestead needed @ all. drop me note if need it.

html - How to set a shadow on a two panels page, regardless of its height? -

Image
i have found answer, not sure best approach problem. page has 2 panels: 1 sidebar , 1 content view . want have shadow on sidebar if content view producing it: the problem sidebar menu buttons, icons, etc. if try set (inset) shadow there: .sidebar { box-shadow: inset -7px 0 9px -7px rgba(0,0,0,0.7); } i get: so, have buttons, hide shadow. if other way content view produces it: .content { box-shadow: -7px 0 9px -7px rgba(0,0,0,0.7); } i shadow along content, if content "shorter" total height of screen, shadow disappears. similar previous case. my final approach set manual height content view or javascript, adapt viewport height. not sure best way it. know if there more css way it, without having set things manually or getting shadows cut. edit while creating fiddle better understanding problem realized had background-color on buttons. since have hover , transition on button, still hides shadow. check out: http://jsfiddle.net/h3cp59qd/

Get value from JSON file in Swift -

i have json file converted nsdictionary object. question how 1 single value out object? make httppost webside , json array values "success" , "userid" want check on success if true or false. import uikit class viewcontroller2: uiviewcontroller { override func viewdidload() { super.viewdidload() // additional setup after loading view. } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } @ibaction func httpbtn(sender: anyobject) { posttoserver() httppost() } func posttoserver() { println("button presed") } func httppost() { var poststring = "email=joakim@and.dk&password=123456" //declare url var url: nsurl! = nsurl(string: "http://95.85.53.176/nhi/api/app/login") var request: nsmutableurlrequest = nsmutableurlrequest(url: url) //declare httpmethod request.httpmethod = "post" //post data

php - $_POST with javascript – it works in javascript but not in jquery plugin -

i have form gets submitted. retrieve submitted data javascript on next page. this works fine when put in body of html: <script> var $_post = <?php echo json_encode($_post); ?>; document.write($_post["form_input_name"]); </script> now want have functionality in jquery plugin method. tried following in jquery plugin: $.pluginname.test = function() { var $_post = <?php echo json_encode($_post); ?>; document.write($_post["form_input_name"]); }; but when try execute in body of html, following error messages: [error] syntaxerror: unexpected token '<' [error] typeerror: undefined not object (evaluating '$.pluginname.test') why code-snipped working in regular javascript environment not when called jquery plugin? your php tags being evaluated javascript. means php not processing them. presumably, because have moved script .js file. while possible generate javascript file

javascript - Form ajax php not work with data serialize with action empty -

this form operated process.php in action form , work well. but when want work in same page action empty, ajax not work (php no receiving data ajax form) when change. data: form.serialize(), data: request, form work, php receiving data ajax have problem, form refresh page. ajax source <script> //if form valid else { loading.show(); $.ajax({ url: form.attr('action'), type: form.attr('method'), data: form.serialize(), success: function(){ shownotice('success'); form.get(0).reset(); loading.hide(); } }); } return false; //this stops submission off form , stops browsers showing default error messages }); </script> html form <form method="post" action="" class="mailform"> <b

javascript - AngularJS ng-change on select with custom directive -

in application have custom directive select tag. <div class="row pv10" ng-if="item.visible"> <div class="col-xs-4 text-danger"><span ng-if="item.label_visible"> {{item.label}}</span></div> <div class="col-xs-8"> <div class="row"> <div class="col-xs-1"> <select ng-options="oneitem oneitem in item.options" ng-model="selecteditem" ng-change="changeevent()"> {{selecteditem | json}} </select> </div> </div> </div> </div> i perform action on every change event. tought of using ng-change, btw. worked fine radiobtn/checkbox.i tried 2 approaches here. firstly tried pass "changeevent" function directive's isolated scope. <custom-select item='item' change-event="change()" ng-if="ite

ios - Selection of Popup Button clearing UI Text Field -

i've been developing programming user can select list of fields popup buttons, press calculate button , depending on choices, string of text gets outputted uitext field. however text field cleared when user starts selecting other choices in popup button before pressing select button. is there anyway possible? just right code in place happens: /*you can replace thetextfieldyouaretalkingabout 1 talking about*/ thetextfieldyouaretalkingabout.text = ""

html - How to set text area to maximum width in bootstrap -

Image
i'm trying create chat area. it'll display messages on top , input on bottom. want keep "esc" button , "send" button same width, increase textarea maximum width while keeping 3 elements inline. i've tried far. <div class="col-sm-8"> <div id="chatarea"> </div> <form class="form-inline" role="form" id="userinput"> <button id="endchat" type="button" class="btn btn-danger">esc</button> <div class="form-group"> <textarea class="form-control" rows="5" id="messagearea"></textarea> </div> <button id="sendmessage" type="submit" class="btn btn-info">send</button> </form> </div> and css #chatarea { height: 500px; background-color: black; } #messagearea {

How do I repeat this JQuery Function/ Animation? -

i have code got github , @ moment calls function once , stops want repeat 3 times , within 3 times want have delay of 10 seconds. i tried using setinterval didn't work. when try insert setinterval code, second time tries animation doesn't work properly. please me out? here link jsfiddle html code: <div class="resized-splitflap sixthanimation"> london </div> <div class="resized-newyork sixthanimation"> new york </div> <div class="resized-dublin sixthanimation"> dublin </div> <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <script> (function ($) { $(document).ready(function () { window.settimeout(function(){ var ratio = 0.5; $('.resized-splitflap').splitflap({ charwidth: 25 * ratio, charheight: 50 * ratio, imagesize: (1250 * ratio) + 'px ' + (50 * ratio) + 'px'

Android SDK Download doesn't start -

i'm trying download android sdk android developers page takes me installation steps , download never starts. i tried using chrome , firefox on linux , windows , download doesnt work. have idea of problem? or maybe way or page download (i need ubuntu 14.04). thanks lot help. i know have tried this. https://developer.android.com/sdk/index.html if click on sdk take license page. try turning off ad-blocker if have 1 on. if unable sdk, can try full android studio suite , download sdk through that. hope helps!

ruby - Debugging Object.const_get -

consider following code (i know have past 30 minutes): [1] pry(main)> durhamscraper::tweet => durhamscraper::tweet [2] pry(main)> object.const_get("durhamscraper::tweet") nameerror: wrong constant name durhamscraper::tweet (pry):2:in 'const_get' [3] pry(main)> string => string [4] pry(main)> object.const_get("string") => string durhamscraper::tweet class loaded (as can infer line 1). no exceptions raised when ran code earlier. change when code executed changed repository name. advice on how debug further, or how may solve this? per ruby 2.1.1 documentation: this method recursively constant names if namespaced class name provided. the issue when changed directory's name, no longer using ruby 2.1.1 , instead using ruby 1.9.3. if object.const_get not work expect, make sure check ruby version , corresponding documentation. for earlier versions of ruby not allow namespaced class names, can walk hierarchy, kardeiz s

c# - Should I Treat Entity Framework as an Unmanaged Resource? -

i working class uses reference ef in constructor. i have implemented idisposable , i'm not sure if need destructor because i'm not can classify ef unmanaged resource. if ef managed resource, don't need destructor, think proper example: public exampleclass : idisposable { public exampleclass(string connectionstringname, ilogger log) { //... db = new entities(connectionstringname); } private bool _isdisposed; public void dispose() { if (_isdisposed) return; db.dispose(); _isdisposed= true; } } if ef unmanaged, i'll go this: public exampleclass : idisposable { public exampleclass(string connectionstringname, ilogger log) { //... db = new entities(connectionstringname); } public void dispose() { dispose(true); } ~exampleclass() { dispose(false); } private bool _isdisposed; protected virtual void dispose(bool di

c# - Winform check Invokerequired for each tabpages in a tabcontrol -

i have winform app in main form has tabcontrol, 1 thread create or remove tabpages frequently.and other background threads data , need visit each tabpage's control inside it. code here , can work: public void getcustomermessage() { if (this.tabcontrol.invokerequired == true) { customerinforhandler handler = getcustomermessage; this.tabcontrol.invoke(handler); } else { //code update in tabpages //with foreach tabpage in tabcontrols , use begininvoke } } the problem is, realize in fact background thread need visit tabpage, not tabcontrol, right check invokerequired property of tabcontrol, or need check each tabpage's invokerequired ? because feel ui block short time. is mean when tabcontrol can visit ui thread, not equals tabpage

c++ - How to avoid aliasing and improve performance? -

in stack overflow answer demonstrated aliasing in c++ can slow down code. , aliasing in c++ doesn't apply pointers, applies references, , more these types specified standard . particularly, there an aggregate or union type includes 1 of aforementioned types among members (including, recursively, member of subaggregate or contained union) so according understanding, if have code below, class a{ public: int val; }; void foo(vector<a> & array, int & size, & a0) { for(int i=0;i<size;++i) { array[i].val = 2*a0.val; } } and possible a0 can alias 1 of elements in array , possibly alias size because of aforementioned quote, a0 , size have loaded each iteration resulting in performance drop. then question should code avoid aliasing, , improve performance? passing const & won't since won't avoid aliasing specified standard. pass a0 value? make copying of a0 don't like, since in practice, class a may comple

javascript - Fetch API Cache Mode -

according spec , there various cache modes fetch api. ("default", "no-store", "reload", "no-cache", "force-cache", , "only-if-cached") however, isn't clear each mode for, or state of browser support. you can see documentation of polyfill here: https://fetch.spec.whatwg.org/ it explain each value means "default" fetch inspect http cache on way network. if there fresh response used. if there stale response conditional request created, , normal request otherwise. updates http cache response. [http] "no-store" fetch behaves if there no http cache @ all. "reload" fetch behaves if there no http cache on way network. ergo, creates normal request , updates http cache response. "no-cache" fetch creates conditional request if there response in http cache , normal request otherwise. updates http cache response. "force-cache" fetch uses