Posts

Showing posts from February, 2014

mysql - Convert SQL query to Rails ActiveRecord query -

i have sql query multiple left joins works fine: query = <<-eos select date(t.completed_at) completed_date, s.id district, assignee_id, u.first_name, u.last_name, count(t.id) completed_tasks tasks t left join tickets k on k.id = t.ticket_id left join installations on i.id = k.installation_id left join administrative_areas on i.ward_id = a.id left join service_areas s on s.id = a.service_district_id left join users u on u.id = t.assignee_id 1 = 1 , s.id = '#{district_id}' , t.status = '#{status}' , t.kind = 1 , t.completed_at >= '#{days_ago.days.ago.beginning_of_day.to_s(:db)}' , t.completed_at <= '#{days_until.days.ago.beginning_of_day.to_s(:db)}' group date(t.completed_at), s.id, s.name, u.first_name, u.last_name, t.assignee_id eos i got value after mapping: [{:completed_date=>"2015-07-11", :district=>"1339", :assignee

java - Can I invoke some method from XML mapping file in Hibernate? -

i have xml mapping file. can invoke method it? idea: <?xml version="1.0" encoding="utf-8"?> <!doctype hibernate-mapping public "-//hibernate/hibernate mapping dtd 3.0//en" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="pkg.someitem" table="item"> <id name="itemid" column="itemid" unsaved-value="0"> <generator class="increment"/> </id> <property name="filesize" invoke="myfilemanager.getactualfilesize(itemid);"/> </class> </hibernate-mapping> use reflection : // xml parsing code incorrect; illustration purposes string classname = xml.getelement("class").getattribute("name").getvalue(); string methodname = xml.getattribute("invoke").getvalue(); // generic insta

ios - How can I process multiple links of JSON data? -

the code works perfectly. problem that, after trying while, cannot figure out how make program process second link of different json data. here viewdidload goes on: override func viewdidload() { super.viewdidload() var err: nserror? let urlpath: string = "https://na.api.pvp.net/api/lol/na/v1.4/summoner/by-name/" + searchfielddatapassed + "?api_key=(removed private api key obvious reasons" var url: nsurl = nsurl(string: urlpath)! let session = nsurlsession.sharedsession() let task = session.datataskwithurl(url) { data, response, error in // cast response nshttpurlresponse , switch on statuscode if if let httpresponse = response as? nshttpurlresponse { switch httpresponse.statuscode { case 200..<300: println("ok") default: println("not ok") } } // parse json using nsjsonserialization if you've got data if let jsonresult = nsjsonserializatio

php - pulling mysql data for timelinejs? -

i'm trying pull data mysql database create json file use timelinejs timeline. problem json file must formatted way. i've created following code formats json correctly, pulling 1 entry database (specifically last entry). guys offer appreciated! <?php $link = mysql_pconnect("localhost", "root", "********") or die("could not connect"); mysql_select_db("php_test") or die("could not select database"); $rs = mysql_query("select * timelinetest"); while($row = mysql_fetch_array($rs, mysql_assoc)) $object = array ('timeline'=> array( 'headline'=>'georgia history title page', 'type'=>'default', 'text'=> 'testing overview', 'startdate'=>'1700', 'asset'=>array('media'=>'titlepagemedia', 'credit'=>'titlepagecredit', &

c# - WCF certificate authentication -

while implementiong wcf security using certificate, facing below mentioned error. secure channel cannot opened because security negotiation remote endpoint has failed. may due absent or incorrectly specified endpointidentity in endpointaddress used create channel. i have put certificates in trusted people. it looks identity problem , have tried setting identity both in service , client config still didn't work. below configuration details. service configuration <bindings> <wshttpbinding> <binding name="wshttp"> <security mode="message"> <message clientcredentialtype="certificate" /> </security> </binding> </wshttpbinding> </bindings> <service name="wcfcertificateauth.service1"> <endpoint address="" binding="wshttpbinding" bindingconfiguration="" bindingn

php - How to get user id in session? -

kinda noob problem i'm working on 2 hours , can't solve i have login system works fine (thanks tutorials), i'd save id in session when user's logging this login.php: <?php session_start(); require_once 'config.php'; if(isset($_post['btn-login'])){ $uname = $_post['txt_uname_email']; $umail = $_post['txt_uname_email']; $upass = $_post['txt_password']; $sth = $bdd->prepare("select user_id users user_name=$uname"); $sth->execute(); $result = $sth->fetch(pdo::fetch_assoc); $uid = $result; if($user->login($uname,$umail,$upass)){ $_session['user_name'] = $uname; $_session['user_mail'] = $umail; $_session['user_session'] = $userrow['user_id']; $_session['user_id'] = $uid; $uname = $_post['txt_uname_email']; $umail = $_post['txt_uname_email']; $upass = $_p

Best way to render two dimensional table in grails -

i need table displayed , headings, have 2 lists: list1 = [a, b, c, d, e, f, g] and list2 list of maps list2 = [ [from: a, to: a, val:20], [from: a, to: b, val:10], [from: a, to: c, val:30], [from: b, to: a, val:10], [from: b, to: b, val:40] ] the result should be from b c d e f g 20 10 30 - - - - b 10 40 - - - - - c - - - - - - - d - - - - - - - e - - - - - - - f - - - - - - - g - - - - - - - how can that? <table> <tr> <th>from</th> <th>to</th> <g:each in="${list1}" var="item"> <th>${item}</th> </g:each> </tr> <g:each in="${list1}" var="fromitem"> <tr> <td>${fromitem}</td> <td></td> <g:each in="${list1}" var

bash - Replace a variable with text (sed) -

i have find specific text in file , replace text new text. the contents of file are: host=100 servers=4 clients=70 i have tried this: var=$(grep "servers=" /path/to/file) sed -i "s/${var}/servers=5/g" /path/to/file but gives me error: sed: -e expression #1, char 2: unterminated `s' command note: want update value of each of variable i.e. servers=4 should replaced servers=5. please me figure out solution. thanks. the output of grep ends newline character. sed expects whole command on 1 line or escaping line breaks. however, can achieve complete task sed only: sed -i 's/^servers=[0-9]*$/servers=5/' /path/to/file

ExtJS 4: How can I get all grid columns in current order? -

when use grid.columns returns columns grid (visible or not), it's not in current order.. then tried grid.getview().getgridcolumns() , returned columns in current order, visible ones. how can columns, visible , not visible, in current order? you can try grid.down('headercontainer').getgridcolumns(); returns visible , non-visible columns grid.down('headercontainer').getvisiblegridcolumns(); returns visible columns

javascript - How to add "slow effect" to my slide menu when slide out from left? -

$(document).ready(function() { $('.slideout-menu-toggle').on('click', function(event) { event.preventdefault(); // create menu variables var slideoutmenu = $('.slideout-menu'); var slideoutmenuwidth = $('.slideout-menu').width(); // toggle open class slideoutmenu.toggleclass("open"); // slide menu if (slideoutmenu.hasclass("open")) { slideoutmenu.animate({ left: "0px" }); } else { slideoutmenu.animate({ left: -slideoutmenuwidth }, 250); } }); }); $(document).ready(function() { $('.slideout-menu li').click(function() { $(this).children('.mobile-sub-menu').toggle("slow"); }); }); .slideout-menu { position: absolute; top: 100px; left: 0px; width: 100%; height: 100%;

python - Merging DataFrames on multiple conditions - not specifically on equal values -

firstly, sorry if bit lengthy, wanted describe have having problems , have tried already. i trying join (merge) 2 dataframe objects on multiple conditions. know how if conditions met 'equals' operators, however, need make use of less , more than. the dataframes represent genetic information: 1 list of mutations in genome (referred snps) , other provides information on locations of genes on human genome. performing df.head() on these returns following: snp dataframe (snp_df): chromosome snp bp 0 1 rs3094315 752566 1 1 rs3131972 752721 2 1 rs2073814 753474 3 1 rs3115859 754503 4 1 rs3131956 758144 this shows snp reference id , locations. 'bp' stands 'base-pair' position. gene dataframe (gene_df): chromosome chr_start chr_stop feature_id 0 1 10954 11507 geneid:100506145 1 1 12190 13639 geneid:100652771 2 1 1

vba - DLL "'-t" gives Run-time error 424: Object Required -

i using simple timer tells me time elapsed between performing same calculation different data types. when run error: run-time error '424': object required the troublesome line: target_sheet.range("a2").value = -t here of code: public declare function gettickcount lib "kernel32.dll" () long sub function1_var_randnumcounter() dim var_randnum_x, var_randnum_y, count variant count = 1 count = 1000000 var_randnum_x = rnd(now) ' rnd vals based on now, built-in vba property var_randnum_y = rnd(now) next count target_sheet.range("a2").value = -t ' msgbox gettickcount - t, , "milliseconds" call function1_dec_randnumcounter end sub sub function1_dec_randnumcounter() dim count, var_randnum_x, dec_randnum_x, var_randnum_y, dec_randnum_y dec_randnum_x = cdec(var_randnum_x) dec_randnum_y = cdec(var_randnum_y) ' convert these vals decimals count = 1 count = 1000000 dec_randnum_x = rnd(now) '

Boolean column(Check box) cell in Infragistics UltraGrid should be disabled based on a condition in InitializeRow event -

in infragistics ultra grid have disable boolean (check box) cell based on condition in initialize row event ps: don't want entire column disabled. cell should disabled (cell contains check box should disabled). i kept code below e.row.activation = activation.noedit this code disabling cells in ultra grid row. boolean checkbox present in cell not getting disabled. try like: private void ultragrid1_initializerow(object sender, infragistics.win.ultrawingrid.initializeroweventargs e) { // deactivate boolean in cell 0 //ultragrid1.displaylayout.bands[0].columns[0].cellactivation = // infragistics.win.ultrawingrid.activation.disabled; e.row.cells[0].activation = infragistics.win.ultrawingrid.activation.disabled; } other choices available beside disabled are: activateonly , allowedit , , noedit you can come , activate it.

php - Session in codeigniter not working well -

i can't figure out what's actual error session in codeigniter. other project working code. in case, got problem. for login session code is: $data = array( 'username' => $this->input->post('username'), 'admin_logged_in' => true, 'logged_in' =>true ); $this->session->set_userdata($data); and check session as: if ($this->session->userdata('admin_logged_in') == true) { // code } before going controller checking session above , if session not true redirecting login page. for logout: function logout() { if ($this->session->userdata('admin_logged_in') == true) { $useremail = $this->session->userdata('username'); $data = array( 'username' => $useremail, 'admin_logged_in' => true, 'logged_in' =>tr

html - CSS applied to asp:Label under placeholder1 only working in design view? -

all other parts of css work fine in browser. part works in design view. tried adding cssclass , clearing cache , running on ie, chrome , firefox. nothing seems work. <asp:label id="lblwelcometext" runat="server" text="welcome" cssclass="welcome"> .welcome{ display: inline-block; text-align:center; /*border-bottom: 5px solid #f0f1e7;*/ color: #ffe9da; font-family: sans-serif; font-size: 68px; font-weight: normal; /*line-height: 48px; margin: 0 0 26px; padding: 0 0 24px;*/ } make sure closed </asp:label> tag. check rendered html code using inspect element tool of browser, markup must : <span id="lblwelcometext" class="welcome">welcome</span> when inspect element using tool can check css applied element. can install firebug firefox browser inspect element. please update problem detail.

How can I place a folder in a specific location using javafx-ant with Maven? -

i have upgraded build plain ant maven manage dependencies. 1 of third party jars needs supporting file placed in specific location. i have managed create simple pom.xml compile application , generate exe installer. unable place file in specific folder location. when application build & deployed should placed in location: ${project.build.directory}/deploy/bundles/myapplication/app/{custom-folder}/*.properties this want correctly bundled in installer - unable find way specify specific location specific file. following pattern (only showing relative pieces of pom): <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-antrun-plugin</artifactid> <version>1.6</version> <executions> <execution> <phase>package</phase> <configuration> <target> <taskdef name="jfxdeploy" classname="com.sun.javafx.tools.ant.deployfxtask" classpathref="maven.plugin.classpath" />

vector graphics - What are binormals used for? -

i know binormal orthogonal both surface normal , tangent in point on plane used exactly? there lot of uses, more can covered in simple answer. one of common usage in shaders. normal, tangent , binormal can used navigate in surface space. can used create matrix lets transform vector model space surface space or texture space. in turn used lot of different shader effects, e.g. advanced lighting or effects parallax mapping.

ios - Defining a new interface causes "Undefined symbols for architecture x86_64:". Existing interfaces work fine -

i have ios app , using xcode version 6.3.1 (6d1002). have m file in define @interface customobject:nsobject {} @end and try use in viewdidload as customobject* obj = [[customobject alloc]init]; when run this, linkage errors saying undefined symbols architecture x86_64: "_objc_class_$_customobject", referenced from: objc-class-ref in choosealbumviewcontroller.o ld: symbol(s) not found architecture x86_64 i have similar interfaces defined other objects , continue build, link , run fine. new interfaces i'm defining failing these linkage errors. use figure out what's causing this. i'm new ios development if i'm missing information crucial figure out please let me know , i'll add it. few flags build settings might - build active architecture = yes architectures = standard architecture armv7 armv64 valid architectures = arm64 armv7 armv7s here code in define interface , try use it @interface customalbum : nsobject {

R tolower function -

how convert data frame lower case if use tolower(df) , workspace crashes.x ps: df has around 400000 rows , 4 columns , need text inside df in lowercase try: x<- apply(x,2,tolower) this works smaller dataframes. might have chunk yours , rebind them many rows though.

how fetch kml google earth api -

my fetch kml not work. here code: function initcallback(object) { ge = object; ge.getwindow().setvisibility(true); function finished(object) { if (!object) { settimeout(function() { alert('bad or null kml.'); }, 0); return; } ge.getfeatures().appendchild(object); } var url = 'http://localhost/ta/bangun.aula.kml'; google.earth.fetchkml(ge, url, finished); document.getelementbyid('installed-plugin-version').innerhtml = ge.getpluginversion().tostring(); } kml file not directly parsed js in browser. google needs access kml file. need place kml file google can access (host online). since kml file on localhost , google not able access it.

python - Plotting with lines connecting points -

Image
i'm creating program determine minimum, maximum, , percentiles of winds @ heights. file split 5 columns. code far looks this: import matplotlib.pyplot plt f = open('wind.txt', 'r') line in f.readlines(): line = line.strip() columns = line.split() z = columns[0] u_min = columns[1] u_10 = columns[2] u_max = columns[4] u_90 = columns[3] plt.plot(u_min,z,'-o') plt.plot(u_max,z,'-o') plt.show() as can see it's plotting each min , max @ specific altitude dot. how can adjust makes line instead. edited answer due comment to create line connects min values: store min values in list (using append) plot list the code: import matplotlib.pyplot plt f = open('wind.txt', 'r') min_vector = [] max_vector = [] z_vector = [] line in f.readlines(): line = line.strip() columns = line.split() z = columns[0] u_min = columns[1] u_10 = columns[2] u_max = columns[

Is there a way to initialise an array using an expression/function in R -

is there easy way initialise array using function based on indexes of each cell within array? for example if wanted create array values equal i+j+k such (for example): > a[1,2,3] 6 > a[4,8,9] 21 i'd along lines of: a <- array( i+j+k , dim=c(10,10,10) , dimnames=list(i,j,k) ) do first need create array of size want, , apply function array (ie two-stage process)? or there way initilize values @ same time creating matrix? nested outer calls seem trick (here 3 visibility): outer(outer(1:3,1:3,"+"),1:3,"+") or duplicate example: > a=outer(outer(1:10,1:10,"+"),1:10,"+") > a[1,2,3] [1] 6 > a[4,8,9] [1] 21

java - FreeMarker : Displaying a custom 404 page without redirection -

i have static 404 page fancy stuff in it. in case user enters wrong url of page not exist, him see 404 page , keep url in order user see mistake s/he has done typing url . the page entered , not exist : http://localhost:10039/my.website/my/halp.html the 404 page : http://localhost:10039/my.website/my/notfound.html briefly, instead of using "sendredirect" here, "get content" of pagenotfoundurl , show while url still http://localhost:10039/my.website/my/halp.html instead of redirect, tried "forward" kayaman suggested in case " cannot forward. response committed." testservlet defined in web.xml , , class extends utilfreemarkerservlet extends freemarkerservlet. utilfreemarkerservlet public abstract class utilfreemarkerservlet extends freemarkerservlet { private static final long serialversionuid = 1l; public static final string request_object_name = "requestobject"; private logger logger = loggerfactor

excel - R1C1 Formula: Using Row counter for R[ ] -

im trying use row counter make range countif. giving me error every time run , suspect syntax error. thoughts? dim nrows integer 'row counter nrows = range(range("b4"), range("b4").end(xldown)).rows.count range("y5").select activecell.formular1c1 = _ "=if(countif("r5c5:r" & nrows & "c5",rc[-20])>=2,""duplicate account combination"","""")" range("y5").select selection.autofill destination:=range("y5:y" & nrows) i believe issue @ "=if(countif("r5c5:r" & nrows & "c5",rc[-20])>=2," part of code. the problem having in fact in line suspected was. problem escaping string @ wrong time. need change quotation marks such: activecell.formular1c1 = _ "=if(countif(r5c5:r" & nrows & "c5,rc[-20])>=2,""duplicate account combination"","""&quo

html - send attachments and data in form in an email with php -

this php code and html form below want data name , email, phone number fields , file attachment. now tried file attached ( without other information entered) in live server environment getting , attachment in mail different format (like have send word doc word file in dat format doesn't display data in word file) <?php if(isset($_post['submit'])) { //the form has been submitted, prep nice thank message $output = '<h1>thanks file , message!</h1>'; //set form flag no display (cheap way!) $flags = 'style="display:none;"'; //deal email $to = 'xxxx@gmail.com'; $subject = 'details , file attachments '; $message = strip_tags($_post['message']); $attachment = (file_get_contents($_files['file']['tmp_name'])); $filename = $_files['file']['name']; $boundary =md5(date('r'

javascript - How to get a Spring Security's token username on the client side from JSESSIONID cookie? -

is username specify while creating springs's authenticationtoken on server in way stored on client side? somehow stored in jsessionid cookie or in other way or server-side entity binded container sessions? want retrieve username js script in page display username , etc... possible way? other alternatives? thx. take on savedrequestawareauthenticationsuccesshandler, can add cookie on method. can see flow here http://docs.spring.io/spring-security/site/docs/3.0.x/reference/core-web-filters.html#form-login-flow-handling .

javascript - How to show a single combination from matrix of values and hide others -

edit: edited question, because classes index based, in real scenario not.. lets have markup, more or less <div class="container"> <div class="room_special"> <div class="aaaa"></div> <div class="bbbb"></div> <div class="cccc"></div> </div> <div class="room_junior"> <div class="xyz"></div> <div class="ztx"></div> <div class="tda"></div> </div> <div class="room3"> <div class="xxxx"></div> <div class="board3"></div> <div class="zzzzz"></div> </div> </div> and want make visible (the rest, hidden) room2 - board 3, , change when user clicks on elements (not those..) and have 2 vars, wich read user

c# - WPF Application Has Lost Windows 8 Style And Reverted to a XP Like Look -

for no reason can think of - there have been no code changes, wpf application has stopped showing window frame in windows 8 style , seems have reverted windows xp style (weird grey border around main window , grey, raised buttons minimize,maximize , close in top right corner. if try , resize window can see win8 style buttons trying draw "underneath" before grey button style draws on it. (that's best can describe it) does know why might happening?

angularjs - How can I test a directive for a load event? -

so, made simple directive angular .module('cherrytech.common', []) .directive('ctonload', function() { return { restrict: 'a', scope: { callback: '&ctonload' }, link: function(scope, element) { element.on('load', function(event) { scope.callback({ event: event }); }); } }; }); and works fine, no issues @ all. callback called event object when element has finished loading. i'm using iframes, should work on element supports load event. but wanted test it. i'm using testem default configuration, , i'm trying simple test code, can't work: describe('directive: ctonload', function() { var element, scope; beforeeach(module('cherrytech.common')); beforeeach(inject(function($rootscope, $compile) { scope = $rootscope; element

git mirroring to GitHub and filtering private files -

currently working on project. want open-source our day-to-day commits full info (author, etc...) while filtering out specific private folders. let's commit a/file1 , b/file2 in branch master, have mirrored on github b folder filtered (this commit have a/file1). one way thinking remote update hook that: list new commits added newref (let's lastfoundcommit..newref) amend commits 1 one (from lastfoundcommit newref) remove unwanted files in process, might create local master-filtered branch (if helps have locally) push branch public repository somehow keep mapping of commit id between private , public commits, compute "lastfoundcommit" on next push ideally go both way (i.e., nice if import github branches , pull requests , have them "rebased" on top of our private repository, either automatically or simple process -- not hard rebase). this similar git-subtree can do, except not extract subdir filter various files instead. does seem feasible

java - Android Studio - Unrecognized VM option 'MaxPermSize=256m' -

i installed android studio on elementary os 0.3 freya , run using terminal. on first start-up, however, there's error message shown: gradle 'test' project refresh failed unable start daemon process. problem might caused incorrect configuration of daemon. example, unrecognized jvm option used. please refer user guide chapter on daemon @ http://gradle.org/docs/2.2.1/userguide/gradle_daemon.html please read following process output find out more: unrecognized vm option 'maxpermsize=256m' error: not create java virtual machine. error: fatal exception has occurred. program exit. i read this , tried ways solve no avail. did notice error different mine , thought might why couldn't solve problem using ways suggested. as executed .sh file on terminal, printed: java hotspot(tm) server vm warning: ignoring option maxpermsize=250m; support removed in 8.0 (java:5094): gtk-warning **: unable locate theme engine in module_

ios - parameters' label in a function -

i learning swift , in apple's tutorial, has following code snippet when introducing function : func greet(name: string, lunch: string) -> string { return "hello \(name), eat \(lunch)." } //why here 'lunch' cannot removed? greet("bob", lunch: "tuesday") the code defined greet(string, string) function, when calls function: greet("bob", lunch: "tuesday") the 1st parameter doesn't have label 'name', 2nd 1 has label 'lunch', if remove label 'lunch', compiler error says " missing argument label lunch in call " why 1st parameter without label, not 2nd one? clarity the main reason clarity. in swift's function naming style, method name implies first argument, not later arguments. for example: nsnotificationcenter.defaultcenter().addobserver(self, selector: "dosomething", name: uiscreenbrightnessdidchangenotification, object: nil) self impl

regex - Perl Removing New Line -

i cant seem remove new line output executing command on linux server , have tried several different ways heres code 1st try $location = `curl -m 5 -si 216.58.219.206 | grep "location:"`; chomp ($location); print "before\n"; print "$location"; print "after\n"; output, doesnt work, gets printed new line. before location: http://www.google.com/ after 2nd try $location = `curl -m 5 -si 216.58.219.206 | grep "location:"`; $location =~ s/\n//g; print "before\n"; print "$location"; print "after\n"; output, still doesn't work. before location: http://www.google.com/ after raw shell output [user@localhost dir]# curl -m 5 -si 216.58.219.206 | grep "location:" location: http://www.google.com/ [user@localhost dir]# doesnt work either, still see new line. missing something? the curl response coming \r\n instead of \n . use od (octal-dump) see ( -c means show characte

Java validation API: skip some rules without changing bean definition -

i have object in api jar, cannot change: public class user { @notnull private string name; @notnull private string password; } in code need use object , validate data inside, but, example, let password empty. cannot remove @notnull class (and cannot define groups given constraint). how can influence validation without redefinig scratch? one possible solution override constraint definition of specific class using either constraint-mapping xml file or hibernate validator specific api. as described in documentation, can overide specific annotations (like password field annotation) , leave others untouched. <constraint-mappings ...> <bean class="user" ignore-annotations="false"> <field name="password" ignore-annotations="true"> ... new annotations </field> </bean> </constraint-mappings> further reading: http://docs.jboss.org/hibernate/validator/5.1/ref

can I add a function to this jquery? -

probably simple 1 cannot working, want add simple fade in appearing text triggered jquery (with great mr. rao): $('.col').on('mouseover',function() { $('.grafischewerktekst').text($(this).attr('data-desc')) }); i guess need : function(){ $(this).fadein('slow'); } but how , fit correctly have not figured out yet? demo if following html , css given, can change jquery code follows. html <a href="#" class="col" data-desc="description">link</a> <div class="grafischewerktekst">some div</div> css .grafischewerktekst { display:none } jquery $('.col').on('mouseover',function() { $('.grafischewerktekst').text($(this).attr('data-desc')).fadein("slow"); });

c - Assigning a string to a pointer in a struct -

#include <stdio.h> #include <stdlib.h> #include <string.h> struct person { char *forename; char *surname; int age; }; void change_struct(struct person *person, char *forename, char *surname, int age); void print_struct(struct person *person); int main(void) { struct person person1; person1.forename = malloc((strlen("max") + 1) * sizeof(char)); if (!person1.forename) { exit(exit_failure); } strcpy(person1.forename, "max"); person1.surname = malloc((strlen("mustermann") + 1) * sizeof(char)); if (!person1.surname) { exit(exit_failure); } strcpy(person1.surname, "mustermann"); person1.age = 35; print_struct(&person1); change_struct(&person1, "hans", "bauer", 45); print_struct(&person1); free(person1.forename);

excel - mismatch error for sheetname -

i wondering why keep facing mismatch error if (sheets(newsheetname).rows(l).cells(1, 2).value = product) then the code trying figure out , match cells , loop across different worksheets. see below code : dim range1, range2 range 'define variables dim referencesheetcols integer dim range1rows, range1cols, range2rows, range2cols, testrows, testcols, i, j, p long dim bmatches, rowmatched boolean dim product string product = "producta" newsheetcols = 2123 referencesheetcols = 2123 ' how many rows , columns should compare? testrows = 1 testcols = 7 p = sheets(referencesheetname).usedrange.rows.count l = 7 newsheetcols 'only test if correct product **if (sheets(newsheetname).rows(l).cells(1, 2).value = product) then** rowmatched = false k = 7 referencesheetcols 'bmatch = false set range1 = sheets(referencesheetname).row

ios - Delegate Call back method returns variable slow which causes variable nil while accessing from another class? -

in app delegate class, trying retrieve user current location class using delegate. retreived user curren location used in many parts of application.so ,i have set here in appdelegate class @uiapplicationmain class appdelegate: uiresponder, uiapplicationdelegate { var window: uiwindow? var helperlocation:helperlocationmanager? var currentlocation:cllocation? func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject: anyobject]?) -> bool { //get current location , set other screens can use self.helperlocation = helperlocationmanager() self.helperlocation?.delegate = self return true } } extension appdelegate: sendlocationdelegate{ func sendcoordinates(loccoordinate:cllocation, placemark:clplacemark){ currentlocation = loccoordinate } } and seems helperlocationmanager class protocol sendlocationdelegate{ func sendcoordinates(coordinates:cll

sqlite - Can't retrieve str from mySqlite3 -

im trying retrieve latest versions of audit questions stored in table t3 of hs_audit.sqlite. have tried multiple versions of cur.exectute line keep getting result = none. i'm new sqlite can me correct syntax. if execute cur.execute line follows cur.execute("select hvq1 t3 audit_ver = 1") and remove con.text_factory = str it works think problem must use of variables in sqlite command. max_audit_ver = 1 audit_questions = ["hvq1", "hvq2", "hvq3", "hvq4", "hvq5"] count = 0 quest in audit_questions: con = sqlite3.connect("hs_audit.sqlite") con.text_factory = str cur = con.cursor() cur.execute("select '%s' t3 audit_ver = '%s'" % (quest, max_audit_version)) result = cur.fetchone() con.close() print "question =%s" % (quest) print "audit version =%s"

Eureka Client and spring integration -

i trying make spring application discovery client. moment add following dependency <dependency> <groupid>com.netflix.eureka</groupid> <artifactid>eureka-client</artifactid> <version>1.1.37</version> </dependency> the gwt webapp fails launch 503 service unavailable. can netflix eureka used spring boot or spring cloud applications? resolved: the version using old. updated version 1.1.159 , working fine.

How to fix The following classes could not be instantiated in android -

i creating application consists of search widget on action bar downloaded here , had placed in layout.xml showing error on xml called the following classes not instantiated:the following classes not instantiated: - com.milan.searchmenu.persistentsearch.searchbox (open class, show error log) see error log (window > show view) more details. tip: use view.isineditmode() in custom views skip code when shown in eclipse java.lang.nullpointerexception running application run time null pointer exception occurs can 1 tell me how fix this: activity: protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.manual); actionbar actionbar; actionbar = getactionbar(); search = (searchbox) findviewbyid(r.id.searchbox); search.enablevoicerecognition(this); for(int x = 0; x < 10; x++){ com.milan.searchmenu.persistentsearch.searchresult option = new searchresult(&q

ember.js - Is there any way to create a batch of multiple records with a single POST request in Ember Data? -

var batch = [somerecord, somerecord, somerecord...] batch.invoke('save'); if have array of 50 newly created records , invoke save on array, ember data make 50 post requests. rather bulk them single request , handle on api performance. there way this? right appears have implement manually ajax. if there better way, please share. there used bulkcommit feature in ember-data on restadapter, removed. as workaround today, way can think of sending multiple records server @ same time create custom adapter knows how serialize multiple records include of records want serialize in hasmany relationship on model. https://github.com/emberjs/data/issues/2845 so no, you'll need implement own solution in own adapter (or straight make ajax call wherever if you're feeling naughty).

actionscript 3 - Does Flash have a method that does the reverse of toString? -

when using objectutil there method called, tostring() takes object. if pass class named, "person" return string "[class person]". var person:person = new person(); trace(objectutil.tostring(person));//update i'm not using objectutil.tostring() // traces [class person] is there toobject() method? takes same format tostring outputs , creates instance so: var person:person = objectutil.toobject("[class person]"); update : sorry. incorrect. thought using objectutil.tostring(). not. when use method returns like: (com.printui.assets.skins::fontlist)#0 accessibilitydescription = "" accessibilityenabled = true accessibilityimplementation = (null) in code somewhere returning "[class person]" described. line: var currentvalue:* = target[property]; popupvalueinput.text = currentvalue; i thought using instance.tostring() tostring() not returning close that: var f:fontlist = new fontlist(); var f1:fontlist = new fon

cookies - PHP setcookie with small timeout value not working? -

setcookie('cdate', date('ymd'), time() + 120); setcookie('cdate', date('ymd'), time() + 82500); i trying set cookie 2 minutes expired time. strangely, no cookie set no. 1 no. 2 working. view cookie in chrome , firefox. idea? btw, running php + iis in windows 7 locally. please check server time (it must same computer time): var_dump(date('h:i:s')) . if not same computer time, can change timezone on server.

django - __unicode__(self) for python3 and Django1.8 not working -

Image
use python3 , django1.8 admin.py manage db: class employee(models.model): name = models.charfield(max_length=20) sex = models.charfield(max_length=1,choices=sex_choices) def __unicode__(self): return self.name i want return object's name,so use __unicode__(self) return self.name but result: it's show object ,not name!!!! what should do?? i believe, in python 3 django need define __str__() instead of __unicode__(). i found information in section "__str__() , __unicode__() methods" here .