Posts

Showing posts from August, 2012

ios - UIImageView in full screen mode -

i think going wrong way need little help, please. my goal: i have uiimageview displays single image user. view in uiview. when user taps on image go full screen mode. current facebook , ebay ios apps on iphone. once in mode, user can zoom on image , when done - swipe / down on image , goes last view. problem i not entirely sure how done. on apps mentioned, there new bar appears @ bottom of screen - bar allows user other actions. this, along swipe gesture makes me believe full screen mode presented new view controller. noticed scroll or down on ebay ios app, background starts change clear colour see view presented from. did not know possible uiviewcontroller when dismissing it? not sure how done. i tried setting uiimageview full screen - misses else described above. can point me in right direction. i'd appreciate it. thanks! i present new view controller in front of first 1 image full screen and, optionally, other controls. think effect of seeing prese...

tkinter - Zelle Graphics Error Python -

i have been trying import zelle's graphics library python while keep getting error short program created. traceback (most recent call last): file "d:\my_stuff\desktop\connectfour.py", line 5, in <module> graphics import* file "c:\python33\lib\site-packages\graphics.py", line 1, in <module> class graphwin(tk.canvas): nameerror: name 'tk' not defined here program in case: from graphics import* def main(): win = graphwin("connect four", 320, 240) win.setbackround("white") win.setcoords(0,0,7,6) board = rectangle((0,0),(7,6)) board.draw(win) (tk.canvas) main() i believe error relates tkinter library (which have). , person said fix code indentation: i'm new (^) better? several small problems code: 1) line 4: should win.setbackground (probably typo) 2) line 6: rectangle's arguments must point objects, e.g. rectangle(point(0,0), point(7,6)) 3) line ...

javascript - Linking to File With Space in JQuery -

how link file contains space? possible? have javascript document , have dozens of images contain spaces hoping able still link them. %20 escaped value blank space. use in hyperlink, , you'll file want :) in case test in browser: modern browsers (chrome sure) not visually change space %20 anymore in address bar, still escape characters before making web request. edit generally speaking, you'd html encode strings via accessible method, rather manually escaping needed characters. the following question has elegant solution. if use element not visible user (or not part of dom, case linked answer), won't know.

html - How to select a div with nth-child()? -

i have html structure this: <section id="main-content" class="photo-grid"> <h2>photos</h2> <div class="col-1-4"> <a href="#"> <p>file 503</p> <img src="#" /> </a> </div> <div class="col-1-4"> <a href="#"> <p>file 508</p> <img src="#" /> </a> </div> <div class="col-1-4"> <a href="#"> <p>file 505</p> <img src="#" /> </a> </div> <div class="col-1-4"> <a href="#"> <p>file 525</p> <img src="#" /> </a> </div...

c++ - Define object from other classes -

i can't define object other classes under top class example : class b; class { public: a(){ cout << "a\n"; } ~a(){ cout << "~a\n"; } private: b ob; }; class b { public: b(){ cout << "b\n"; } ~b(){ cout << "~b\n"; } ob; }; int main() { b r; system("pause"); } the problem can't make object in class if write (class b;) above it your problem solved passing b object pointer a constructor. if change b class contain pointer a , recursion solved. is, creating infinite loop, creating object b contains object a , contains object b , , on. class b { public: b(a* _ob) : ob(_ob) { cout << "b\n"; } ~b(){ cout << "~b\n"; } a* ob; }; int main() { _a; b r(_a); system("pause"); }

crosstab - How can I count the frequency of an answer in R? -

i have db this: id group drink 1 yes 2 no 3 na 4 b no 5 b no 6 b yes and measure how many people of group drinks , how many people in group b drinks. i using length() , function returns 3 ( na being considered = yes). how can fix it? table() 1 option: db <- read.table(text = "id group drink 1 yes 2 no 3 na 4 b no 5 b no 6 b yes", header = true) with(db, table(drink)) with(db, table(group, drink)) > with(db, table(drink)) drink no yes 3 2 > with(db, table(group, drink)) drink group no yes 1 1 b 2 1 including na class achieved usena argument: with(db, table(drink, usena = "ifany")) > with(db, table(drink, usena = "ifany")) drink no yes <na> 3 2 1 you can of course store objects returned table() , access them other matrix/array: tab <- with(db, table(drink, usena = "ifany...

css - How to select all elements excluding a specific one along with all its descendants -

Image
update: may not possible. i'm still looking solution. i need create css selector select page elements using * exclude .exception elements along descendants (!). .exception element , descendants needs detain initial styles while * styles should applied other page elements. important: solution not if styles applied .exception , descendants first , need override initial values manually! i don't want apply styles .exception and/or descendants @ all! desired result please keep in mind trivial example. page need apply solution contains more elements i need generic solution filtering elements. manual selection , overriding elements wouldn't possible there. http://jsfiddle.net/zv5gf/2/ (initial state, no solution) solution :not selector - not perfect this solution not enough because exclude li.exception not exclude descendants. li.exception descendants initial styles lost. http://jsfiddle.net/zv5gf/3/ *:not(.exception){ background-color:orang...

Template engine disables PHP -

so build template engine, when parse files, disables php, make me unable sitename , stuff. parser (rlly lightweight) class template { public function __construct($directory) { $this->directory = $directory; } public function gettemplate($filename) { $file = "app/themes/" . $this->directory . "/" . $filename . ".php"; if(!file_exists($file)) { die("het opgevraagde bestand bestaat niet."); } else { $this->content = file_get_contents($file); echo $this->content; } } } does know way enable php again? way, i'm running on template: $core->getsitename please note isn't existing template engine. simply include page (instead of loading via file() etc.). if so, output buffer comes in handy well: public function gettemplate($filename) { $file = "app/themes/" . $this->directory . "/" . $filename . ".php"; if(!fi...

php - sub-domain masks with htaccess -

we have created yammer account , link our account link https://www.yammer.com/mydomain.org.uk/ i want hide word yammer.com , mask word social domain life this. social.mydomain.org.uk so if open social.mydomain.org.uk show https://www.yammer.com/mydomain.org.uk/ address masked social.mydomain.org.uk i'm not technical know how change dns , can upload htaccess file if can kindly tell me suppose write in file. you can't solve problem htaccess. one workaround install index.html html-frameset in it, points browser yammer.com/… (example here: http://www.quackit.com/html/templates/frames/frames_example_2.html , need adapt example little bit) caveat solution: can't copy deep url browser address bar , don't know if yammer.com permits solution.

Android - Is this possible to get android device's system configuration? -

i device's system configuration information including ram, rom, external memory, processor details in app running. begineer, please started? first of all, have @ these "build" class @ android-sdk page: http://developer.android.com/reference/android/os/build.html . // device model string phonemodel = android.os.build.model; // android version string androidversion = android.os.build.version.release; eg: public string getdevicename() { string manufacturer = build.manufacturer; string model = build.model; if (model.startswith(manufacturer)) { return capitalize(model); } else { return capitalize(manufacturer) + " " + model; } } private string getandroidversion() { return android.os.build.version.release; } private string capitalize(string s) { if (s == null || s.length() == 0) { return ""; } char first = s.charat(0); if (character.isuppercase(first)) { return s...

java - Unfortunately app stopped working in Android emulator -

this question has answer here: unfortunately myapp has stopped. how can solve this? 14 answers the ui portion alone worked fine, later when wrote onclicklistener , ran code got error stating "unfortunately app stopped working". i re-tried new project again getting these error. have attached xml, mainactivity class , logs well. kindly me out. have been stuck simple program whole week. :( log: 05-18 01:54:31.015: d/android :(1436): oncreate() event 05-18 01:54:31.015: d/androidruntime(1436): shutting down vm 05-18 01:54:31.015: w/dalvikvm(1436): threadid=1: thread exiting uncaught exception (group=0xb2afaba8) 05-18 01:54:31.055: e/androidruntime(1436): fatal exception: main 05-18 01:54:31.055: e/androidruntime(1436): process: com.example.test3, pid: 1436 05-18 01:54:31.055: e/androidruntime(1436): java.lang.runtimeexception: unab...

node.js - create nodejs chat on php web application -

i've heard nodejs best choice creating real-time chat application. decide try one. //on server side //create nodejs server var http = require('http'); var chatapp = http.createserver(function (request, response) { //create html chat form listened nodejs server response.writehead(200, {'content-type': 'text/html'}); response.write('<script src="http://localhost/nodejs/app/socket.io.js"></script><script src="http://localhost/nodejs/app/chat.client.js"></script><input type="text" id="message_input"><div id="chatlog"></div>'); response.end(); }).listen(8000); //create websocket protocol via socket.io var io = require('socket.io').listen(chatapp); //send data client io.sockets.on('connection', function(socket) { socket.on('message_to_server', function(data) { io.sockets.emit("message_to_client",{ ...

c# - Calling Method from Native dll works first time, instacrashes on second time (due to fortran modules)? -

i'm creating c# net4.5 console project consumes fortran dll. method dll works fine on first call, , instacrashes on second call, no error messages of sort. running tests, found if don't use module1, meaning put variable declaration on subroutine, works fine, on number of calls c# static void main(string[] args) { testmyarray();//works flawlesly testmyarray();//instakills program } private static void testmyarray() { console.writeline("start"); int size = 52; float[] myarray = new float[size]; sub_(ref size, myarray); console.writeline(myarray.select(x => x.tostring()).aggregate((x, y) => x + ";" + y)); console.readline(); } [dllimport("fortranarraysimpletest.dll", callingconvention = callingconvention.cdecl)] static extern void sub_(ref int size, float[] myarray); fortran !dec$ attributes dllexport::ingammaextern subroutine sub(size,...

php include function leaves my page blank -

when try include php menu and/or footer onto page, whole page shows blank. if take same code , put index.php html works fine. doing wrong? here's index page: <div id="navigation"> <?php include 'menu.php'; ?> </div> <div id="content"> <?php echo "hello world!"; ?> </div> <div id="footer"> <?php include 'footer.php'; ?> </div> ok , here's menu.php , footer.php pages: menu: <?php echo "<ul> <li><a href="index.php">main</a></li> <li><a href="info.php">php info</a></li> <li><a href="wda1.php">assignment 1</a></li> </ul>"; ?> footer: <?php echo "$filename = 'index.php'; if (file_exists($filename)) { echo "this page last modified: " . date ...

winapi - Using Powershell as COMSPEC -

i trying setup comspec powershell default interpreter. helps me handle situation if current directory unc applications being launched using system(..). have thirdparty tools support unix utilities under windows. 1 of them ls.exe. in testing, found system("ls -al") being picked powershell instead of thirdparty directory in path. there way can avoid using powershell alias through environment variable? or use custom alias redirecting thirdparty directory environment variable? or there way stop using alias powershell , use interpreter environment variable? -karthik the command get-item alias:ls show alias ls item of drive alias . remove item can use : remove-item alias:ls . now bit unix shell you've got concept of profle file can put command it's run prior shell execution. more information profile in windows powershell owner's manual .

ole - Clearquest Api C# Sort Order -

i having trouble sorting result set field using clearquest api in c#. trying follow this tutorial seems methods not same in c# clearquest api. if post example of how sort data set ascending field name great! edit: here's code example have tried: session cqsession = new session(); cqsession.userlogon("exampleuser", "examplepassword", "exampledb", 2, "ex_db_set"); oadquerydef querydef = (cqsession.buildquery("defect")) oadquerydef; // build fields of result set querydef.buildfield("id"); querydef.buildfield("state"); querydef.buildfield("headline"); querydef.buildfield("total_est_hrs"); // create filter operators ioadqueryfilternode filter1 = querydef.buildfilteroperator(and); ioadqueryfilternode filter2 = filter1.buildfilteroperator(and); ioadqueryfilternode filter3 = filter2.buildfilteroperator(and); // build filters filter1.buildfilter("state", equal, "opened...

vb.net - Context menu strip , text before image, not working -

Image
i have context menu strip in windows forms application. the problem can not set text before image. if change option settings, stays same. no matter try, image displayed before text. tried other options, not working either. "text above image, etc." i using visual studio 2012 . there bug in context menu strip? how can fix problem?

wpf - VS2013 - how do you add existing xaml+vb files to a new project? -

i want move big pile of code separate project , use framework came from.. , other stuff too. i started new vb.net wpf project , started adding files old project when added, wpf , associated vb file treated separate things. mean when add new wpf usercontrol file(or whatever), vb file gets nested in xaml file when adding existing, added side side. i'm not sure whether work or not, still lot add , little bit rewrite i'd start finish. there more appropriate way this? or if not how nest vb files xaml files? apparently need add files 1 one selecting xaml one, automatically adds .vb nested.

php - Can anyone help me capture an image, display it in imageView, store in gallery, upload that image to server? -

i want camera capture, image store in gallery, display in image view on screen , upload image server using php,json. have json parser code works. image gets saved as"temp" , gets overwritten(which don't want because want images in gallery) posting code below, please guide me. public class camactivity extends activity { private imageview img; int boundboxindp; private static final int camera_request = 1888; button bt1,bt2,btn; contentvalues values; int serverresponsecode = 0; progressdialog dialog = null; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_cam); string path = android.os.environment.getexternalstoragedirectory()+ file.separator + "sdcard" + file.separator + "sdcard"; img = (imageview)findviewbyid(r.id.imageview1);// assign imageview bitm...

Ctrlp Vim Plugin -

i using ctrlp plugin vim. reason though can access file search when type in :ctrlp, not when hit actual keys ctrlp. thoughts? don't have custom key mappings. here key mapping vim: n <nl> *@:call nerdtree#invokekeymap("<c-j>")<cr> n <c-k> *@:call nerdtree#invokekeymap("<c-k>")<cr> n <cr> *@:call nerdtree#invokekeymap('o')<cr> n ? *@:call nerdtree#invokekeymap("?")<cr> n *@:call nerdtree#invokekeymap("a")<cr> n b *@:call nerdtree#invokekeymap("b")<cr> n cd *@:call nerdtree#invokekeymap("cd")<cr> n c *@:call nerdtree#invokekeymap("c")<cr> n d *@:call nerdtree#invokekeymap("d")<cr> n f *@:call nerdtree#invokekeymap("f")<cr> n *@:call nerdtree#invokekeymap("i")<cr> n j ...

java - Generic method declaration from examlab -

abstract class typetest<k extends number> { public abstract <k> k useme(object k); //ok public abstract <k> typetest<? extends number> useme(typetest<? super k> k); //ok public abstract <k> typetest<? super number> useme(typetest<? extends k> k); //error public abstract <v extends k> typetest<v> useme(typetest<v> k); //ok } answer examlab declaration above ok,but found 3rd compiled error.and want know why,thanks! i found fine in eclipse compile error in editplus jdk1.7,i want confirm whether 3rd line declaration right. compile error info typetest.java:4: 错误: 类型参数? extends k#1不在类型变量k#2的范围内 public abstract <k> typetest<? super number> useme(typetest<? extends k> k); //error ^ 其中, k#1,k#2是类型变量: k#1扩展已在方法 <k#1>useme(typetest<? extends k#1>)中声明的object k#2扩展已在类 typetest中声明的number 1 个错误 请按...

sql - Atomically establish relation between records -

i'm developing e-commerce website delivers unique digital products (e.g. 40-digit codes). these digital products stored rows in stock table. when order placed, one unique digital product should assigned order. currently, i'm selecting oldest product (in first-in first-out manner), doing business logic (sending e-mail customer, etc.) , deleting record stock table. problem operation not atomic . e.g. if 2 orders placed @ same time, same code selected, e-mailed customer, , deleted (though second delete fail, ofcourse). leaves database in inconsistent state (from business perspective), because same unique digital product assigned 2 orders. how establish link between digital product table stock , order table order in consistent/atomic fashion? ps. i'm using mysql (myisam), i'm not fond of lack of referential integrity. plan on moving either innodb or postgresql in near future. therefore, i'd prefer technology-independent answer. add column stock ta...

ggplot2 - Plot summarized data using qplot in R -

Image
i cross-classify , plot bal using qplot facets: > str(bal) 'data.frame': 2096 obs. of 6 variables: $ fips : chr "24510" "24510" "24510" "24510" ... $ scc : chr "10100601" "10200601" "10200602" "30100699" ... $ pollutant: chr "pm25-pri" "pm25-pri" "pm25-pri" "pm25-pri" ... $ emissions: num 6.53 78.88 0.92 10.38 10.86 ... $ type : chr "point" "point" "point" "point" ... $ year : int 1999 1999 1999 1999 1999 1999 1999 1999 1999 1999 ... i'm interested in 2 classifiers year , type : > levels(factor(bal$year)) [1] "1999" "2002" "2005" "2008" > levels(factor(bal$type)) [1] "non-road" "nonpoint" "on-road" "point" i far, can plot distribution of emissions cross-classified year , typ...

Android upload/download text files from sdcard to Google Drive with Google Play Services -

i want implement google drive upload/download txt file android app using google play services, don't find right way it. in dropbox easy: file file = new file("working-draft.txt"); fileinputstream inputstream = new fileinputstream(file); entry response = mdbapi.putfile("/magnum-opus.txt", inputstream, file.length(), null, null); log.i("dbexamplelog", "the uploaded file's rev is: " + response.rev); but google drive google play services have not found simple way that. know how to? by way, use own credentials (google service account) instead user account, way implement google play services? thanks in advance take look here , you've mentioned. don't know 'simple' requirement, though. or go through official demo code here . not 'two-liner' endeavor.

fonts - Genericons work on testserver but not on real server -

the title on online-test-server genericons work -> http://panorama-publishing.de/s/ yet when copying site on actual server don't work -> http://contected.com/ thats can tell - it's literally 1:1 same site... yes, kaiser check odd one, on image tag string "_iphone" added images before extension(.png) , try remove- solved, ex: " http://www.contected.com/pics/me_de_iphone.png " - doesnot available. " http://www.contected.com/pics/me_de.png " - available.

android - UDP port 3526 Starquiz-port -

i installed linphone on galaxy s2 device , ran tcpdump on capture sip traffic linphone sending asterisk server. notice strange! sometime device sends special packet 3526 udp port asterisk server sip port (5060) contains: 0d0a0d0a asci: 13101310. wireshark resolves port starquiz-port(this name not useful because clients use ephemeral ports). searched net port , starquiz found nothing useful. useful information found this link @ iana .does knows packet , why phone sends asterisk? ps: in section 3.5.1 of rfc 5626 keep-alive using crlf mentioned connection oriented protocols: crlf keep-alive technique approach can used connection-oriented transports such tcp or sctp. client periodically sends double-crlf (the "ping") waits receive single crlf (the "pong"). if client not receive "pong" within appropriate amount of time, considers flow failed. you softphone can use port. that normal. softphone or asterisk(if...

c# - How to enable "update-all packages" button at nuget interface? -

Image
is there way enable "update all" button @ nuget screen? although can via package manager console, i'm pretty sure i've seen button before... there update all button available , enabled in updates section of nuget gui, seen in following screenshot:

ruby on rails - Add new column in user-database with controller of lecture -

i have little system users. user admin-rights can create new lecture. thats working. now want solve problem users can sign lectures. want add new column (boolean type) e.g. lecture1 in users database when create new lecture. can set variable true if user sign up. is idea or better have database (e.g. signupstatus) exercise_id, user_id. when there entry user has sign lecture. or have better idea? thanks :) the table better. never want create such columns( lecture1 ...) in user table, each new lecture added in system. imagine series of such columns [ lecture1 , lecture2 , lecture3 , lecturen ...] => totally unconventional , against design principles. what want simple many-to-many relationship. lecture can enrolled many users ; user can subscribe many lectures . you should follow this guide achieve it. create table - lectures_users , store lecture_id , user_id maintain relationship

ruby - why can I require gems which are outside from $LOAD_PATH -

i installed gem coffee-cup in rvm gem set, ruby-2.1.1@test path /users/dingxijin/.rvm/gems/ruby-2.1.1@test/gems/coffee-cup-0.0.4 . then open irb,just this: 2.1.1 :001 > puts $: /users/dingxijin/.rvm/rubies/ruby-2.1.1/lib/ruby/site_ruby/2.1.0 /users/dingxijin/.rvm/rubies/ruby-2.1.1/lib/ruby/site_ruby/2.1.0/x86_64-darwin12.0 /users/dingxijin/.rvm/rubies/ruby-2.1.1/lib/ruby/site_ruby /users/dingxijin/.rvm/rubies/ruby-2.1.1/lib/ruby/vendor_ruby/2.1.0 /users/dingxijin/.rvm/rubies/ruby-2.1.1/lib/ruby/vendor_ruby/2.1.0/x86_64-darwin12.0 /users/dingxijin/.rvm/rubies/ruby-2.1.1/lib/ruby/vendor_ruby /users/dingxijin/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0 /users/dingxijin/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin12.0 => nil 2.1.1 :002 > require "coffee-cup" nameerror: uninitialized constant coffeecup::rails /users/dingxijin/.rvm/gems/ruby-2.1.1@test/gems/coffee-cup-0.0.4/lib/coffee-cup/engine.rb:2:in `<module:coffeecup>' .......... does ruby ...

Wordpress Post pages -

i trying develop website using wordpress customizr theme. problem is, have post pages appear on customised page have created instead of front page. doesn't seems option in customizr theme me have post appear on page want them. please help. it easy. go dashboard. click settings-> reading. select radio button of "a static page (select below)". select font page want show font page , select posts page show post.

c - Reading multiple strings from a file using one fscanf -

so idea read file , put in fields of struct carro. thing is, when try printf structure variable ( dados[1].marca instance), doesn't show me in console. i can't see problem is, since fscanf returns 8 (8 read variables). the file i'm using list of cars, each line containing info specific model, , has following format: ford[]transit custom van 270l1 econetic base 2.2tdci h1[\t]2013[\t]3[\t]2[\n] (...) #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct { char marca[50]; char modelo[50]; char ano[5]; char lugares[5]; char portas[5]; }carro; main() { file *fp=null; carro dados[4700]; int i=0; fp=fopen("car.txt","r"); while (fscanf(fp,"%[^ ] %[^\t] %[^\t] %[^\t] %[^\n]", dados[i]. marca, dados[i].modelo, dados[i].ano, dados[i].lugares, dados[i].portas)!=eof); { i++; } fcl...

c++ - Base class with variadic template constructor wont copy-construct from derived class -

when compile code visual studio 2013 error: error c2664: 'std::array<int,10>::array(const std::array<int,10> &)' : cannot convert argument 1 'initializer-list' 'const std::array<int,10> &' i thought derived class staticaly cast (sliced) base class always, why doesn't work here? and thought work without explicit cast? #include <array> template <typename t> class { public: std::array<t, 10> data; template <typename... z> a(z... ts) : data({ ts... }) { } }; template <typename t> class b : public a<t> { public: template <typename... z> b(z... ts) : a<t>({ ts... }) { } }; int main() { b<int> w(1,4,3); a<int> g(w); //cant construct derived class a<int> h(static_vast< a<int> >(w)); //not cast a<int> j(4,5); a<int> t(j); //regular copy constructor works b<int> p(t); //works, can constr...

Just I am trying to implements simple Spring MVC projects then some kinds of error occoured in just like -

Image
my servlet-context.xml when make new project in spring mvc hello spring project:- we have got problem shown in given image please me how fix problem:- you forgot use context: . see spring docu <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:annotation-config/> </beans>

css - Editing the file input tag so it will look a certain way -

Image
this question has answer here: style button in upload type 2 answers i have file input button design (it second button says upload) how accomplish design in html using css , or javascript??? ok try out: html: <p class="form"> <input type="text" id="path" /> <label class="uploadfile">upload<span><input type="file" id="myfile" name="myfile" /></span> </label> </p> css: .form input[type="file"]{ z-index: 999; line-height: 0; font-size: 50px; position: absolute; opacity: 0; filter: alpha(opacity = 0);-ms-filter: "alpha(opacity=0)"; cursor: pointer; _cursor: hand; margin: 0; padding:0; left:0; } .uploadfile{ position:relative; overflow:hidden; cursor:poi...

double() function in c++ or not? -

i hava following c++ code #include <cstdlib> #include <iostream> #include <fstream> #include <time.h> #include <math.h> using namespace std; #define pi 3.1415926 int n; double* a,*b; double function(double); double a(int j) { double s=0; int ii; (int i=-n;i<n+1;i++) { s=s+function(2*pi*double(i)/(2*n+1))*cos(2*pi*double(j)*double(i)/(2*n+1)); } if (j==0) return 1/double(2*n+1)*s; return 2/double(2*n+1)*s; } and there isn't declared function double() , , looked function in math.h library , haven't found such. can explain it, lambda expression or delegate ? double(...) thought of way of saying (double)(...) . recall when have class constructor takes parameters can write myclass(params) and produce instance of myclass . c++ standard expanded same syntax primitive types well. syntax shorter cast, because not require parentheses around double † . note: in program above explicit...

c++ RAII destructor exception -

as far understand raii refers acquire resources in ctor , release them in dtor. ctor acquires resources , can fail, resulting in exception. dtor releases resources , can fail, exception dtors foobar no exception. class { a() throw(ex) { // acquire resources } ~a() throw() { // release resources } } so if user of class should made aware of error happening in a´s uninitialisation can outsource uninitialisation function throws, called dtor swallows exceptions: class { a() throw(ex) { // acquire resources } ~a() throw() { try {release(); } catch(...) {} } void release() throw(ex) { // release resources } } that way user can call exit() if wants feedback release-error or ignore letting dtor it´s job when goes out of scope (e.g. other exception occurs used). to prevent multiple executions of exit() (first explicitly user, later indirect dtor) have add init-status: class { bool init; a() throw(ex) { init = true; // acquire resources } ~a() throw() { try {rel...

gawk - awk: –f awk: ^ invalid char '�' in expression -

hi have following awk program problem don't know why complains "awk: –f awk: ^ invalid char '�' in expression" when awk -f pdf.awk aodv1.tr anyone of out there brighter me in area? =) begin { recvdsize = 0 starttime = 400 stoptime = 0 } { event = $1 time = $265.01 node_id = $29 pkt_size = $8 level = $4 if (level == "agt" && event == "s" && pkt_size >= 512) { if (time < starttime) { starttime = time } } if (level == "agt" && event == "r" && pkt_size >= 512) { if (time > stoptime) { stoptime = time } hdr_size = pkt_size % 512 pkt_size -= hdr_size recvdsize += pkt_size } } end { printf("average throughput[kbps] = %.2f\t\t starttime=%.2f\tstoptime=%.2f\n",(recvdsize/(stoptime-starttime))*(8/1000),starttime,stoptime) } didn...

java - Listing all the combinations of the elements of a set -

among elements of set, want list 3-combinations of set. there way it? if list; for(int i=0; i<list.size()-2; i++) for(int j=i+1; j<list.size()-1; j++) for(int k=j+1; k<list.size(); k++) system.out.println(list.get(i) + " " + list.get(j) + " " + list.get(k)); but how set without converting list? converting list , using logic code first choice. if want without converting list, can iterators, this: set<string> set = ...; (string : set) { boolean bgo = false; (string b : set) { if (bgo) { boolean cgo = false; (string c : set) { if (cgo) { system.out.println(a + " " + b + " " + c); } else if (b.equals(c)) { cgo = true; } } } else if (a.equals(b)) { bgo = true; } } } the logic above freely iterates set in outer loop. when ...

c++ - MFC can't find GetDocument() in a Dialog -

i'm new mfc,and want data in dialog,but doesn't work, ctestdoc* pdoc=getdocument(); pdoc->get(...); i google , find getdocument() used in cview. try , works: cmainframe *pmain=(cmainframe *)afxgetapp()->m_pmainwnd; ctestview *pview=(ctestview *)pmain->getactiveview(); m_name=pview->v_name; but don't think it's solution,so want know there functions solve this?thank you. you didn't dialog may desirable pass data dialog, , not have dialog access document data directly. helps keep dialog more isolated , more usable in other programs. i @ command dialog displayed. in view? if so, can pass document data needed dialog. if not, code posted may still make sense. either way, that's should locate desired document information, , pass dialog. i avoid making dialog directly aware of document if it's not necessary.

c# - Adjust label fontsize -

i adjust label content dynamically; when text bigger adjust label fontsize fit in label space. <label name="lblresult" content="0" margin="0,-1,-222,0" verticalalignment="top" horizontalcontentalignment="right" verticalcontentalignment="bottom" fontfamily="helvetica neue" foreground="white" background="black" height="87" fontsize="63" rendertransformorigin="0.5,0.5" padding="9" contentstringformat="{}{0:#,0}" fontweight="light" cliptobounds="true" /> thank you the wpf viewbox control grow / shrink contents available space: http://www.wpftutorial.net/viewbox.html just place label within viewbox: <viewbox stretch="uniform"> <label name="lblresult" content="moez rebai" verticalalignment="top" horizontalcontentalignmen...

derby - Java DB Database, check for all table names -

i've got embedded derby database in java application, , have multiple table's (that created , deleted, nothing set in stone). wanted able return list of names of tables in database have display list in application information them. easiest way so? don't need code method or methods. i'm terrible google-fu user. currently code works grabbing resultset specific table name entered, it's testing purposes , need able display full list of tables have. edit: current workaround different posted. have table holds table names created , updates when 1 created/deleted. not best approach works me right now. databasemetadata metadata = connection.getmetadata(); resultset resultset = metadata.gettables(null, "schenaname", "%" ,new string[] {"table"} ); while (resultset.next()) { system.out.println(resultset.getstring(3)); } adding new answer: connection connection = getdbconnection(); databasemetadata dbmetadata =...

Jquery: Enable one form field and disable other when checkbox is clicked -

i looking better solution achieve subject. when checkbox clicked, disable select box , enable input field , vise versa. code <div class="col-md-4 col-lg-4"> <select class="form-control recipe_cats otherrecipe_cat" id="recipe_cats" name="recipe_cats"> <option value="-1">books category</option> <option value="30" class="level-0">book1</option> <option value="48" class="level-0">book2</option> <option value="49" class="level-0">book3</option> </select> </div> <div class="col-md-3 col-lg-3"> <label class="control-label checkbox-inline" for="lblothercats">not listed</label> <sup><i class="fa fa-asterisk"></i></sup> <input class="form-control" type="checkbox...

amazon ec2 - how to limit instance launch by instance type in AWS using IAM service -

i using policy limit runistances specific instance types , specific region. when run launch wizard or simulation under test user getting "implicitly denied" error. here policy: { "version": "2012-10-17", "statement": [ { "effect": "allow", "action": "ec2:runinstances", "resource": [ "arn:aws:ec2:us-east-1::instance/*" ], "condition": { "stringequals": { "ec2:instancetype": [ "t1.micro", "m1.small" ] } } }, { "effect": "allow", "action": "ec2:runinstances", "resource": [ "arn:aws:ec2:us-east-1::image/ami-*", "arn:aws:ec2:us-east-1::subnet/*", "arn:aws:ec2:us-east-1::network-interface/*", ...

php - remove commas from a string, and also print code for each word before and after the comma -

hopefully question title makes sense. just wondering if possible data record in mysql, remove commas , print each item individually? i have column called tags, , example in 1 of records tags "rock,bass,alternative" what want remove commas , print html code <a href ="/tag name"> before , </a> after each individual tag. so far code : $id = $_get['id']; $station = mysql_query ( "select * `stations` `id` = '$id'" ); $sta = mysql_fetch_object ( $station ); <? echo "$sta->tags";?> explode on , , giving array, print each item , concatenate string encapsulstaion. $tags = explode(',', $sta->tags); foreach($tags $tag): echo "$tag"; endforeach;

c++ - Arduinosumo bot with rotatory motor -

i making sumo bot project using arduino. have no experience arduino code, have java experience. said bot has edge detector prevent falling off, l298 driver, , forth. lack of experience, don't know how arduino's code works methods , etc. said, main question how executing methods delays? getting stuck in methods no return? not entering? executing ending later? seems run motors forward without switch on or off. have checked wiring. ( apologize poor questioning- stackedoverflow virgin). int motor_forward = 10; int motor_reverse = 9; int motor2_forward = 13; int motor2_reverse = 12; int edgedec1 = 7; //int edgedec2 = 6; //the setup routine runs once when press reset; void setup(){ //initialize digital pin output. pinmode(motor_forward, output); pinmode(motor_reverse,output); pinmode(motor2_forward,output); pinmode(motor2_reverse,output); pinmode(edgedec1,input); } //the loop routine runs on , on again forever void loop(){ int indicator = random(2); delay(50...

iphone - Prevent installation of iOS app in jail broken devices -

i want prevent installation of ios app in jail broken devices. there checks can done during installation identitfy if device jail broken ? there way stop installation if device jail broken? generally, break down 2 questions: 1) detection of jailbreak device. there plenty of different methods. none of them 100% guaranteed work. @ question: how detect ios app running on jailbroken phone? 2) taking actions on jailbroken device as @paulw11 mentioned, can't stop installation , can't uninstall. the common way exit application (don't provide useful functionality user). however, if application have high value, protection can removed reverse engineer application. generally speaking, there no bulletproof protection, can make enough, won't worthwhile breaking it.

makefile - How to run Linux shell commands from GNU make file to setup preconditions for a build target -

my issue in make file want create directory object code before building , cannot find way whithout having impact output of make. also, want in 1 place , not each , every object file. i have tried this: build: setup exe.i686 setup: mkdir -p obj exe.i686: $(objs) @echo 'building target: $@' @echo 'invoking: gcc c++ linker' ${gcc_location}/linux/i686/bin/i686-pc-linux-gnu-g++ $(objs) -o "exe.i686" -l... @echo 'finished building target: $@' @echo ' ' where objs object code. if don't run setup first , there no ./obj directory present build fail because of missing directory when trying build object code. just clear, here example of how 1 object file built: ./obj/cell.o: ${cell_root}/main/cell/cell/src/cell.cc @echo 'building file: $<' @echo 'invoking: gcc c++ compiler' $(gcc_c++_build) -mf"$(@:%.o=%.d)" -mt"$(@:%.o=%.d)" -o "$@" "$<"...