Posts

Showing posts from July, 2011

javascript - Using Bootstrap Nav option I need to exclude the end item from Hover -

my menu created bootstrap nav menu script. works fine except need not include last item want use button click event. code below shows how menu set out in index.html file. <body> <div class="row"> <nav class="navbar"> <div class="col-md-offset-2 col-md-8"> <div class="logo col-md-1"> <img src="images/logo.png" /> </div> <div> <ul class="nav navbar-nav navbar-right menu"> <li class="dropdown"> <a href="#" class="dropdown-toggle">home<span style="color:#ff6633; padding:5px;" class="glyphicon glyphicon-menu-down" /></a> <ul style="background-color:#383838" class="dropdown-menu"> <li>&l

perl - Trouble in installing Font::TTF module -

i failed install module through cpan font::ttf . i'm on strawberry perl 5.24, windows 8 32bit. c:\users\user>cpan loading internal null logger. install log::log4perl logging messages there seems running cpan process (pid 5860). contacting... other job not responding. shall overwrite lockfile 'c:\strawb~1\cpan\.lock '? (y/n) [y] cpan shell -- cpan exploration , modules installation (v2.11) enter 'h' help. cpan> o conf build_dir_reuse 0 build_dir_reuse [0] commit: wrote 'c:\strawberry\perl\lib/cpan/config.pm' cpan> o conf commit commit: wrote 'c:\strawberry\perl\lib/cpan/config.pm' cpan> exit lockfile removed. c:\users\user>cpan font::ttf loading internal null logger. install log::log4perl logging messages cpan: cpan::sqlite loaded ok (v0.211) database generated on fri, 15 jul 2016 06:47:48 gmt running install module 'font::ttf' cpan: digest::sha loaded ok (v5.95) cpan: compress::zlib loaded ok (v2.069)

mongodb - Meteor + existing mongo : Data added through GUI not visible in database -

i'm trying use existing mongo instance meteor app (example simple-todos app form submission). simple-todos.html <head> <title>todo list</title> </head> <body> <div class="container"> <header> <h1>todo list</h1> <form class="new-task"> <input type="text" name="text" placeholder="type add new tasks" /> </form> </header> <ul> {{#each tasks}} {{> task}} {{/each}} </ul> </div> </body> <template name="task"> <li>{{text}}</li> </template> simple-todos.js tasks = new mongo.collection("tasks"); if (meteor.isclient) { // code runs on client meteor.subscribe("tasks-broadcast"); template.body.helpers({ tasks: function(){ return tasks.find(); } }); template.body.events({

c# - How do I wrap a text in SQL Server database? -

Image
as shown in photo, cell in datagridview contains 2 lines , when insert database doesn't wrap. checked wrap option in tools --> options --> test editor --> language --> word wrap. word wrap still not working. can see wrapped line in datagridview becomes 1 line in database. idea in how can wrap line? i used code insert data datagridview sql server database: private void button9_click(object sender, eventargs e) { sqlconnection cn = new sqlconnection("data source=pcn-tosh;initial catalog=mydb;integrated security=true"); cn.open(); sqlcommand cm = new sqlcommand("insert customer(qty, des, price) values ('" + datagridview1.rows[0].cells[0].value + "', '" + datagridview1.rows[0].cells[1].value + "','" + datagridview1.rows[0].cells[2].value + "')"); cm.connection = cn; cm.executenonquery(); cn.close(); }

gpgpu - OpenACC - How to find if device is busy doing some CUDA operations? -

i have cuda-based code , want incorporate openacc parts of code. but, function trying parallelize openacc code governed cuda calls , not. my question how can query openacc library see whether device busy or not. there api calls that? note: not familiar cuda, use pseudo-code. sometimes target function seq_function called on host when device busy computation below. but, called when device not busy. cudamemalloc(...); cudalaunchasync(...); ... //this function trying parallelize openacc seq_function(...); ... cudawait(...); cudadealloc(...); so, want make target function flexible: if device busy or cuda-based computation running => use host. if device not busy => use gpu through openacc-enabled code. is there way find whether device busy or not? i don't know of way programmatically device utilization. can memory usage via cudamemgetinfo might able use extrapolate if running on gpu or not.

CSS - Footer image not resizing correctly when browser viewport changes -

i have mvc app image in footer. css looks follows: footer { position:absolute; bottom:-150px; /* puts footer 100px below bottom of page*/ width:70%; height: 170px; /* height of footer */ background-image: url("/images/footer/footer3.png"); background-repeat: no-repeat; background-position: center; } the problem have image not being resized correctly fit within width , height of container. parts of image cut off. , when resize browser viewport (shrink it), more of image cut off. image size 1000x175 if helps. image responsive , auto resized correctly within container. did try background-size: 100% 100%;

r - Subset by group with data.table -

assume have data table containing baseball players: library(plyr) library(data.table) bdt <- as.data.table(baseball) for each player (given id), want find row corresponding year in played games. straightforward in plyr: ddply(baseball, "id", subset, g == max(g)) what's equivalent code data.table? i tried: setkey(bdt, "id") bdt[g == max(g)] # 1 row bdt[g == max(g), = id] # error: 'by' or 'keyby' supplied not j bdt[, .sd[g == max(g)]] # 1 row this works: bdt[, .sd[g == max(g)], = id] but it's 30% faster plyr, suggesting it's not idiomatic. here's fast data.table way: bdt[bdt[, .i[g == max(g)], = id]$v1] this avoids constructing .sd , bottleneck in expressions. edit: actually, main reason op slow not has .sd in it, fact uses in particular way - calling [.data.table , @ moment has huge overhead, running in loop (when 1 by ) accumulates large penalty.

c++ - Delete all the last node of linked list which have value = 0 -

i have linked list this: 1 0 1 2 0 0 0 . want delete last "0" node list can like: 1 0 1 2 . tried using recursion: node *trimtlist(node* head) { if (head->next->data == 0 && head->next->next == null) { head->next = null; return head; } trimlist(head->next); return head; } i realize method delete last 0, not last 0... node *trimtlist(node* head) { if (head && !trimtlist(head->next) && head->data == 0) { delete head; head = nullptr; } return head; } int main() { list a; a.head= new node(1); a.head->next = new node(0); a.head->next->next = new node(2); a.head->next->next->next = new node(0); a.head->next->next->next->next = new node(0); a.head= trimtlist(a.head); cout << << endl; } the output 1 0 2 2 , windows has stop working... it should like: node *trimlist(node* head) {

r - How to select data from dataframe and create a subdataset? -

i have 2 dataframe in r. "x" dataframe has 2 columns (number of identity[id] of animal "i" in 1st, , in 2nd col. point related of animal "i"), , "n"-rows number of animals scored. "y" dataframe has 2 col. x (id of animal "i" in 1st col. , in 2nd col. point related animal "i" in same row, caracther studied). not animals have both evaluations, of them. take sub-dataframe animals have both evaluations. use id recognize animals have both evaluations. subdaframe make composed 3 columns: id of "i" animal (in 1st c.), point in dataframe x (in 2nd c.), , point in dataframe y animal "i" (in 3rd c.). i'm quite new in r , search on web. found "merge" it's seems not work. me? in advance. i found answer. did subdataframe of each dataframe 4° , 11° column, , used script: a=merge(x,y,by.x="v4",by.x="v4")

express - Mongoose error when running node -

when run node server.js in terminal, receive following error mongoose: /users/xxxx/desktop/projects/crud/node_modules/mongoose/node_modules/mongodb/lib/server.js:235 process.nexttick(function() { throw err; }) ^ error: connect econnrefused 127.0.0.1:27017 @ object.exports._errnoexception (util.js:860:11) @ exports._exceptionwithhostport (util.js:883:20) @ tcpconnectwrap.afterconnect [as oncomplete] (net.js:1063:14) i've ran npm install mongoose warning, doubt that's reason mongodb database isn't running. here warning: > kerberos@0.0.17 install /users/sean/desktop/projects/crud/node_modules/kerberos > (node-gyp rebuild) || (exit 0) cxx(target) release/obj.target/kerberos/lib/kerberos.o cxx(target) release/obj.target/kerberos/lib/worker.o cc(target) release/obj.target/kerberos/lib/kerberosgss.o ../lib/kerberosgss.c:509:13: warning: implicit declaration of function 'gss_acquire_cred_impersonat

solrj - Solr - retrieve documents in the same order as the IDs provided in the query -

i'm using apache solr 4.7.2. i need implement following behavior: user provides list of ids , solr returns documents paginated , ordered same order user informed ids. i came across boost terms approach. if user provides ids "2875141 2873071 2875198 108142 2918841 2870688 107920 2870637 2870636 2870635 2918792 107721 2875078 2875166 2875151 2918829 2918808", solr query be: studentid:(2875141^16 2873071^15 2875198^14 108142^13 2918841^12 2870688^11 107920^10 2870637^9 2870636^8 2870635^7 2918792^6 107721^5 2875078^4 2875166^3 2875151^2 2918829^2 2918808^1) but approach not working. example specifically, can see @ explain query , highest score isn't ^16 . if use big boost values such 1, 10, 100, 1000, 10000 , on, adding 1 0 @ end, suggested in cookbook , ordering works fine. issue if user searches 200 items instance, query long causing communication issues. is there other approach achieve this? if not, use multiplication or exponencial operations in or

Does Apache Thrift TSimpleServer drop requests? -

i doing research, , sending requests @ high rate (100 requests per second) apache python tsimpleserver . notice client side says 353 requests sent server, @ end of day, server receives 345 requests. have idea on goes wrong? cannot use tthreadedserver because underlying library not thread-safe, , wonder whether tsimpleserver drops requests @ high rps. lot! i figured our. since function declared oneway , client has open transport rather close after function call.

javascript - How to customize an extension in medium editor? -

i'd change "anchor" extension button label use unicode symbol browser link - (u+1f517). don't want install fontawesome. to need way either modify extension or subclass it. suggestions? in case looking simple way override the content of of built-in mediumeditor buttons, can specify properties during initialization of mediumeditor object. button text, you'd want override defaultcontent property of button, accepts block of html: var editor = new mediumeditor('.editable', { toolbar: { buttons: ['bold', 'italic', 'underline', { name: 'anchor', defaultcontent: '<i>my unicode char</i>' } ] } }); you can find more examples of simple button properties can overriden in fashion in button options section of mediumeditor readme. includes ability add custom classes or additional attributes button element.

c++ - Passing 2D array and vector of string as argument to function -

i have written 2 function in passing vector of string particular function (printstringvector) print content , in second function, passing array of pointers print content.the first function working fine second 1 giving error below code. #include <cmath> #include <stdlib.h> #include <cstdio> #include <string> #include <vector> #include <iostream> #include <algorithm> using namespace std; int n; void printstringvector(vector<string> & v){ for(int i=0;i<v.size();i++){ cout<<v[i]<<endl;} } void printstringarray(const char *arr[n]){ for(int i=0;i<n;i++){ cout<<arr[i]<<endl;} } int main() { vector<string> vec; cin>>n; const char *arr[n]; for(int i=0;i<n;i++){ string str; cin>>str; vec.push_back(str); arr[i]=str.c_str(); } printstringvector(vec); printstringarray(arr); return 0;

c++ - Explicit friend specialization of template function in class template -

i'm facing situation arise 2 questions how adl , template function specialization works under circumstances. why can't use cout inside friend specialization definition? in scenario i'm getting link error stating basic_stream undefined, if switch call cat compilation proceed. template<class t> void func1(t&){ ... } void cat(){ cout << "foo.func1" <<endl; } namespace first{ template<class r> struct foo{ friend void func1<>(foo<int>&){ cout << "foo.func1" <<endl; // cat(); } }; } foo<int> f; func1(f); why adl doesn't apply when change specialization refer template class param? if i'm not wrong adl mechanic, in order resolve right version of func1 call in 3 (e.g. global(1), or friend defined one(2)) collects possible matches , selects concrete one. and, think concrete 1 version of func1 in 2, because instead of s

json - JSONException occurred during parsing -

Image
i have follow map: { errors=[], warnings=[], items=[{ itemkey=3806, errors=[], warnings=[<span style="color: #000;">der titel ist im unternehmen bereits vorhanden.</span>] }], surchargeitems=[{ parentconfigurationkey=3806, surchargedescription=logistikkosten, surchargeprice=1.00, surchargecurrencyid=eur}] } and during calling method parse of grails.converters.json class have follow exception: org.codehaus.groovy.grails.web.json.jsonexception: expected ',' or ']' @ character 79 of {errors=[], warnings=[], items=[{itemkey=3806, errors=[], warnings=[ how can parse html json contains? thx! json grails groovy share | improve question edited jul 19 '16 @ 13:57 asked jul 15 '16 @ 18:47

javascript - How to move an object diagonally and in zigzag? -

i created algorithm move particle diagonally , works fine using angle. basically, do: this.x += this.speed * math.cos(this.angle * math.pi / 180); this.y += this.speed * math.sin(this.angle * math.pi / 180); this.draw(); how can combine zigzag movement? i recommend calculating lateral deviation normal path or amplitude given by // triangle wave @ position t period p: function amplitude(t, p) { t %= p; return t > p * 0.25 ? t < p * 0.75 ? p * 0.5 - t : t - p : t; } where t set length of traveled path, , p period of 'zigzag' triangle wave pattern. given amplitude , previous position, can compute next position moving ahead described original code , adding lateral deviation our position: var amplitude = amplitude(distance, p) - this.amplitude(previous_distance, p); this.x += amplitude * math.sin(this.angle * math.pi/180); this.y -= amplitude * math.cos(this.angle * math.pi/180); a complete example 2 movable objects, 1 moving 'normal

How to reverse array in Swift without using ".reverse()"? -

i have array , need reverse without array.reverse method, for loop. var names:[string] = ["apple", "microsoft", "sony", "lenovo", "asus"] here @abhinav 's answer translated swift 2.2 : var names: [string] = ["apple", "microsoft", "sony", "lenovo", "asus"] var reversednames = [string]() arrayindex in (names.count - 1).stride(through: 0, by: -1) { reversednames.append(names[arrayindex]) } using code shouldn't give errors or warnings use deprecated of c-style for-loops or use of -- . swift 3: var names: [string] = ["apple", "microsoft", "sony", "lenovo", "asus"] var reversednames = [string]() arrayindex in stride(from: names.count - 1, through: 0, by: -1) { reversednames.append(names[arrayindex]) } alternatively, loop through , subtract each time: var names: [string] = ["apple", &qu

objective c - CABasicAnimation progress with variable speed -

i need calculate progress of cabasicanimation @ time t in order update progress view. when progress linear, calculate elapsed time @ each time (thanks https://stackoverflow.com/a/20993376/2268168 ). the thing is, animation not linear, speed variable. speed up mylayer.timeoffset = [mylayer converttime:cacurrentmediatime() fromlayer:nil]; mylayer.begintime = cacurrentmediatime(); mylayer.speed=2; speed = 2; slow down mylayer.timeoffset = [mylayer converttime:cacurrentmediatime() fromlayer:nil]; mylayer.begintime = cacurrentmediatime(); mylayer.speed=0.5; speed = 0.5; how can calculate progress of animation taking account variable speed ? i tried this, seems work when speed increases once. cftimeinterval elapsedtime = (cacurrentmediatime() - animation.begintime); cftimeinterval remainingtime = (totalduration - elapsedtime)/speed; speed = 1; totalduration = remainingtime+elapsedtime; float progress = (totalduration-remainingtime)/totalduration; am doing wrong ?

java - Data Entry in List Error Spring -

error creating bean name 'sumitgulati' defined in class path resource [springmodule.xml]: error setting property values; nested exception org.springframework.beans.notwritablepropertyexception: invalid property 'lists' of bean class spring.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id="sumitgulati" class="com.spring.first.listclass"> <!-- java.util.list --> <property name="lists"> <list> <value>1</value> <value>2</value> </list> </property> </bean> </beans> listclass.java package com.spring.first; import java.util.arraylist; import java.util.list; public class list

database - "Missing Keyword" When creating a table in Oracle SQL Developer -

i keep getting "sql error: ora - 00905: missing keyword" in "create table" portions of code shown below: create table orders ( received char(9), shipped char(9), foreign key (ono), references odetails (ono), foreign key (cno), references customers (cno), foreign key (eno), references employee (eno), primary key (ono, cno, eno) ); create table zipcodes ( zip char(5) not null, city char(20), foreign key (zip), references customers (zip), primary key (zip) ); however, wrote code in same worksheet , did not errors ever: create table odetails ( ono char(4) not null, pno char(5) not null, qty char(1), foreign key (pno), references parts (pno), primary key (ono) ); can me identify causing error? 1) not use comma 2) define columns create table orders ( received char(9), shipped char(9), ono int not null , -- missing columns (add datatype nee

javascript - capture MyScript Katex annotation encoding field for use elsewhere -

i new myscript , katex may dumb question. apologise if is. playing around idea, call newapp. want users able write formulae onto screen, myscript convert katex , display user can confirm understood correctly , send result newapp. in order check user's response in newapp i'm thinking best way send katex annotation encoding newapp think need doing through javascript don't know how pick katex. html katex following, depending on equation entered. <div id="resultfield" class="style-scope myscript-math-web"> <span class="katex"> <span class="katex-mathml"> <math> <semantics> <mrow> <mfrac> <mrow> <mn>2</mn> <mn>1</mn> <mo>−</mo> <mn>3</mn> <mn>5</mn> </mrow> <mrow> <mn>1</mn> <mn>3</mn>

physics - How to apply Marshall Palmer function at ID level in R? -

i'm analyzing dual-polarization radar data , want add result of marshall palmer relation id-level variable in my data . there's no cran function can find, r user has script wherein applies relation estimate of expected value in data: # troy w. (thanks!) # few small changes hack-r ## better in r me clean up/refactor code bit. library(dplyr) library(data.table) test <- fread('../input/test.csv') mpalmer <- function(ref, minutes_past) { # order reflectivity values , minutes_past sort_min_index = order(minutes_past) minutes_past <- minutes_past[sort_min_index] ref <- ref[sort_min_index] # calculate length of time each reflectivity value valid valid_time <- rep(0, length(minutes_past)) valid_time[1] <- minutes_past[1] if (length(valid_time) > 1) { (i in seq(2, length(minutes_past))) { valid_time[i] <- minutes_past[i] - minutes_past[i-1] } valid_time[length(valid_time)] = valid_time[length(valid_time)]

How do I create a list to store strings in java applet -

i trying create list holds strings inputted user. i'm not sure if code below right way create string, however, created list of strings, string called x assigned textf retrieve user input nothing happens when press button. wanted make sure code below right way add user input secret stored list when press button "b1" import java.applet.*; import java.awt.event.*; import java.awt.*; import java.util.arraylist; import java.util.list; public class test 1 extends applet implements actionlistener { list<string> wordlist = new arraylist <string>(); font fonttext; textfield textf; string x; button b1; button b2; button b3; button b4; button b5; button b6; public void init(){ setbackground(color.lightgray); fonttext = new font("times new roman", font.bold, 24); textf = new textfield("", 40); add(textf); b1 = new button ("add word list"); b2 = new button ("display words list letter"); b3 =

mysql automatically create 3 records in table when user creates 1 in another table -

i have table user enters records (table1) : table1 id name date desc amt 1 fred 11/30/2015 bridge 123 2 fred 11/30/2015 tunnel 234 i need parse through table1 , create 3 records in table2 (or if name/date/desc there, update amt field) : table2 id name date desc sortorder amt 3 fred 11/30/2015 bridge 1 123 4 fred 11/30/2015 bridge 2 123 5 fred 11/30/2015 bridge 3 123 6 fred 11/30/2015 tunnel 1 234 7 fred 11/30/2015 tunnel 2 234 8 fred 11/30/2015 tunnel 3 234 id in each table ai key. name , date indexed , foreign keys. efficient way this? thanks! you insert records as: insert table2(name, date, desc, sortorder amt) select t1.name, t1.date, t1.desc, n.n, t1.amt table1 t1 cross join (select 1 n union select 2 union select 3) n on duplicate key update amt = values(amt);

java - ImageJ no error messages for plugin development -

i'm using imagej image processing class, , i've been creating small plugins few weeks. it's been frustrating me because never saw java error messages, such syntax error on line 3 blah blah. when plugins don't compile (due compile time error), see "class not found", or if plugin had compiled in past , there class file available run old compiled version , not give me error. i thought normal until met friend , had been getting error messages whole time. any idea why is? i'm using windows (tried on windows 10, 8, , 7), he's using osx distribution (most latest). i've tried available versions of imagej website, don't think it's version issue. norm on windows reason? i suspect using imagej 1.x, e.g. downloaded here? , trying compile via plugins>compile , run... ? in general, recommend developing java code in eclipse - having proper ide vastly more powerful can in imagej. if need write simple macros calling existing

sql - How to write ROW_NUMBER in Crystal Reports? -

i wondering if can use row_number in formula in crystal reports? here part code wrote in ssms sql. row_number() on (partition bedside_ua_csn order ua_time) "session_number" any valid sql can used in crystal reports. there 2 ways can use. first way can directly use add commnad while creating database connection. second way can write in sql expression fields inside reports in way need enclose sql inside ()

regex - Why does grep show me different output depending on my input file size? -

i'm little puzzled output of grep command, seems truncating results based on size of -f file . instance, consider 1000-line file of strings, patterns.txt , e.g.: adkgjwofjdjglkadjglkjasdfahdg dsklfjsldkfjaghwioeghsdlkjfld sdkljfsdkljghsdlfhkwhfklshdfo ... sdklfjsdklfjsdklfjslkjghdfkjj and 1gb queryfile.txt search patterns. when run grep -f -o -f patterns.txt queryfile.txt | grep -c adkgjwofjdjglkadjglkjasdfahdg in case, command reports 0 matches 1st line, ( adkgjwofjdjglkadjglkjasdfahdg ) of patterns.txt , though there 35 occurrences in queryfile.txt . verified reducing patterns.txt file first 10 lines. rerunning grep -f -o -f patterns_reduced-list.txt queryfile.txt | grep -c adkgjwofjdjglkadjglkjasdfahdg properly reports 35 occurrences of adkgjwofjdjglkadjglkjasdfahdg . what's happening? this shouldn't happen unless... patterns overlap . check example: echo "xyxx" | grep -o -f yx$'\n'xy # output: xy this finds second

ios - MFMessageComposeViewController cancel button not working -

i use block send message contacts, after sending, button there, when touch nothing happens. please me out :) -(ibaction) inviteit:(id) sender{ if ([mfmessagecomposeviewcontroller cansendtext]) { mfmessagecomposeviewcontroller *messagecomposer = [[mfmessagecomposeviewcontroller alloc] init]; messagecomposer.messagecomposedelegate = self; nsstring *message = @"you have more body buddies think at: http://www.itunes.com/app/joychain "; [messagecomposer setbody:message]; messagecomposer.recipients = [nsarray arraywithobjects:_itsnum, nil]; messagecomposer.messagecomposedelegate = self; [self presentviewcontroller:messagecomposer animated:yes completion:nil]; } } did forget implement mailcomposecontroller:didfinishwithresult: ?... - (void) mailcomposecontroller:(mfmailcomposeviewcontroller *)controller didfinishwithresult:(mfmailcomposeresult)result error:(nserror *)error { switch (res

c# - How to get data from every single cell? -

i'm doing app friend works in hospital. what app doing grab data excel, sort , display it. stuck on grabbing data. excel file has 3 columns , n rows. cells of first column not filled in. i have tried different ways of taking data, , wasn't able make working right. trying include empty cells search, temp returns me empty strings. how iterate each row until end, , on every iteration grab data each column, if empty - return ""? excel.application excelapp = new microsoft.office.interop.excel.application(); excel.workbook excelworkbook = excelapp.workbooks.open(currentexcellocation, 0, true, 5, "", "", false, excel.xlplatform.xlwindows, "", false, true, 0, false, false, false); excel.sheets excelsheets = excelworkbook.worksheets; excel.worksheet excelworksheet = (excel.worksheet)excelsheets.get_item(3);