Posts

Showing posts from March, 2014

Force definition of symbol for a C++ template instance in a library -

i'd provide library provides template code. keep possible ownership of code (generated code) when can guess usage of different usual types of template. here example of trying do: lib1.h #include <iostream> template<int n> void print_me() { std::cout << "i function number " << n << std::endl; } lib1.cpp #include "lib1.h" /* force symbols defined here. */ template void print_me<0>(); template void print_me<1>(); i compile library using: g++ -shared -fpic lib1.cpp -o lib1.so and when use library: main.cpp #include <lib1.h> int main() { print_me<0>(); print_me<1>(); print_me<2>(); } compiled with: g++ main.cpp -l1 here expect symbol print_me<0>() , print_me<1>() defined , used lib1.so , print_me<2>() defined , used executable (checked nm --defined-only). seems not case! symbols 0 , 1 defined in lib1.so weak symbols. , redefined ...

compression - PDF XFA File convert to "normal" PDF file -

i´m searching way convert pdf xfa files normal pdf files processed , / or compressed via imagemagick or ghostscript example. options found removing the xfa tags resulting in empty file. one way use adobe acrobat reader , print file via virtual printer. not acceptable option on server. itext out of option because expensive need. got idea or have better way? i have been able convert forms created xfa features using free toolkit pdflabs called pdftk. interface not quite intuitive hope job done. also, debenu has product called quick pdf library. have not tried function called removexfaentries think want also. thinking writing utility encapsulate feature make job easier.

c# - Access textbox from ControlTemplate in UserControl.Resources -

i have control template defined this: <usercontrol.resources> <controltemplate targettype="{x:type datagrid}" x:key="inputitemscontroltemplate"> <grid> <grid.columndefinitions> <columndefinition width="120"/> <columndefinition width="200"/> <columndefinition width="20"/> <columndefinition width="200"/> </grid.columndefinitions> <grid grid.column="0"> <grid.rowdefinitions> <rowdefinition height="25" /> <rowdefinition height="25" /> <rowdefinition height="25" /> </grid.rowdefinitions> <label grid.row="1" content="{dynamicresource ucodestr}" horizontalalignmen...

android - How can I take values from EditText and sum them in array -

i have 2 edit-text example. wanna take value user entered on it. , sum them on array . let code this. edittext onevalue = (edittext)addview.findviewbyid(r.id.one); edittext twovalue = (edittext)addview.findviewbyid(r.id.two); if user entered 5 in onevalue , , 7 in twovalue . how can sum them in array ? what mean "sum them in array"? if want add 2 values , add summed value in array can following: int[] array = new int[10]; // size int = integer.parseint(onevalue.gettext().tostring()); int b = integer.parseint(twovalue.gettext().tostring()); int c = + b; array[0] = c; // position

javascript - Change responsive slider height with scale transition -

i know how make rslides style transition scale transition way clients div changing after clients link clicked, here fiddle: http://jsfiddle.net/vladicorp/ktqfq/1/ html code: <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <div id="container"> <div id="sections"> <div id="slider"> <div id="index_slider"> <ul class="rslides" > <li><img src="http://www.emocool.com/work/slide2.jpg"></li> <li><img src="http://www.emocool.com/work/slide2.jpg"></li> </ul></div></div> <script src="http://www.emocool.com/work/js/responsiveslides.min.js"></script> <script> $(function() { $(".rslides").responsiveslides({ ...

how to parse complex xml in php -

i have xml document , i'm trying parse ( loop through items ) seems no xml parser understands it. i've tried simplexml , few others provide 2 fields (@attributes: locale, country) or unclear arrays. using online viewer can see list of items must issue php parser. need extract each item image, price , location. decode in array highly appreciated ! need loop through 'ad' array , extract information each 'ad'. id, price, title, start-date-time, category, locations, pictures (array). here print-screen: http://i.imgur.com/r9ykuzy.png . doesn't let me post image without 10 reputation. $xml = simplexml_load_file('xml'); print_r($xml); returns simplexmlelement object ( [@attributes] => array ( [locale] => en_gb [version] => 1.17 ) ) i tried class i've found ( xml2array ) no luck ! thinking use regex it's old friend of mine data doesn't seem structured in such way extracted ...

Shorter version of Java System.out.println() -

is there way shorthand system.out.println() method? system.out.println() = short(); so change main method to... package array; import java.util.random; public class array { public static void main(string args[]) { data(); a(); random(); a(); array(); a(); rows(); a(); system.out.println("average " + average(45,15,15,48,97,45)); } static void a() {system.out.println();} static void data() { int array[] = {1,5,6}; int alength = array.length; system.out.println(" location\tdata"); for(int i=0;i<alength;i++) { system.out.println(" " + + "\t\t" + array[i]); } } static void random() { random rdm = new random(); int freq[] = new int[7]; for(int i=1;i<1000;i++) { ++freq[1+rdm.nextint(6)]; } system.out.println("face\tfrequency"...

c# - How do I separate each line of a .csv file into a string list> -

i new c# , attempting read in .csv file , put each line of text in separate list item can sort later. the .csv file organised so: 1;"final60";"united kingdom";"2013-12-06 15:48:16"; 2;"donnyr8";"netherlands";"2013-12-06 15:54:32"; etc this first attempt doesn't work.it shows no errors in visual studios 2010 when run console program displays following exception instead of list. exception of type 'system.outofmemoryexception' thrown. bizarre because .csv file contains small list. try { // load csv file using (streamreader file = new streamreader("file.csv")) { string line = file.readline(); list<string> filelist = new list<string>(); // lines file until end of // file reached. while (line != null) { filelist.add(line); } foreach (string filelistline in filelist) { console.wri...

.net - VS2013 - Nuget - Installing Google.Apis.Datastore.v1beta2 gives error -

peace upon you, i have vs2013 ultimate, tried install google.apis.datastore.v1beta2 using package manager console command stated here install-package google.apis.datastore.v1beta2 -pre and got these results: attempting resolve dependency 'google.apis (≥ 1.7.0-beta)'. attempting resolve dependency 'google.apis.core (≥ 1.7.0-beta)'. attempting resolve dependency 'newtonsoft.json (≥ 5.0.5)'. attempting resolve dependency 'microsoft.bcl (≥ 1.0.19)'. attempting resolve dependency 'microsoft.bcl.build (≥ 1.0.4)'. attempting resolve dependency 'microsoft.bcl.async (≥ 1.0.16)'. attempting resolve dependency 'microsoft.net.http (≥ 2.1.10)'. attempting resolve dependency 'zlib.portable (≥ 1.9.2)'. attempting resolve dependency 'log4net (≥ 2.0.0)'. install-package : remote server returned error: (404) not found. @ line:1 char:1 + install-package google.apis.datastore.v1beta2 -pre + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...

python - tornado.wsgi.WSGIApplication issue: __call__ takes exactly 3 arguments (2 given) -

as part of project, i've been trying port tornado server work on google app engine. since app engine doesn't implement asynchronous functions of normal tornado, i've been trying convert main application wsgiapplication. normal main code works fine (forgive imports , formatting, it's mess trying follow other examples): import wsgiref import tornado.wsgi import tornado.web import tornado.httpserver import os import handlers tornado.options import define, options define("port", default=8000, help="run on given port", type=int) def application(): handlers=[(r"/", handlers.mainhandler), (r"/login", handlers.loginhandler), (r"/viewhistory",handlers.viewhistoryhandler), (r"/uploadfile", handlers.uploadhandler), (r"/index", handlers.indexhandler), (r"/about", handlers.abouthandler), (r"/profile", handlers.p...

javascript - Filter json data in controller, the right way -

(there other questions neither helped me out) hi, know if right way filter results service i'm displaying 1 result (like detail). i know use ng-repeat , filter in view , cleanest, want have more control on because re-use of data in controller other operations. right i'm doing this: $scope.savedevents = event.getpayedevents(); //gets list service //goes through entire list , checks match angular.foreach($scope.savedevents, function(event) { if (event.idevent == $stateparams.eventid) { $scope.showevent = event; } }); //now if there match can use $scope.showevent.eventname etc not sure if easier using $filter return 1 event has correct idevent. or if has better solution, please let me know. thanks i don't see problems have, inject $filter service , 1 liner: $scope.showevent = $filter('filter')($scope.savedevents, { idevent: $stateparams.eventid }); edit: here easy way resolve result single value returned array: var sh...

How do I use C preprocessor macros with Rust's FFI? -

i'm writing code interfaces existing library written in c. in rust code i'd able use values cpp macros. if have c include.h looks this: #define init_flag 0x00000001 i'd able use in rust this: #[link(name="mylib")] extern { pub static init_flag: c_int = init_flag; } i've looked @ other ffi code , see lot of people duplicating these values in rust instead of getting them ffi. seems little brittle, , i'd able handle more complicated things defined via cpp macros. running cpp on rust files work if i'm sure cpp macros used simple things. it impossible, , don't think possible in future. c macros bring many problems them. if want run cpp on rust sources, can manually. if don't want , if there lot of constants , don't want copy values c code rust can make c wrapper provide global variables these values: #define init_flag 0x00000001 ... const int init_flag = init_flag; you compile file, create static library , link...

msbuild - How to build a multiple language bootstrapper setup.exe with WIX 3.7 -

i have setup project build wix 3.7 includes 3 languages (english, french , german). build output setup_en-us.msi, setup_fr-fr.msi , setup_de-de.msi. every msi bootstrapper (for .net 4.5) setup.exe generated following line in .wixproj: <generatebootstrapper applicationname="$(productname)" bootstrapperitems="@(bootstrapperfile)" componentslocation="homesite" copycomponents="true" outputpath="$(targetdir)%(culturegroup.outputfolder)" culture="%(culturegroup.identity)" fallbackculture="en-us" path="$(bootstrapperpath)" /> now i've managed include 3 language in 1 msi setup.msi. my problem can set 1 language while generating bootstrapper setup.exe prefer setup.exe includes 3 languages, too. is there possibility create such setup.exe?

python 3.x - How to clear the screen and how to run the code after the levelOne loop -

full code , files: https://www.dropbox.com/sh/gqke6hfooz7mbnr/qm8nmlynqc can't seem find solution dilemma. basicly press space go next loop ( leveltwo ) , stops, nothing new appears on screen though have code that. i'd appreciate help. part of code dilemma not sure: if len(rabbits) == 0: rabbitcounter = 0 windowsurface.blit (textlevelone, (100, 104)) levelone = false windowsurface.fill((0,0,0)) #ritar fönstret pygame.display.update() mainclock.tick(60) #level 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ startsoundleveltwo = true while levelone == false: leveltwo = true if startsoundleveltwo == true: rabbitsound.play() foxsound.play() pygame.mixer.music.play() startsoundleveltwo = false pigspawn = true boarspawn = true level 2 lacks pygame.display.update() call. personally, structure pygame code 1 main loop, this: level =...

python - How to run a system command from a django web application? -

does knows of proven , simple way of running system command django application? maybe using celery? ... from research, it's problematic task, since involves permissions , insecure approaches problem. right? edit: use case: delete files on remote machine. thanks here 1 approach: in django web application, write message queue (e.g., rabbitmq) containing information need. in separate system, read message queue , perform file actions. can indeed use celery setting system.

css - Mixing floating and absolute positioning issues -

i'm trying float 3 elements, no problem there. in 2 outside boxes need position element vertically in center, thought wrap them both in div, float wrapping divs , absolute position elements inside them , set wrapping elements position: relative; wouldn't mess layout , 3 elements stay floated correctly. however doesn't seem have happened way, middle element still seems shoved way left. my css: .line_wrap { float: left; position: relative; width: 366px; min-width: 366px; max-width: 366px; } .line_wrap .line { position: absolute; top: 25px; left: 0; width: 366px; min-width: 366px; max-width: 366px; border-top: 1px solid #d9dce6; } .title { float: left; } .title h2 { font-weight: 300; font-size: 37px; color: #425080; } my html: <div class="fee_header"> <div class="line_wrap"> <div class="line"></div> </div> <div...

Do MySQL views ever expire? -

do mysql views ever expire or automatically deleted? it looks temporary tables last long connection. views have similar expiration date? if apache or mysql restarted, views dropped? right now, looks views deleted if manually drop them (or overwrite them new data). i looked on mysql documentation, google , not find discussion on this. temporary tables automatically deleted because temporary . views not temporary, aren't automatically deleted.

html - PHP login using CodeIgniter -

i'm trying login on php using codeigniter. my code this: login view <div class="section section_with_padding" id="usuarios"> <h1>acceso usuarios</h1> <div class="half left"> <h4>usuario existente</h4> <p>si posee una cuenta en garage, introduzca su nombre de usuario y contraseña para acceder.</p> <div id="login"> <!-- usado para que muestre los errores de validacion --> <form method="post" name="users" action="index.php/verificarlogin"> <div class="left"> <label for="username">nombre de usuario:</label> <input name="username" type="text" class="required input_field" id="username" maxlength="30" ...

c++ - Using a local short to pass a value into a function expecting an int; does this save memory? -

i'm on embedded system (for first time) , have whopping 512 bytes of memory. i'm bumping against barrier, , i'm looking save on each , every byte possible. such, following question: in sdk, there's function, prototyped: void foo(int val); as such, main looked like: void main() { int myval = 0; // stuff compute myval foo(myval); } myval, however, never have value more ~100. saving memory @ doing instead? void main() { short int myval = 0; // stuff compute myval foo(myval); } edit: on architecture, ints 4-bytes, shorts 2-bytes. i'm unsure of whether using local short (or char, or whatever) save space since has up-cast meet foo(int) prototype. i have no experience such small systems; following guess (the smallest ones worked had 384 k). changing int short or makes compiler's optimizer work, , optimizer's output cannot predicted 100% accuracy. your platform has sort of convention passing parameters f...

how to code linked list in python with multiple variables -

i kind of new python. background more in java , c++. i'm trying create linked list multiple variables. know can done in java , c++ im not sure how set python. have code have found on other websites work single variable need hold several pieces of information. have is: class node: def __init__(self, cargo=none, next=none): self.cargo = cargo self.next = next def __str__(self): return str(self.cargo) this ok need more info this. c++ put many variables wanted in struct. can please advise on need change can use many pieces of data. example: movie title, rating, genre, ect. (not project example). goal of project to compare 2 very large list each other. or maybe has more efficient way of doing this. love hear it. thanks in advance python uses called 'duck typing'. if object walks duck , quacks duck, it's duck. think of 'walk' , 'quack' object methods. long methods exist on object, can called. cargo c...

winapi - Mouse hooking callback not called? -

i'm trying hook mouse this: #include <windows.h> #include <stdio.h> hhook mousehook; lresult winapi mousehookproc(int ncode, wparam wparam, lparam lparam) { messagebox(0, "not called :-(", "m", 0); return callnexthookex(mousehook, ncode, wparam, lparam); } int main() { mousehook = setwindowshookex(wh_mouse, (hookproc)mousehookproc, getmodulehandle(null), 0); printf("press enter exit.\n"); getchar(); return 0; } but messagebox never appears. think everything's ok, seems there's wrong. thanks in advance.

javascript - Timeout in Jquery to update the Dom? -

let's want change image source onclick , calculations. whats happening right source changes when the function exits. (dom busy?) how can make image source updates right away , function proceeds while loop? html: <img src="http://goo.gl/l55g2p" id="imagesrc"> js: $( "#imagesrc" ).click(function() { new_imgsrc="http://goo.gl/wbhyee"; $("#imagesrc").attr('src',new_imgsrc); test = 0 { test = test + 1; console.log(test); } while (test != 50000); }); here 's jsfiddle. not sure understand correctly use timeout: settimeout(function() { //while loop here }, 1000); where 1000 means 1 second. shrink value doesn't wait long. as click() has no callback oncomplete not sure of better way achieve this.

c++ - Is there a penalty for using static variables in C++11 -

in c++11, this: const std::vector<int>& f() { static const std::vector<int> x { 1, 2, 3 }; return x; } is thread-safe. however, there penalty calling function after first time (i.e. when initialized) due thread-safe guarantee? wondering if function slower 1 using global variable, because has acquire mutex check whether it's being initialized thread every time called, or something. "the best intution ever had 'i should measure this.'" let's find out : #include <atomic> #include <chrono> #include <cstdint> #include <iostream> #include <numeric> #include <vector> namespace { class timer { using hrc = std::chrono::high_resolution_clock; hrc::time_point start; static hrc::time_point now() { // prevent memory operations reordering across // time measurement. overkill, needs more // research determine correct fencing. std::atomic_thread_fence(std::mem...

excel - VBA Runtime Error...but I can't click on debug -

Image
i runtime error cannot click on debug. do debug error? "run time error 91 object variable or block not set" the vbaproject within worksheet more locked. need unlock it. by: opening microsoft vba window alt + f11 right-clicking vba project selecting vbaproject properties option clicking on protection tab , unselecting lock checkbox

javascript - getURLParameter and RegExp -

i new jquery , javascript. trying understand piece of code below. can explain me parameter "name" suppose be? url? (i.e https://stackoverflow.com/questions/ask ). can explain how location.search.match.regexp("[?|&]" + name + '=(.+?)(&|$)')) works. great if can use in example input "name" , display output. thank in advance! $(document).ready(function () { function geturlparameter(name) { return decodeuricomponent( (location.search.match(regexp("[?|&]" + name + '=(.+?)(&|$)')) || [, null])[1]); } } name called function's parameter . when function called uses parameter search query string portion of browser's url parameter matching name , returns value . query string specified (at minimum): ?parameter1=value1 number of additional/optional parameters separated & , ie. ?parameter1=value1&parameter2=value2 . if name parameter not found, function ret...

jquery UI - able to move draggable into wrong sortable -

i have draggable i've designated connect sortable .sectionlist connecting sortable .questionlist . i'm pretty sure had working before can't figure out what's wrong. fiddle: http://jsfiddle.net/sewhr/4/ full screen fiddle: http://jsfiddle.net/sewhr/4/embedded/result/ html (stripped lot of stuff out): <span id="j_id0:j_id11"></span><span id="j_id0:j_id37"><span id="j_id0:j_id40"> <div id="topcontent"> <div class="dragsection"> <h3>drag create new section or new question:</h3> <div class="draggablenewsection questionbox"> <div class="questionlabel">new section</div> </div> <div class="draggablenewquestion questionbox"> <div class="questionlabel">new question</div> </div> </div> <hr /> </div> <div id="allse...

sql server - converting Year and Month varchar to date -

i have table month , year varchar. realized big mistake. since getting complicated query way. year month productname 2013 11 acb 2013 11 cde i add column called date , store these year month date existing table year month productname date 2013 11 acb 2013-11-01 2013 11 cde 2013-11-01 is there way can columns of existing table ?? please let me know convert month , year columns strings concatenated '-'s , add '-01' end. convert date. update t set t.[date] = convert(date, convert(varchar(4), t.[year]) + '-' + convert(varchar(2), t.[month]) + '-01') table t this create date records in table.

utf-8 unicode in html and utf-8_general_ci in mysql -

i have mysql database collation utf-8 general_ci in html text shown ???????? p.s i using <meta charset="utf-8"> and this <meta http-equiv="content-type" content="text/html; charset=utf-8" /> in mysql database text shown needed in html shown ???????? p.s it's georgian unicode use "set_charset" function after connecting mysql database.

plsql - ORACLE PL/SQL: Table or view does not exist -

i'd appreciate on topic since making first steps pl/sql: when trying create function, error: "table or view not exist" 5 select statements (and statement in cursor declaration well). sure tables exist. many in advance. create or replace function zinskalk (vtid in number, intart in integer) return number j integer := 0; p number := 1; q number := 0; t number := 1; r number := 0; lz integer := 0; modusvn integer := 0; w1 number := 0; w2 number := 0; integer := 0; type array_typ varray (200) of number (10, 2); rarray array_typ; cursor c1 select vtobslpos.anzahl, vtobslpos.betrag vtobsl, vtobslpos vtobsl.sysid = vtobslpos.sysvtobsl , vtobsl.sysid in (select max (vtobsl.sysid) vtobsl vtobsl.sysvt = vtid , vtobsl.rang = 100) or...

python file read() displaying empty line -

i following series of tutorials ( http://learnpythonthehardway.org/book/ex16.html ) online , stuck. have looked everywhere answer cannot seem o find solution. apologise if silly question , obvious total beginner. the script below works fine except 1 mistake. .read () command on line 29 returns empty when script run. if tell me why , how fix happy. kind regards. :) from sys import argv script, filename = argv print "we going erase %r" % filename print "if not want hit ctrl c ( ^c )." print "if want hit return." raw_input ("?") print "opening file....." target = open (filename, "r+") print "truncating file. goodbye!" target.truncate () print "now going ask 3 lines" line1 = raw_input ("line 1:") line2 = raw_input ("line 2:") line3 = raw_input ("line 3:") print "now, im going write 3 lines %s file:" % filename target.write ("%s\n%s\n%s" % ...

html - Countdown Timer in Javascript -

this question exact duplicate of: countdown timer in html [closed] i have little countdown code written in javascript html document. need someone's knowledge , modify code can input own time , start countdown button. counter_start = 3 function tick () { if (document.getelementbyid ('counter').firstchild.data > 0) { document.getelementbyid ('counter').firstchild.data = document.getelementbyid ('counter').firstchild.data - 1 settimeout ('tick()', 1000) } else { document.getelementbyid ('counter').firstchild.data = 'done' } } if (document.getelementbyid) onload = function () { var t = document.createtextnode (counter_start) var p = document.createelement ('p') p.appendchild (t) p.setattribute ('id', 'counter') var body = document.getelementsbytagname ('body')[0] var firstchil...

ios - Export an OTA installable IPA from XCARCHIVE -

i'm migrating our build scripts produce xcarchive files, can upload builds right xcode organizer, however, i'm having trouble getting builds work on air now. i'm building archive with: xcodebuild -scheme myscheme \ "code_sign_identity[sdk=iphoneos*]=$appstore_identity" \ provisioning_profile=$appstore_profile_id \ -archivepath $outputarchive archive` then i'm trying export , re-sign using enterprise distribution profile with: enterprise_profile_name=`basename $enterprise_profile_file .mobileprovision` \ xcodebuild -exportarchive \ -archivepath "$outputarchive" \ -exportformat ipa \ -exportprovisioningprofile "$enterprise_profile_name" \ -exportpath "$outputipa" the resulting ipa looks correct (contains correct profile, codesign says it's valid, etc), however, when generate manifest file can installed on air things stop working. on io...

click - Bind a jquery image zoom effect to onclick -

i'm using plugin enable image zoom on site: http://www.elevateweb.co.uk/image-zoom/ i modified code magnifying glass appears when click image (the mouse cursor magnifying glass when hover on image suggest can click zoom). code looks following: $("#mainimage").click(function() { $("#mainimage").elevatezoom({ zoomtype: "lens", lensshape: "round", lenssize: 300 }); }); this code works fine. i'd remove zoom effect on click. code try , write doesn't work... suggestions? thanks! edit: i found github note seems suggest there's changestate function: https://github.com/elevateweb/elevatezoom/commit/81c2cc4946f6bebc33c0d8e804b046b36fa1bc61 but i'm having trouble using without documentation... right have (just test it): $("#mainimage").click(function() { $("#mainimage").elevatezoom({ zoomtype: "lens", lensshape: ...

websphere portal - Unable to access WCM library -

i trying access wcm(web content management) library, working fine portal application. requirement access same library enterprise application deployed on was(webspher application server). works fine on localhost, when deployed on development server giving me below error- stack trace com.ibm.websphere.servlet.error.servleterrorreport: java.lang.illegalstateexception: wcm repository not registered wcm_api @ com.ibm.ws.webcontainer.filter.webappfilterchain.dofilter(webappfilterchain.java:152) @ com.ibm.ws.webcontainer.filter.webappfilterchain._dofilter(webappfilterchain.java:77) @ com.ibm.ws.webcontainer.filter.webappfiltermanager.dofilter(webappfiltermanager.java:908) @ com.ibm.ws.webcontainer.servlet.servletwrapper.handlerequest(servletwrapper.java:934) @ com.ibm.ws.webcontainer.servlet.servletwrapper.handlerequest(servletwrapper.java:502) @ com.ibm.ws.webcontainer.servlet.servletwrapperimpl.handlerequest(servletwrapperimpl.java:179) @ com.ibm.wsspi...