Posts

Showing posts from August, 2014

javascript - jquery how to toggle this specific animation? -

so want toggle animation in jquery found hard find way. $( "#console" ).animate({height: "20px"}); you can set height of element in variable , use animate. need save toggle state having animation without bug. var firstheight = $("div").height(); $("div").click(function(){ $(this).stop(); if (!$(this).data("animatetoggle")) $("div").data("animatetoggle", 1).animate({height: "200px"}); else $("div").removedata("animatetoggle").animate({height: firstheight}); }); div { width: 100px; height: 100px; background: green; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div></div>

javascript - sapui5 - Two master pages -

i've got 2 master pages dynamic lists. master page 1: <page title="title" showbackbutton="true" id="master1"> <list id="idlistauctions" mode="singleselectmaster" select="onpressgotomaster2" items="{auctions>/auctionsglobal/0/auctionstypes}"> <items> <standardlistitem title="{auctions>auctiontype}" type="navigation" /> </items> </list> </page> master page 2: <list id="idlistauctionsdetail" mode="singleselectmaster" select="handlelistselect" items="{auctiontypes/auctions}"> <items> <standardlistitem> <!-- output items master page 1 --> </standardlistitem> </items> </list> my javascript: onpressgotomaster2 : function(oevent) { console.log( oevent.getparameter("lis...

swift - Cannot call value of non-function type UIAlertAction -

i'm not sure what's wrong function. i'm trying present alert asking if user delete selected photo. if function deletes photo returns error, show error user. xcode failing on errorcontroller.addaction line message "cannot call value of non-function type uialertaction" i'm using swift 2 @ibaction func deletephoto(sender: anyobject) { let alertcontroller = uialertcontroller(title: "delete photo", message: "are sure want delete photo?", preferredstyle: .alert) let okaction = uialertaction(title: "ok", style: .default) { uialertaction in self.photogateway!.delete(self.photo!.id!, completion: { (witherror: bool) -> void in if (witherror == true) { let errorcontroller = uialertcontroller(title: "delete failed", message: "blah", preferredstyle: uialertcontrollerstyle.alert) // next line causing error errorcontroller.addaction...

java - Encrypting a byte [ ] using a AES 256 Session key -

i have session key changing every execution of program. have encrypt byte[ ] using session key (aes 256) how that. i generating key key key; securerandom rand = new securerandom(); keygenerator generator = keygenerator.getinstance("aes"); generator.init(rand); generator.init(256); key = generator.generatekey(); and using encrypt byte array public static byte[] encrypt(byte[] a,key skey) throws exception { // instantiate cipher cipher cipher = cipher.getinstance("aes"); cipher.init(cipher.encrypt_mode, skey); byte[] encrypted =cipher.dofinal(a); cipher.init(cipher.decrypt_mode, skey); byte[] original = cipher.dofinal(encrypted); string originalstring = new string(original); return encrypted; } but every time run program shows , error exception in thread "main" java.security.invalidkeyexception: illegal key size or default paramet...

How to close Object Spy of HP UFT(12.02) using vbscript -

we using uft automation testing , have our own framework invoke uft , load scripts. if chance object spy open uft gives error " program waiting user.." can 1 close object spy ( if open) using vb scripts commands object spy part of uft.exe process - maybe use wmi query check if exists before invoke , kill if so? option explicit dim objwmiservice, objprocess, colprocess dim strcomputer, strprocesskill strcomputer = "." strprocesskill = "'uft.exe'" set objwmiservice = getobject("winmgmts:{impersonationlevel=impersonate}!\\" & strcomputer & "\root\cimv2") set colprocess = objwmiservice.execquery("select * win32_process name = " & strprocesskill ) each objprocess in colprocess objprocess.terminate() next wscript.echo "just killed process " & strprocesskill & " on " & strcomputer or saying open uft programmatically , object spy opening on own somehow? ...

android.R.attr.colorPrimary gives me the wrong colors all the time -

i'm trying give buttons colors current themes attributes: android.r.attr.colorprimary or r.attr.colorprimary should return yellow, gives me blue color time instead! have set theme in manifest. setting example backgroundcolor of toolbar android:background="?attr/colorprimary" gives correct color, not if set code. this how i'm trying set color of button: typedvalue typedvalue = new typedvalue(); app.getappcontex().gettheme().resolveattribute(android.r.attr.colorprimary, typedvalue, true); buttoncolor = typedvalue.data; addbutton.settext("save"); addbutton.getbackground().setcolorfilter(buttoncolor, porterduff.mode.multiply); this "yellow" theme <style name="apptheme_yellow" parent="theme.appcompat.light.noactionbar"> <item name="colorprimary">@color/primaryyellow</item> <item name="colorprimarydark">@color/primary_darkyellow</item>...

c++ - Getting OpenCV with NDK support to work in Android Studio -

i'm new opencv , android programming , want use opencv in project. i'm trying run opencv's 2nd tutorial in android studio following ndk error: error:execution failed task ':opencvtutorial2mixedprocessing:compiledebugndk'. ndk not configured. download ndk http://developer.android.com/tools/sdk/ndk/.then add ndk.dir=path/to/ndk in local.properties. (on windows, make sure escape backslashes, e.g. c:\ndk rather c:\ndk) then looked @ internet , guys suggested should add these gradle.build file: jnilibs.srcdirs = ['native-libs'] jni.srcdirs = [] //disable automatic ndk-build after adding these works following error: java.lang.unsatisfiedlinkerror: dalvik.system.pathclassloader[dexpathlist[[zip file "/data/app/org.opencv.samples.tutorial2-2/base.apk"],nativelibrarydirectories=[/data/app/org.opencv.samples.tutorial2-2/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "libopencv_java3.so" this gradle f...

Geany not running Python -

i'm new user of python i installed python35 windows. hello.py runs fine in terminal. when trying run same in geany path not found. these settings in geany: compile: c:\python35\python -m py_compile "%f" execute: c:\python35\python ¨%f¨ what i'm doing wrong? execute: c:\python35\python ¨%f¨ this string contains diaeresis character (¨) (u+00a8) instead of double quote (") (u+0022).

regex - how to print previous string after selecting specific string python -

i want find word appear before keyword (specified , searched me) , print out result. tried below code gives me after words not before... str = "phone has better display, speaker. phone has average display" p1 = re.search(r"(display>=?)(.*)", str) if p1 none: return none return p1.groups() this code gives me , speaker. phone has average display but want better,average you can use positive lookahead, findall instead of search : >>> p = re.compile(r'(\w+)\s+(?=display)') >>> p.findall(str) ['better', 'average']

python - Why is a function argument default value (an empty list) static? -

this question has answer here: “least astonishment” , mutable default argument 30 answers code: def func(a=[]): a.append(1) print(a) func() func() func() output: [1] [1, 1] [1, 1, 1] i thought default value, list, re-assigned every time func called, , answer be: [1] [1] [1] you "thought default value, list, re-assigned everytime func called." thought wrong. if learning python should work through the official tutorial @ point. here what says default arguments : the default value evaluated once. makes difference when default mutable object such list, dictionary, or instances of classes. read tutorial details.

dcg - Solving Tower of Hanoi declaratively (Prolog) -

my professor gave this example of prolog. program solves tower of hanoi puzzle, have move stack of disks peg moving 1 disk after other, without putting bigger disk on top of smaller disk. now, don't program. told prolog meant declarative programming. don't want program how solve problem, want write down using prolog problem is . let prolog solve it. my effort far can found below. there 2 types of lists employ, sequence of actions represented this: [[1,2],[3,1]] ; "move top disk peg 1 peg 2, move disk peg 3 peg 1". second type of list state , example, if there 3 pegs [[1,2,3], [], []] mean there 3 disks on first peg. smaller disks have smaller numbers, front of inner list top of stack. % sequence of actions (first argument) solution if leads % begin state (second argument) end state (third argument). solution([], x, x). solution([[fromidx | toidx] | t], begin, end) :- moved(fromidx, toidx, begin, x), solution(t, x, end). % moved true when result...

c - Passing an array of pointers by reference -

i'm trying commands keyboard in similiar fashion command line args int main( int argc, char *argv[] ) but in separate function. when parse , print them within scope of getcmd() function looks , behaves intended, return main function become bunch of garbage. questions below code. #include <stdio.h> #include <time.h> #include <stdlib.h> #include <string.h> void getcmd(char *cmd, char *args[]) { char input[81] = { 0 }; char *next_token = null; printf("$ "); fgets(input, 81, stdin); input[strcspn(input, "\n")] = 0; cmd = strtok_s(input, " ", &next_token); if (!strcmp(cmd, "mv")) { args[0] = strtok_s(null, " ", &next_token); args[1] = strtok_s(null, " ", &next_token); printf("\n\n%s\n%s\n%s\n\n", cmd, args[0], args[1]); } } int main(void) { char *cmd = null, *args[5]; cmd = (char *)calloc(20,sizeof(char));...

How do i change the icon of my new Android app in Android studio? -

this question has answer here: how change launcher logo of app in android studio? 9 answers i made app using android studio. created signed apk , copied phone. installed apk in phone, icon of app default android icon. how can change , make new one. , how change name of app? for setting app icon goto androidmanifest.xml under <application tag there attribute android:icon can set desired icon.for example: android:icon="@drawable/sample_image" sample_image name of image set placed under /res/drawable/ folder. for setting app name goto strings.xml , for: <string name="app_name"> , change value of string desired.

python 2.7 - Pygame import error in pyenv 2.7.11 on Arch Linux -

i installed pygame on arch linux machine following command: $ sudo pacman -s python2-pygame i using pyenv , version of python in virtual environment project 2.7.11 when run program $ python smartcab/agent.py here get: traceback (most recent call last): file "smartcab/agent.py", line 2, in <module> environment import agent, environment file "/home/alex/machine-learning/projects/smartcab/smartcab/environment.py", line 5, in <module> simulator import simulator file "/home/alex/machine-learning/projects/smartcab/smartcab/simulator.py", line 4, in <module> import pygame importerror: no module named pygame how can solve please? on own arch linux machine... i have created 2.7.11 virtualenv using pyenv , installed python2-pygame pacman. virtualenv activated, couldn't import pygame python. able reproduce issue. after that, tried downloading , compiling pygame 's source python setup.py inst...

SQL Server 2016 R Services: sp_execute_external_script returns 0x80004005 error -

i run r code after querying 100m records , following error after process runs on 6 hours: msg 39004, level 16, state 19, line 300 'r' script error occurred during execution of 'sp_execute_external_script' hresult 0x80004005. hresult 0x80004005 appears associated in windows connectivity, permissions or "unspecified" error. i know logging in r code process never reaches r script @ all. know entire procedure completes after 4 minutes on smaller number of records, example, 1m. leads me believe scaling problem or issue data, rather bug in r code. have not included r code or full query proprietary reasons. however, expect disk or memory error display 0x80004004 out of memory error if case. one clue noticed in sql errorlog following: sql server received abort message , abort execution major error : 18 , minor error : 42 however time of log line not coincide interruption of process, although occur after started. unfortunately, there precious li...

graph - R ethogram or actogram script -

Image
i trying build ethogram or actogram figure in r. measured single behavior on 150 seconds (with 1 sec resolution), in wrote down following in excel: empty cell represents "no behavior", , cell containing 1 represents "behavior". each animal represents 1 row (150 cells long), , number of animals scored different in each experiment ( n between 11 , 20). far, have raw data exported *.csv here's example of first 4 rows containing each ~40 data points 1 *.csv file (each row 1 animal, each data point comma separated): ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,1,1,1,1,1,1,1,1,1 ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,1,1,1,1,1,1,1,1, ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,1,,,,,,1,1,1,,,, ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,1,,1,1,1,1,1,,,, i create graph in r looking similar 1 in figure 7c shown here: https://elife-publishing-cdn.s3.amazonaws.com/08758/elife-08758-fig7-v2.jpg (the whole, free article here: https://elifesciences.org/content/4/e08758 ). behavior plotted "tiny box...

how to pass parameters in groovy script using some java code -

i want automate test. have written script in groovy in soapui. calling script using java code. want pass parameters given user. saw interface soapui script or script engine. help? know should not ask without trying don't know how begin. please me out let's assume there script in src/test/groovy/com/ka/script.groovy , test in src/test/java/com/ka/myscripttest.java script.groovy println "hello ${name}" name myscripttest.java package com.ka; import groovy.lang.binding; import groovy.lang.groovyshell; import groovy.lang.script; import org.junit.test; import java.io.*; public class myscripttest { @test public void executescript() { binding binding = new binding(); binding.setvariable("name", "anonymous"); groovyshell shell = new groovyshell(binding); script script = shell.parse(getscript("./src/test/groovy/com/ka/script.groovy")); bytearrayoutputstream scriptoutput = n...

javascript - Recursive directory search including files inside ZIP's and RAR's -

i'm trying find solution problem. need files inside target directory, including files inside zip , rars. possible? i'm working version, takes files inside directories, including zips , rars files, not inside. var fs = require('fs'); var path = require('path'); var walk = function(dir, done) { var results = []; fs.readdir(dir, function(err, list) { if (err) return done(err); var pending = list.length; if (!pending) return done(null, results); list.foreach(function(file) { file = path.resolve(dir, file); fs.stat(file, function(err, stat) { if (stat && stat.isdirectory()) { walk(file, function(err, res) { results = results.concat(res); if (!--pending) done(null, results); }); } else { results.push(file); if (!--pending) done(null, results); } }); }); }); }; thanks in advance. while recursively looking file,if z...

delphi - How can I make a TList property from my custom control streamable? -

overview i writing own listbox control derived tcustomlistbox . i have began implementing own property editor allowing editing caption , imageindex of items @ designtime (i custom drawing listbox , have published own imagelist property control). problem so far working well, cannot items stream dfm. believe due fact standard listbox items property of tstrings , , control have published own property named items , of tlist class. dont want standard items property of listbox appear instead own items type. so though can drop control onto form @ designtime, edit items own property editor, if run application listboxes empty, if view dfm @ designtime , return form view items gone, not been stored in dfm , unsure how correct this? relevant extracts of code looks (comments added purpose of question): my own listbox item type: tlistboxitem = class(tobject) // tried tpersistent private fcaption: string; fimageindex: integer; public // tried published property capti...

java - How to support batch web api request processing using Spring/Servlets -

we have our web api written in using resteasy . provide support batch requests processing way google batch request processing works. following approach using currently, we have filter accepts incoming multipart request. filter creates multiple mock requests , response objects , calls chain.dofilter using these mock requests. public class batchrequestprocessingfilter extends genericfilterbean { @override public void dofilter(servletrequest req, servletresponse res, filterchain chain) throws ioexception, servletexception { httpservletrequest request = (httpservletrequest)req; mockhttpservletrequest[] mockrequests = batchrequestprocessorutils.parserequest(request); mockhttpservletresponse[] mockresponses = new mockhttpservletresponse[mockrequests.length]; for(int i=0 ; <= mockrequests.length ; i++ ) { chain.dofilter(mockrequests[i], mockresponses[i], chain); } batchrequestproc...

java - Spring Boot JPA - No qualifying bean of type -

i'm learning spring , things going running issue cannot find qualified bean. hitting wall, in new app i'm getting this. let me know if need more, going take break! must missing simple. caused by: org.springframework.beans.factory.nosuchbeandefinitionexception: no qualifying bean of type [com.alco.repository.contactrepository] found dependency [com.alco.repository.contactrepository]: expected @ least 1 bean qualifies autowire candidate dependency. dependency annotations: {@org.springframework.beans.factory.annotation.autowired(required=true)} my dependencies: <dependencies> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-data-jpa</artifactid> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-data-rest</artifactid> </dependency> <depende...

php - While statement only echoing last result -

i new, having small problem.. cannot while loop loop through entire result set, retrieving last result set, , expecting 2 result sets. i echo'd query out see result get, , echo printed out both result sets want print out. leading me confusion while loop issue. i have looked through lost on here posts have seen problem query, rather while loop. assistance appreciated. have used different posts on here construct query, don't know go here. date_default_timezone_set("europe/london"); $date = jddayofweek(unixtojd()); $sql = "select * tbl id = $id , day = $date"; $results = $conn->query($sql); echo $sql; if ($results->num_rows > 0) { while ($row = $results->fetch_assoc()) { $output = "test2" . "</br>" . $row["time"] . "</br>"; } } else { $output = $output . "test1" . "</br>"; } } you not echoin...

android - How can I save image in my Sugar ORM database? -

i want save image in database sugar orm. how can this? i have next code try save it: entity: import android.graphics.drawable.drawable; import android.media.image; import com.orm.sugarrecord; import com.orm.dsl.notnull; import com.orm.dsl.unique; public class exercise extends sugarrecord { @unique protected string name; @notnull protected string description; protected drawable image; protected string video; public exercise() { } public exercise(string name, string description, drawable image, string video) { this.name = name; this.description = description; this.image = image; this.video = video; } /** * @return string name */ public string getname() { return name; } /** * @param name */ public void setname(string name) { this.name = name; } /** * @return string description */ public string getdescription() { ret...

xml - moving repeating elements into a copy of its parent -

if <animal> has more 1 <xxx> need duplicate <animal> (duplicate count = count of repeating <xxx> within corresponding <animal> ) , move repeating <xxx> copy. in xml <xxx> repeating twice first instance of <animal> , in output need have 2 <animals> . first <animal> should contain first instance of <xxx> , second <animal> should contain second instance of <xxx> input xml <?xml version="1.0" encoding="utf-8"?> <header> <animal> <element1>element1</element1> <element2>element2</element2> <element3 lang="en">element3</element3> <xxx> <code>yy</code> <description>code yy</description> </xxx> <xxx> <code>zz</code> <description>code zz</description> ...

Android Device Monitor Data Folder Only Containing "Con" Folders -

Image
i'm trying see sqlitedatabase opening android device monitor. im navigating right path, data folder containing this: what need fix/change? i had problem. "name" field short display full name of folders. need resize mouse!

JavaScript setInterval function may or may not have parameters -

i working on simple higher-order function, delay , invoke function parameter, func , , delay amount of time passed in wait . have read other answers put in parameters, none of answers found addressed need learn: , how should allow parameters may or may not passed func ? original instructions: "invokes func after wait milliseconds. additional arguments provided func when invoked." here's basic start: function delay(func, wait) { setinterval(func, wait); } another answer on states anonymous function can used wrap func parameter parameters can passed in there, haven't had success building yet. guidance appreciated. it sounds need make use of arguments pseudo-array, , function#apply : function delay(func, wait) { // arguments after first 2 var args = array.prototype.slice.call(arguments, 2); settimeout(function() { func.apply(null, args); }, wait); } example: function delay(func, wait) { var args = array.prototype.slice...

c++ - Why does Xcode think gsl::span needs two template arguments? -

Image
i'm getting familiar gsl, , wrote following simple example test out how gsl::span works. xcode seems have problems can see here: this compiles , runs fine, should, @ same time xcode thinks gsl::span needs template argument, quite strange. i've never seen compiler or ide give actual error (not warning) , compile fine. gsl::span can deduce size of array, second template argument wouldn't necessary. if change argument type gsl::span<int,5> , errors go away, of course not solution.

bash file globbing anomaly -

the bash manual (i'm using version 4.3.42 on osx) states vertical bar '|' character used separator multiple file patterns in file globbing. thus, following should work on system: projectfiles=./config/**/*|./support/**/* however, second pattern gives "permission denied" on last file in directory structure pattern never resolved projectfiles. i've tried variations on this, including wrapping patterns in parentheses, projectfiles=(./config/**/*)|(./support/**/*) which laid out in manual, doesn't work either. any suggestions on i'm doing wrong? you're referring part in man bash : if extglob shell option enabled using shopt builtin, several extended pattern matching operators recognized. in following description, pattern-list list of 1 or more patterns separated |. composite patterns may formed using 1 or more of fol- lowing sub-patterns: ?(pattern-list) matches 0 or 1 occurrence ...

Json parsing in android is showing no results,Illegal Argument Exception,Host name may not be null -

Image
this line of code giving me errors : httppost httppost = new httppost("file:///android_asset/www/me.json"); instead of file,even if use "http://xyz......"); still errors ./.................... import android.os.bundle; import android.app.activity; import android.webkit.webview; import android.widget.textview; import java.io.bufferedreader; import java.io.inputstream; import java.io.inputstreamreader; import org.apache.http.httpentity; import org.apache.http.httpresponse; import org.apache.http.client.methods.httppost; import org.apache.http.impl.client.defaulthttpclient; import org.apache.http.params.basichttpparams; public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); textview tv=(textview)findviewbyid(r.id.tv1); defaulthttpclient httpclient = new defaulthttpclient(new bas...

arc4random - Swift random float between 0 and 1 -

running xcode6-beta4, in public osx yosemite beta. i'm trying random float between 0 , 1 can't seem type conversions work. func randomcgfloat() -> cgfloat { return cgfloat(arc4random()) / uint32_max } i'm getting 'cgfloat' not convertible 'uint8' error try initializing divisor float well, la: cgfloat(float(arc4random()) / float(uint32_max))

module - implement `each` for Enumerable mixin in Ruby -

i'm learning magic of enumerable in ruby. i've heard 1 have include enumerable , implement each method , can have power of enumerable class. so, thought implementing own custom class foo practice. looks below: class foo include enumerable def initialize numbers @num = numbers end def each return enum_for(:each) unless block_given? @num.each { |i| yield + 1 } end end this class takes array , each works similar array#each . here's difference: >> f = foo.new [1, 2, 3] => #<foo:0x00000001632e40 @num=[1, 2, 3]> >> f.each { |i| p } 2 3 4 => [1, 2, 3] # why this? why not [2, 3, 4]? everything works expect except 1 thing last statement. know return value shouldn't [2, 3, 4] . there way make [2, 3, 4] . also please comment on way have implemented each . if there's better way please let me know. @ first in implementation didn't had line return enum_for(:each) unless block_given? , wasn't working whe...

rdbms - RBDMS design for Employees with admin powers in a Company -

we have 2 models, company , employee . 1 company has many employees. the vast majority of employees not have admin powers, there may 1 or more employees admins powers on company. what best way of doing in db? can think of following 2 ways, , both have cons , benefits. 1) indicate admin status in employee table though false majority of employees. benefit not having joins determine if employee has admins. company ------- id employee -------- id company id admin 2) create junction table between company , employee, , include employees admin powers. requires join everytime want determine if employee has admin powers. company ------- id name employee -------- id company id adminemployee (is there better name this?) ------------- id company id employee id the usual way create roles can associated users . below minimum need: a company table list companies: company id unsigned int(p) name varchar(255) ... +----+---...

c# - How to translate the OlCategoryColor? -

i'm using microsoft.office.interop.outlook; allows me use olcategorycolor . in particular i've this: dictionary<olcategorycolor, keyvaluepair<string, string>> categorycolor; categorycolor = new dictionary<olcategorycolor, keyvaluepair<string, string>> { {olcategorycolor.olcategorycolorred, new keyvaluepair<string, string>("#e7a1a2", "7")} }; to name of color, this: foreach (var outlookcolor in categorycolor) { outlookcolor.key.tostring().remove(0, "olcategorycolor".length); } it returns red , possible take italian language or other languages? here simple solution, may want tweak little depending on wherever want support many languages or italian: public enum language { english, italian } public static class localizationhelper { private static idictionary<string, string> eng2italiancolor = new dictionary<string, string> { { "red", "rosso...

ARM - Implementing stack with load/store multiple register values -

this pretty basic question related implementation of stacks in arm , other register-based machines. ldm , stm commands can used move multiple values between memory , group of general purpose registers stack operation or block copy. ldm or stm operations don't appear alter rules of how can implement stacks , reduce length of code required perform multiple transfers (e.g., common transfers of multiple register contents @ start , end of functions). however, it's unclear whether loaded registers behave stack after values loaded memory. i'm bit confused whether stacks implemented in external memory, registers, or combination of two. thanks in adv! the stack memory. processors special internal memory memory, nothing more stack pointer register points system memory , programmers (operating system and/or application) make sure stack pointer doesnt point @ memory being used else. the idea have limited set of registers, if have more enough registers there may ...

C - Unable to free doubly linked list node -

i have data structure this: typedef struct telephonebooknode { int id; char name[name_length]; char telephone[telephone_length]; struct telephonebooknode * previousnode; struct telephonebooknode * nextnode; } telephonebooknode; typedef struct telephonebooklist { telephonebooknode * head; telephonebooknode * tail; telephonebooknode * current; unsigned size; } telephonebooklist; i can create nodes, , make list containing data because got no problems in displaying list, inserting or moving nodes.... but when write function erase list, got error: phonebook(6187,0x7fff77045000) malloc: *** error object 0x7f87c1f00004: pointer being freed not allocated *** set breakpoint in malloc_error_break debug this eraser functions: void freetelephonebooklist(telephonebooklist* alist) { telephonebooknode* node; telephonebooknode* temp = alist->head; while (temp) { node = temp; temp = node->nextnode; freetelep...

css - parse error in css3 using @media -

can't following not throw parse error in css3 @media (min-width: 1500px) { div#headerwrapper, div#navsuppwrapper { width: 100% !important; margin: auto; } } any suggestions? never been fan of !important in css here basic media query template, last query @ bottom should fix problem. /* #### mobile phones portrait #### */ @media screen , (max-device-width: 480px) , (orientation: portrait){ } /* #### mobile phones landscape #### */ @media screen , (max-device-width: 640px) , (orientation: landscape){ } /* #### mobile phones portrait or landscape #### */ @media screen , (max-device-width: 640px){ @media screen , (min-device-width: 768px) , (max-device-width: 1024px){ } } /* #### iphone 4+ portrait or landscape #### */ @media screen , (max-device-width: 480px) , (-webkit-min-device-pixel-ratio: 2){ @media screen , (min-device-width: 768px) , (max-device-width: 1024px){ } } /* #### tablets portrait or landscape #### */ @...

node.js - The "right way" to architecture voting with Mongoose? -

i'm creating web app using mongoose/mongodb store information voted on. i'll storing usernames , ip addresses vote (so voters can update/modify votes if desired). root question: what's best way securely architecture voting in mongoose schema? currently, schema looks (simplified): var thing = new schema({ title: { type: string }, creator: { type: string }, options: [{ description: { type: string }, votes: [{ username: { type: string }, ip: { type: string } }] }] }); mongoose.model('thing', thing); while makes querying db given thing super easy, becomes more problematic security obvious reasons - don't want returning out usernames , ip addresses browser. the problem is, i'm not sure best/least painful scenario securely returning thing data browser: loop through each option in thing.options , sub-loop through each vote in thing.options[i].votes find vote cast ...

How to trim a string after a specific character in java -

i have string variable in java having value: string result="34.1 -118.33\n<!--abcdefg-->"; i want final string contain value: string result="34.1 -118.33"; how can this? i'm new java programming language. thanks, you can use: result = result.split("\n")[0];

r - ggplot stacked bar plot from 2 separate data frames -

Image
i have been struggling conundrum day , getting close, no cigar. have 2 data frames results of 2 separate socio-economic surveys 2 districts within city. want compare columns these data frames side side in bar plot show frequencies (counts) of responses particular question across both surveys. the questions asked in each survey identical. however, coded differently , therefore column names different follows! have managed plot data 2 data frames ( ar , bn ) on same bar plot raw data i.e. without having merge data frames. however, seem unable plot stacked bar plots side-by-side. i used ggplot2 following code: ggplot(bn, aes(a8_hhh_hig, fill=a6_sex_hhh)) + geom_bar(position="stack", alpha=0.5) + geom_bar(data=ar, aes(a9_hhhedulevl, fill=a7_hhsex), position="stack", alpha=0.5) which produces this: as you'll notice attempting plot split between male , female respondents based on highest level of schooling 2 data frames. (note sex of respondent code...