Posts

Showing posts from August, 2014

angularjs - Unit testing function, how to implement call to mock object -

i'm writing unit tests controller has angular scope function when called, calls parse.com framework function makes call parse server , returns success parameters or error code. how go making mock of object unit test? the name of function in controller's scope parse.user.login, , here mock object i've made far. mockparse = { user: { login: function(_username, _password, callbackobj) { callbackobj.success({ attributes:{ username: "testuser", email: "testuser@example.com" } $rootscope.user = _user; $rootscope.isloggedin = true; $state.go('tab.home'); }; callbackobj.error({ err:{ code: 101 } if (err.code == 101){ $scope.error.message = "invalid login credentials"; } else { $scope.error...

How to read blank cell column value of excel using OpenXML in C# -

here in execl sheet there blank value column cell, when use code in error "object reference not set instance of object". foreach (row row in rows) { datarow datarow = datatable.newrow(); (int = 0; < row.descendants<cell>().count(); i++) { datarow[i] = getcellvalue(spreadsheetdocument, row.descendants<cell>().elementat(i)); } datatable.rows.add(datarow); } private static string getcellvalue(spreadsheetdocument document, cell cell) { sharedstringtablepart stringtablepart = document.workbookpart.sharedstringtablepart; string value = cell.cellvalue.innerxml; if (cell.datatype != null && cell.datatype.value == cellvalues.sharedstring) { return stringtablepart.sharedstringtable.childelements[int32.parse(value)].innertext; } else { return value; } } the "cellvalue" don't exist. in case "null", have error. read blank cell : if don't want forma...

R - parse unaligned XML attribute to data frame -

i have xml file structure. <?xml version="1.0" encoding="utf-8"?> <b> <c name="foo" stuff="89" attr="first line&#xa;second line"/> <c name="bar" id="ontime" stuff="23" attr="blahs"/> <c id="delay" name="dog" newattr="clahs"/> ... </b> as can see attribute quite messy; missing values , unaligned. convert following data frame (or other table-like structure) in r language further analysis. ╔══════════╦══════════════╦══════════════════════════════════╦════════════════╦═════════╗ ║ name ║ stuff ║ attr ║ id ║ newattr ║ ╠══════════╬══════════════╬══════════════════════════════════╬════════════════╬═════════╣ ║ 1 foo ║ 89 ║ "first line&#xa;second line" ║ na ║ na ║ ║ 2 bar ║ 23 ║ "blahs" ...

ios - PhysicsBody larger than Texture it is assigned to (pictures) -

i have been having issue 1 of sprites " physicsbody " property. i have placed physicsbody node " barn ", directly on top of non-physicsbody node " mound " without issue. looks fine on simulator, node " hero " keeps bumping invisible barrier, no longer poses problem when remove " barn " (so must issue " barn "). physicsbody element of barn seems extending down y farther actual texture is. i.e. physicsbody , texture seem in 2 different places, despite fact parameters of physicsbody consist of texture: let barn = skspritenode(texture: barn.texture, size: barn.size) barn.physicsbody?.dynamic = false barn.physicsbody?.pinned = true barn.physicsbody?.affectedbygravity = false barn.position = cgpointmake(cgrectgetmidx(self.frame), cgrectgetminy + mound.size.height / 2) as can see in following picture, when apply impulse " hero " node (the black circle sitting on top of tan bar on bottom) gets stopped kind...

.htaccess - URL redirect issue -

i have problem redirecting single webpages within website. trying redirect https://job-center.hu/munkaero_kozvetites/ https://job-center.hu/munkaero-kozvetites/ , using following htaccess file this: <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ /index.php?q=/$1 [qsa] </ifmodule> rewriteengine on rewritecond %{http_host} ^www.allasajanlat.job-center.hu [nc] rewriterule ^(.*)$ https://allasajanlat.job-center.hu/$1 [l,r=301] rewriteengine on rewritecond %{http_host} ^www.job-center.hu [nc] rewriterule ^(.*)$ https://job-center.hu/$1 [l,r=301] options -indexes rewriteengine on rewritecond %{https} off rewriterule (.*) https://%{http_host}%{request_uri} [r,l] redirect 301 /munkaero_kozvetites/ https://job-center.hu/munkaero-kozvetites/ #setenv skip-cache the result strange url , not sure if ok. would considered duplicate content google or ok is. thanks in advance. ...

java - Null pointer exception DrawerLayout -

here mainactivity.java import android.content.context; import android.content.sharedpreferences; import android.support.v4.widget.drawerlayout; import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.support.v7.app.actionbardrawertoggle; import android.support.v7.app.appcompatactivity; import android.support.v7.widget.toolbar; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.arrayadapter; import android.widget.listview; public class mainactivity extends appcompatactivity { listview mnavigationdrawer; private toolbar mtoolbar; private actionbardrawertoggle mdrawertoggle; drawerlayout mdrawerlayout; private boolean muserlearneddrawer; private boolean mfromsavedinstancestate; public static final string pref_file_name = "pref"; public static final string key_user_learned_drawer = "user_learned_drawer"; @override protected void oncreate(bundle savedinstancestate) {...

Passing String Variable as Parameter in JavaScript/jQuery -

i have ajax request returns following text , assigns javascript variable called authcodes . text ajax request: value === '1' || value === '2' || value === '3' . the following code works text manually inserted. $.validator.addmethod("authcode", function(value, element, param) { return this.optional(element) || (value === '1' || value === '2' || value === '3'); }, "please enter valid access code."); however, when try put variable authcodes in, function not work. here variable inserted instead of manually. $.validator.addmethod("authcode", function(value, element, param) { return this.optional(element) || (authcodes); }, "please enter valid access code."); this code related form validation , seems second method, contents of text input ignored , lets value through. whereas first method, values of 1, 2, , 3 let through. any appreciated , thank time in advance. you comparing...

Why i don't have the namespace text to speech in xamarin android? -

using system; using android.app; using android.content; using android.runtime; using android.views; using android.widget; using android.os; using android.speech.tts; namespace app1 { [activity(label = "app1", mainlauncher = true, icon = "@drawable/icon")] public class mainactivity : activity { int count = 1; protected override void oncreate(bundle bundle) { base.oncreate(bundle); // set our view "main" layout resource setcontentview(resource.layout.main); // our button layout resource, // , attach event button button = findviewbyid<button>(resource.id.mybutton); button.click += delegate { button.text = string.format("{0} clicks!", count++); }; } } } i make using android.speech.tts after tts there nothing. maybe need download api using android sdk manager ? there lot of th...

python - How do I find specific event in data series? -

i have series of data files containing analog signal recording. has 2 columns, time , voltage. there specific event , find exact time happens or begins. of data pretty smooth, there huge em spike, data 10x higher rest of them. want find time when spike happens, how can that? have lot of files , big excel need find way extract parts need. i figured easiest find values > threshold, spike covers such wide index range , want precise want isolate beginning of it. here data looks like: % time index chan. 1 -9.993680e-002 -1.249210e+005 -1.351950e-003 -9.993600e-002 -1.249200e+005 -1.416387e-003 -9.993520e-002 -1.249190e+005 -1.158641e-003 -9.993440e-002 -1.249180e+005 -1.255296e-003 -9.993360e-002 -1.249170e+005 -1.319732e-003 -9.993280e-002 -1.249160e+005 -1.094204e-003 -9.993200e-002 -1.249150e+005 -1.094204e-003 -9.993120e-002 -1.249140e+005 -9.331130e-004 -9.993040e-002 -1.249130e+005 -1.287514e-003 -9.992960e-002 -1.249120e...

javascript disable text selection but allow dragging -

i fighting issue while , searches leads use preventdefault() in onmousedown listener (to prevent text selection), when so, disabling dragging (can't drag elements if have draggable="true" attribute). what best way allow dragging elements (using attribute draggable="true") , when dragging them , hovering mouse on text (p, h1 ,h2...) prevent text background form being blue (you know - default when clicking , marking text) thanks. jim. the thing solved issue simple , in css, you can see answer here

android - Shared Element Transition to ImageView works on exit, not smooth on enter -

as can see video when image clicked in recyclerview not smooth when transitioning new activity. when click go original activity transition smooth. how can make transition smooth when opening activity? video of issue here's code launching activity intent myintent = new intent(getactivity(), wallpaperfullactivity.class); view sharedview = v.findviewbyid(r.id.wall_image); string transitionname = "wall_trans"; activityoptionscompat transitionactivityoptions = activityoptionscompat.makescenetransitionanimation(getactivity(), sharedview, transitionname); myintent.putextra(wallpaperfullactivity.bundle_tag, mdatawalls.get(i)); activitycompat.startactivity(getactivity(), myintent, transitionactivityoptions.tobundle()); seeing names of variables, guess transitioning imageview high resolution image. problem might be, loading of image takes time , final position , size of imageview not known @ time of transitioning, making transition jerky. consider postponin...

api - Visual studio Express Edition vs Community -

my question difference between visual studio express edition desktop , visual studio community version? i want use vs create desktop apps, have ultimate version of vs2013, think mentioned versions lighter , faster , full free me because don't use of developing features team server or testing tools or intellitrace, ... . want know mentioned versions have full windows api support (header files definition) ultimate/enterprise versions? don't forget first question: vs express desktop vs community, because both free. thanks community edition full fledged software, can't use on enterprise (>5 users) on other hand, express editions can used in enterprise environments, not let use plugins. so in end, far can tell choice between plugins , enterprise. if it's product developing yourself, or open source software, community edition best bet. on other hand, if want try out latest version @ work free, express edition you.

ios - Some Deprecated UI Objects Causes Memory Leak On iOS8 -

i tried uialertview , uiactionsheet objects causes memory leak in ios8.4 sdk. new objects coming ios8 (such uialertcontroller) supports minimum ios8 os. how can handle leak ios8 , before releases? example code piece causes leak; uialertview *alert = [[uialertview alloc] initwithtitle:@"" message:@"" delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil]; [alert show]; i suggest check class availability. example, if want check whether use uialertcontroller or uialertview then: if ([uialertcontroller class]) { // use uialertcontroller } else { // use uialertview }

javascript - appendChild is not working, firefox on mac -

var xmlns = "http://www.w3.org/2000/svg"; var xlinkns = "http://www.w3.org/1999/xlink"; var arrivedv; var arrivednv; var count = 0; var timerfunction = null; var svgelement = document.getelementbyid("van"); svgelement.addeventlistener("mousedown", mousedown); function mousedown(e) { var x = e.clientx; var y = e.clienty; var coords = "x : " + x + ", y : " + y; document.getelementbyid("mpost").value = coords; addtruck(x, y); } function addtruck(x, y) { var rect = document.createelementns("http://www.w3.org/2000/svg", "rectangle"); rect.setattributens(null, "x", x); rect.setattributens(null, "y", y); rect.setattributens(null, "width", 20); rect.setattributens(null, "height", 20); rect.setattributens(null, "fill", "#800000"); rect.setattributens(null, "stroke", "none...

Oracle APEX default value not working on cascaded items -

i have blank page static content region (template = form region). select project via select list (there 1 project, automatically selects it). have key popup lov (a popup lov displays description not returned number value) select person in project. trying form display person selected , saved when form launches first time (since project chosen due there being one). works when refresh page, doesn't work if log out , log form. tried using default value sql query. tried using dynamic action fires when project changes; neither approaches work. fiddled settings, couldn't work. know how accomplish in oracle apex? i added refresh of cascading popup lov dynamic action. can see hidden input item showing defaulted value, popup lov not display on screen. oracle bug? also in javascript console $s("p51_line_manager1", "7104"); sets hidden value, doesn't display on screen. $v("p51_line_manager1"); does return 7104.

java - Why is String.intern() a native method? -

what's logic behind making method native? what advantage on making interned string pool hash map? it looks little strange, seems it'd pretty easy in non-native code: import java.util.hashmap; public class string { // ... private final static hashmap<string, string> pool = new hashmap<>(); public string intern() { if (pool.containskey(this)) return pool.get(this); synchronized (pool) { if (pool.containskey(this)) return pool.get(this); pool.put(this, this); return this; } } // ... } so why native code then? it seems it'd pretty easy in non-native code ... you're wrong. specification, string.intern() must interact constant pool, meet requirement 'all literal strings interned'. can't done java code.

java - How to count key values in a HashMap -

i writing game , i'm stuck.. we have 2 teams public enum teamtype { team_one, team_two; } private optional<teamtype> team; and hashmap private map<teamtype, player> teamplayers = new hashmap<>(); how count amount of players within team type? (returning numeric value) teamplayers.get(teamtype.zamorak).size(); is not possible. if list of players: private map<teamtype, list<player>> teamplayers = new hashmap<>(); this work: teamplayers.get(teamtype.team_one).size(); of course you'd need initialize empty player list: teamplayers.put(teamtype.team_one, new arraylist<player>()); teamplayers.put(teamtype.team_two, new arraylist<player>()); then add players team: teamplayers.get(teamtype.team_one).add(new player());

angularjs - redirecting a page with angular routing after successfully calling an api on express server -

in single page application using angular routing, how can redirect page after api call. in case, want redirect user profile page after have called login api. thought work isn't. on client, main.js. have angular routing set up app.config(function($routeprovider){ $routeprovider //the home page display .when('/', { templateurl: 'main.html', controller: 'maincontroller' }) .when('/login', { templateurl: 'login.html', controller: 'logincontroller' }) .when('/signup', { templateurl: 'signup.html', controller: 'signupcontroller' }) .when('/profile', { templateurl: 'profile.html', //controller: 'maincontroller' }); }); and controller call /login post api app.controller('authcontroller', function($scope, $http, $rootscope, $location){ $scope.user = {username: '', password: ''}; $scope.error_message = ''; $scope.login =...

android - How can I show ListView item from SlidingTab Fragment? -

this code want show listview item in slidingtab fragment. here sir post single post.xml public class tab1 extends fragment { @override public view oncreateview(layoutinflater inflater, @nullable viewgroup container, @nullable bundle savedinstancestate) { view v =inflater.inflate(r.layout.productlist,container,false); return v; } } this getting listviewitem public class productlist extends listactivity { // progress dialog private progressdialog pdialog; private static final string read_comments_url = "http://192.168.254.101/productlist.php"; private static final string tag_posts = "message"; private static final string tag_brand = "brand"; private static final string tag_category = "category"; private static final string tag_description = "description"; private static final string tag_code = "code"; private static final string tag_quanti...

javascript - json data not load after load page -

this question has answer here: parse json in javascript? [duplicate] 16 answers i have read json data in javascript. json data not display first time page load, load after refresh page. please solve problem. here code: $(document).ready(function () { $.ajax({ url:"http://192.168.0.105/stratagic-json/project_json.php", type:"get", datatype:"json", beforesend: function(){ success:function(jsondata){ var projctlist = ''; (var = 0; < jsondata.length; i++) { projctlist += ' <li><div class="proj-details-wrap"> <img src="images/project-img.jpg" /><div class="proj-badge">upcoming projects</div><div class="proj-name">'+ jsondata[i].name +'<span>'+ jsondata[i].loc...

jquery - How do I get Index of Listview? -

i can correct index of listview using code: $('#listview').on('click', 'li', function() { alert( $(this).index()); }); this returns correct index. however if using code, returns 0: $('#listview').on('click', 'div', function() { alert( $(this).index()); }); i use second code differentiate click event among different divs. the index gives position of element relative siblings in html tree. if div within li , html looks this <ul id="listview"> <li><div>first div click handler</div></li> <li><div>second div click handler</div></li> </ul> then 0 correct index div in listview. maybe need this $(this).closest('li').index(); in click handler.

node.js - How to store json.stringify response into a file? -

currently having problem node.js project doing right now, don't know how can store json.stringify response below code in file can access json data or there better way without storing in file. here code: var watson = require('watson-developer-cloud'); var personality_insights = watson.personality_insights({ username: '...', password: '...', version: 'v2' }); personality_insights.profile({ text: 'i write explain why i’ll holding album, 1989, new streaming service, apple music. feel deserves explanation because apple has been , continue 1 of best partners in selling music , creating ways me connect fans. respect company , ingenious minds have created legacy based on innovation , pushing right boundaries.i’m sure aware apple music offering free 3 month trial signs service. i’m not sure know apple music not paying writers, producers, or artists 3 months. find shocking, disappointing, , unlike historically progressive , genero...

node.js - Make waterline accept async custom validation -

how use async custom validation in waterline ? i tried : module.export = { types: { album : function(albumid) { album.findone(albumid) .then(function(album) { console.log(album !== undefined); // true return album != undefined; }) .catch(function(err) { return false; }); // if return true there, works }, } attributes: { album: { model: 'album', album: true } } } but seems validation rejected because validation function returns before promise successed. tried returning promise doesn't work :p

android - Flurry analytics 5.6.0 not sending events to Flurry servers -

i'm new flurry i've implemented sdk based on official documentation, , seems "working". sessions started correctly , events tracked never ever sent server. missing? a similar issue has been posted here my project configuration follows: googleplayservices version: com.google.android.gms:play-services-gcm:7.5.0 flurry version: flurryanalytics-5.6.0.jar any appreciated. the problem because selectively compiling googleplayservices sdk. adding google cloud messaging (gcm) dependency. need include ads module use flurry. that is, if don't have com.google.android.gms:play-services:7.5.0 (the entire google play services api) in build.gradle, should have @ least com.google.android.gms:play-services-ads:7.5.0 or com.google.android.gms:play-services-analytics:7.5.0 (note addition of ads , analytics @ end), in addition other dependencies. after (and have flurry debug log enabled), should see "analytics report sent" after each new sessi...

vb.net - Using global variable to show value on progress bar -

i making game in visual basic 2010 , have completed except 1 problem have encountered in regards using global variables. have set them in module shown below: module module1 public structure maths public accuracy integer public speed integer public vision integer end structure public mathsprogress maths end module what trying these variables use them within 1 form store values can transfer values second form. this, have created nested if statements should set value of variable mathsprogress.accuracy = x depending on value of 'incorrect'. '''''''''''continued'''''''''''''''''' else : incorrect = incorrect + 1 if incorrect = 0 mathsprogress.accuracy = 10 elseif incorrect < 2 , incorrect > 0 mathsprogress.accuracy = 9 elseif incorrect = 3 mathsprogress.accuracy = 8 ...

Applescript Display Dialog User Input -

i'm running applescript program asking user type in name. if user clicks "ok", name gets stored variable want. however, if user clicks "cancel", program quits. how set either hide "cancel" button, it's not option click, or set loop if cancel clicked, continues ask user his/her name until it's entered? thanks in advance. display dialog "please enter name." default answer " " title "enter name" simple solution display dialog "please enter name." default answer " " title "enter name" buttons {"ok"} default button 1

ruby - Automating Rails workflow? -

when working rails, there way customize results rake commands? for instance, use rake dump task - rake db:dump - gets locally produced database entries. want expand deployed app can run 1 command , have file can reproduce db. how can done? what write bash script commands need dump , deploy. you can create alias runs multiple commands, might closer want do. here's similar question has answers explaining both: how can define bash alias sequence of multiple commands?

android studio - Error:Unable to start the daemon process: -

error:unable start daemon process: not reserve enough space object heap. please assign more memory gradle in project's gradle.properties file. for example, following line, in gradle.properties file, sets maximum java heap size 1,024 mb: org.gradle.jvmargs=-xmx1024m</em> read gradle's configuration guide read java's heap siz try one. add line @ end of application gradle.properties org.gradle.jvmargs=-xmx512m -xx\:maxpermsize\=512m

ios - Error _BSMachError: (os/kern) invalid capability (20) after receiving remote notification on CloudKit record addition -

when receive remote notification on record addition (didreceiveremotenotification called), following error message: _bsmacherror: (os/kern) invalid capability (20) i've tried find out more in forums , via google not find helpful advice applies situation. what error message mean? can it? i experienced error. in uialert action block; when block exited error occurred (btw parent uialertviewcontroller created in dispatch_async block guess off main thread. anyway, wrapped action code in dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{ [self handleactionforelement:thistype]; }); and error went away. mileage may vary!

Compiling a Git submodule with my project in Java -

i have github project in java normal file structure: src/ src/main.java src/com/myproject/myclass.java bin/ and have makefile it; adding git submodule own structure, , within project looks follows: submodule/ submodule/src/ submodule/src/com/project/helperclass.java my question normal practice compile/have multiple projects different directory structures working together? should copy src/com/project/ directory directory structure?

php - creating automatic relations in drupal -

consider scenario. i have 3 nodes a,b,c father of b , b father of c , have created these 2 relations using relations module. implies grandfather of c. can define rules handle such cases automatically in drupal, rather explicitly defining grandfather of c using relations module. use rules module. create rule should fire when relation grandchild created.

python - get text content from p tag -

i trying description text content of each block on page https://twitter.com/search?q=data%20mining&src=typd&vertical=default&f=users . html p tag looks like <p class="profilecard-bio u-dir" dir="ltr" data-aria-label-part=""><a href="http://t.co/kwtdyfn6dc" rel="nofollow" dir="ltr" data-expanded-url="http://dataminingblog.com" class="twitter-timeline-link" target="_blank" title="http://dataminingblog.com"><span class="invisible">http://</span><span class="js-display-url">dataminingblog.com</span><span class="tco-ellipsis"><span class="invisible">&nbsp;</span></span></a> covers current challenges, interviews leading actors , book reviews related data mining, analytics , data science.</p> my code: productdivs = soup.findall('div', attrs={'...

UnicodeEncodeError: 'ascii' exporting csv in pandas python 2.7 -

i've created pandas dataframe in python 2.7 when try export csv function outcome.to_csv("/users/john/out_1.csv") i following error: unicodeencodeerror: 'ascii' codec can't encode character u'\u2019' in position 191: ordinal not in range(128) how can export it? , if can't how go position 191 , remove character? many thanks edit: the dataframe looks like: 0 ca0037381 lsal:g97715947cf ca0037381lsal:g97715947cf 1 ca0037381 lsal:g97717947cf ca0037381lsal:g97717947cf 2 ca0037684 hint:13426cf ca0037684hint:13426cf 3 ca0037679 wave:jla0901brncf ca0037679wave:jla0901brncf 4 ca0037373 hugr:5026134836266cf ca0037373hugr:5026134836266cf 5 ca0037601 wast:wgch23blcf ca0037601wast:wgch23blcf 6 ca0037601 wast:wg19800cf ca0037601wast:wg19800cf 7 ca0037318 endo:albarino ca...

c# xml xpath create attribute if not in document -

how can create attribute if doesn't exist? /document/setup/info/att/group[@name='manu']/osis:attr[@name='time']/@value some of documents have value attribute don't. xml (with time no value attribute): <?xml version="1.0" encoding="utf-8"?> <document xmlns="http://www.ns.com/ns/ns"> <setup> <info> <filepath>\\computer1\project\e2002307\e2002307.drg</filepath> <att> <group class="custom" name="manu" desc="attributes" ord="6"> <attr num="119" name="xyz" desc="zyx" type="s" ord="1" value="s355"> <valid perm="e" max="100"/> </attr> <attr num="120" name="thick" desc="thick." type="r" ord="2" value="5"...

mysql - sql query to calculate percentage -

in table below, need find percentage of males in state 'nyc'. select count(*) table state = 'nyc' , gender = 'male'; gives me count of males nyc. need % of males nyc 75%. +-------+-------+--------+ | name | state | gender | +-------+-------+--------+ | jon | nyc | male | +-------+-------+--------+ | obama | la | male | +-------+-------+--------+ | kat | nyc | male | +-------+-------+--------+ | andy | nyc | male | +-------+-------+--------+ | sri | nyc | female | +-------+-------+--------+ desired output: state, male_percentage--> nyc, 75 % as 3 males , 1 female total 4 nyc. with 1 select table ) select state ,100 * sum( if(gender = 'male',1,0) ) / count(*) table state = 'nyc' group state

android - NDK-build GLuint does not name a type when trying to compile -

so apparently im not sure how include open gl in sdl application i have: if _android_ #include <gles2/gl2.h> #include <gles2/glext.h> but when use gluint gluint not name type my android.mk includes local_ldlibs := -lglesv1_cm -lglesv2 -llog and building android platform 10 (** **) app_platform := android-10 app_abi := armeabi-v7a armeabi x86 so not sure doing wrong (added rest of file having problems:) #pragma once #include <stdlib.h> #include <iostream> #include <random> #include <cassert> #include "vec2.h" #include "vec3.h" #include "vec4.h" #include "mat4.h" #include "transformations.h" #if defined(_msc_ver) #include <windows.h> #include <glew.h> #include <gl\gl.h> #include <gl\glu.h> #include <sdl.h> #include <sdl_ttf.h> #include <sdl_image.h> #include <sdl_mixer.h> #include <sdl_opengl.h> #include <stdio.h...

google cloud endpoints - How to import Sendgrid in android studio -

i use sendgrid send emails google endpoint project, developing in android studio. problem can't find example of how import sendgrid library, tried , other variants: compile 'com.sendgrid:1.0.6' where 1.0.6 latest version? find the answer cfl doesn't work newest version of android studio. using send-grid java dependency clashes various dependencies native android studio. thankfully found forked version made dany santiago. in example, uses user name , password instantiate sendgrid object if have api key, can use instead avoid saving account information on device. add dependencies in build.gradle (app) of android studio project: compile 'com.github.danysantiago:sendgrid-android:1' do not use sendgrid-java android studio, not work. more information, here link https://github.com/danysantiago/sendgrid-android also, don't need use example used in link. if have api key sendgrid, sample code work fine: //might need other imports ...

javascript - Using ng-required with model's value in AngularJS -

i'm trying validate form. in 1 field, have validate null & it's value. how can this? by way, don't write function on controller. <form name="frm"> <input type="text" ng-model="mymodel" ng-required="mymodel != '' || mymodel != undefined || mymodel != 'xxx'" /> <button ng-disabled="frm.$invalid" >send</button> you can't ng-required because checks if value entered or not. in case can use ng-required cover statements: mymodel != '' || mymodel != undefined . , if want check mymodel value isn't 'xxx' should use ng-pattern directive. appropriate regex case should be: /^(xxx.+|(?!xxx).*)$/ . <form name="frm"> <input type="text" ng-model="mymodel" ng-pattern="/^(xxx.+|(?!xxx).*)$/" ng-required="" /> <button ng-disabled="frm.$invalid" >send</button> ...

android - Get and compare EditText background color -

i developing android app have few edittexts. setting background color of edittext dynamically 1 have defined in res/drawable folder. want background color of edittext , compare hex color, e-g if color #ff0000 change text color of edittext white. how setting background color of edittext: allscaleedittexts.get(row_col).setbackgroundresource (r.drawable.edittext_bgcolor_one); that how getting background color of edittext: drawable scaleedtxtcolor = allscaleedittexts.get(row_col) .getbackground(); now want make comparison like: if(scaleedtxtcolor == #ff0000) allscaleedittexts.get(row_col).settextcolor(color.white); else allscaleedittexts.get(row_col).settextcolor(color.black); i don't know how go comparison. have tried this: if(scaleedtxtcolor == color.parsecolor("#ff0000")) but error of comparing drawable int. how can solve it? you can't use if(scaleedtxtcolor == #ff0000) cause ...

Parameterized MySql Query in vb.net Not Passing to DB -

cant seem pass data base assume there issue query appreciated.there no errors given vs , leads me think issue statement, sadly cannot test in navicat because not "true values" tried using parameters params.add(new mysqlparameter("@eventdate", eventdate)) and paramiters this params.add(new mysqlparameter("eventdate", eventdate)) same results both public function parameterizednonquerycommand(byref nonquery string, byval parameters list(of mysqlparameter), _ optional byval connection mysql.data.mysqlclient.mysqlconnection = nothing) integer dim comm new mysql.data.mysqlclient.mysqlcommand(nonquery, connection) try each param mysql.data.mysqlclient.mysqlparameter in parameters comm.parameters.add(param) next if comm.connection.state <> connectionstate.open comm.connection.open() comm.prepare() return comm.executenonquery() catch ex e...

python - how to use two variables in for loop? -

define function calls addfirstandlast(x) takes in list of numbers , returns sum of first , last numbers. examples >>> addfirstandlast([]) 0 >>> addfirstandlast([2, 7, 3]) 5 >>> addfirstandlast([10]) 10 my question can not use 2 variables in loop, should , how fix error. , improved code of problem. def addfirstandlast(x): total = 0 total1 = 0 total2 = 0 pos_last = [] num, last in x: num = str(num) num = num[0] total1 += int(num) last = last % 10 pos_last = pos_last.append(last) total = sum(pos_last) total2 = total+total1 return total2 print addfirstandlast([2, 7, 3]) 3 distinct cases: 1) list empty, 2) list has 1 element, 3) list has 2 or more elements. try without loop: def addfirstandlast(x): if len(x) == 0: return 0 elif len(x) < 2: return x[0] else: return x[0]+x[-1] >>> print addfirstandlast([2, ...

Python BeautifulSoup - How to extract this text -

current python script: import win_unicode_console win_unicode_console.enable() import requests bs4 import beautifulsoup data = ''' <div class="info"> <h1>company title</h1> <p class="type">company type</p> <p class="address"><strong>zip, city</strong></p> <p class="address"><strong>street 123</strong></p> <p style="margin-top:10px;"> phone: <strong>(111) 123-456-78</strong><br /> fax: <strong>(222) 321-654-87</strong><br /> phone: <strong>(333) 87-654-321</strong><br /> fax: <strong>(444) 000-1111-2222</strong><br /> </p> <p style="margin-top:10px;"> e-mail: <a href="mailto:mail@domain.com">mail@domain.com</a><br /> e-mail: <a href="mailto:mail2@domain...

sql - Save fieldname and fieldvalues -

i want save values, field names of table in table. target table:targettable source table:mysourcetable i want run follows: exec fieldvevaluewrite("mysourcetable") create table [dbo].[targettable]( [fieldname] [nchar](50) null, [fieldvalue] [nchar](300) null ) on [primary] output follows: [fieldname] [fieldvalue] name vedat surname pala city tokat counrty tÜrkİye same answer same question: declare @tablename varchar(50) = 'mysourcetable'; declare @columns varchar(4000) = ''; declare @insertvalues varchar(4000) = ''; declare @columnsvar varchar(4000) = ''; declare @sql varchar(max); select @columns = @columns + '[' + column_name + ']' information_schema.columns table_name = @tablename select @insertvalues = @insertvalues + '(''' + column_name + ''',@' + column_name + '),' information_schema.columns table_name = @tablename set @columnsvar = replace(replace(@...

debugging - Visual Studio Watch Window Debugger Displaying Nothing -

i working on application today, , literally of sudden, debugger stopped working. i'm working in visual studio 2013. when debug, set breakpoint, , hit f11 step into, , watch updated results in believe watch window. blank. nothing displays @ all. the program compiles, runs , builds fine, , have literally been on seems quick fix solutions on internet. has else ever had problem? edit: once breakpoint set, can right click variable , add watch debug, isn't convenient. assume reason has decided not add watch default. option somewhere in vs? turns out visual studio had decided not watch in code when debugging. had in end was: start debug, , wait breakpoint. go to: debug -> windows -> autos and returned!

Audio is not in sync with images using Viewpager -

i creating simple android app. used code images , sound etc works fine audio not in pattern(sync) according images. according sound image 1 step next means example ant bee sound plays , want play ant sound ant , bee fee using same array index of images , audios nothing works. here code mainactivity.java package com.example.zeeshanm.ibrahim; import android.media.mediaplayer; import android.os.bundle; import android.app.activity; import android.content.context; import android.support.v4.view.pageradapter; import android.support.v4.view.viewpager; import android.util.log; import android.view.view; import android.view.viewgroup; import android.widget.imageview; import android.widget.toast; public class mainactivity extends activity { public mediaplayer mp; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); viewpager viewpager = (viewpager)findviewbyid...