Posts

Showing posts from February, 2013

Opencv 2.4.11 windows 8 visual stuido 2012 professional The application was unable to start correctly (0xc00007b) -

i follow tutorial on http://docs.opencv.org/doc/tutorials/introduction/windows_visual_studio_opencv/windows_visual_studio_opencv.html#windows-visual-studio-how-to and set project property --> c/c++ directory c:\opencv\build\include and linker--> additonal library directory c:\opencv\build\x64\vc12\lib linker --> input : opencv_calib3d2411d.lib opencv_contrib2411d.lib opencv_core2411d.lib opencv_features2d2411d.lib opencv_flann2411d.lib opencv_gpu2411d.lib opencv_highgui2411d.lib opencv_imgproc2411d.lib opencv_legacy2411d.lib opencv_ml2411d.lib opencv_nonfree2411d.lib opencv_objdetect2411d.lib opencv_ocl2411d.lib opencv_photo2411d.lib opencv_stitching2411d.lib opencv_superres2411d.lib opencv_ts2411d.lib opencv_video2411d.lib opencv_videostab2411d.lib and use test code here http://docs.opencv.org/_downloads/introduction_windows_vs.cpp it built successully when run say: application unable start correctly (0xc00007b)

matlab - Integrating Velocity Over a Complex 2-D Surface -

i'm using matlab calculate the average velocity in cross section of pipe integrating discrete velocity points on surface. points scattered in random pattern form circle (almost). i used scatteredinterpolant create function relating x , y v (velocity) in order create grid of interpolated values. f = scatteredinterpolant(x, y, v,'linear'); vq = f(xq,yq); % xq , yq set of query points the problem having trying calculate the surface area of function, in circular portion contains scatter points. the first way went using quad2d function. int = quad2d(@(x,y) f(x,y), min(x), max(x), min(y), max(y), 'maxfunevals', 100000); however gives incorrect takes area on rectangle , circle. now can define surface area circle in future have work more complex shapes want use points define boundary of scatter points. i'm doing through triangulation, using following command. dt = delaunaytriangulation(x,y); however have no idea how can incorporate these points ...

package - Using Qt Installer Framework to create my Application Installer -

i want create installer application. so, have read qt installer framework , tested tutorial example , create installer , work find example. have doubt when try same process application. when compile code folder created @ same level of code: myapplication (my code) build-myapplication-desktop_qt_5_4_1_mingw_32bit-release (code compiled) so questions are: what files of compilation need copy folder myinstaller/packages/vendor/ recommended qt intaller framework? if have dependencies of qt serialport, multimedia, , others, how insert these dependecies qt installer framework? windeployqt.exe want. run on command line , give executable argument. automatically copy in required qt libraries , provide runtime redistributable installer. can use binarycreator generate installer.

java - How do you create a static table in Android? -

i new android programming ios , need create static table. simple in ios use of static cells there such thing in android? to more precise of need, each row has 3 columns, textview name, edittext number of units , final textview number of units multiplied constant. the way understand listview's in android need make custom adapter read in string constants strings.xml. if however, may able load table visually need it, when edittext value changed, how able handle , edit text of corresponding textview? need each row independent , able set id's every element in row can access , edit them doesn't seem possible reading in values string.xml. sorry there no code given here, new android , don't know start. if please include code in answer, appreciated, thanks! if size of table not known (and if known, still might preferable) it's best use listview (or recyclerview now, linearlayoutmanager). a listview/recyclerview view of many items of same type of data. co...

node.js - Scaling Socket.IO across multiple servers -

i've been searching around looking on setting multi-server cluster node.js socket.io install. trying do: have 1 vip in f5 loadbalancer, pointing n number of node servers running express, , socket.io have client connect 1 vip via io.connect , have filter 1 of servers behind loadbalancer. when message emitted on 1 of servers, is sent users listening event , connect via other servers. for example - if have server a, server b , server c behind lb1 (f5), , user connected server a, user b connected server b , user c connected server c. in "chat" scenario - if message emitted server message event - server b , c should send message connected client. read possible using socket-io.redis , needs redis box - server should install on? if servers connected same redis box - work automatically? var io = require('socket.io')(server); var redis = require('socket.io-redis'); io.adapter(redis({ host: 'localhost', port: 6379 })); any appreciated th...

python - django user logged out after password change -

i having issue django users changing passwords - have built few production sites in django, none in year (or in 1.8), don't recall having issue before. summary when user changes password, user logged out, password changed. details i have view allows user change password, using standard django forms , auth framework, , to stress: changing password works, logs user out have login again . i don't mind terribly, prefer user redirected dashboard message update, if need reauth user in code, will, seems kind of clunky. here view function: @login_required def user_change_password(request): """allows user change password""" if request.method == "post": form = subscriberpasswordform(request.post) if form.is_valid(): try: request.user.set_password(form.cleaned_data['password']) request.user.save() except exception, err: print ...

powershell - Positional parameter binding with values starting with a minus/hyphen -

here powershell test script: param( [parameter(mandatory=$true, position=0)] [int]$val ) write-output $val; now want call this: powershell -executionpolicy bypass -file ".\testscript.ps1" "-1" the error is: a parameter cannot found matches parameter name '1'. note have no control on way application calls script (i.e. can not make application call script -val:-1 ). binding has positional. how can make script bind -1 $val param block? if can't fix how application calls script other option see drop named parameters entirely , use $args collection instead: c:\> type test.ps1 [int]$val = $args[0] write-output $val c:\> powershell -executionpolicy bypass -file test.ps1 -1 -1 by casting argument [int] type safety still enforced: c:\> powershell -executionpolicy bypass -file test.ps1 a cannot convert value "a" type "system.int32". error: "input string not in correc...

android - Using Outpan's JAVA API -

i having problems using outpan java api in android project. api mentioned in official outpan website. my progress till now-: i downloaded outpan java api here , , extracted them. i copied folder io inside src folder (inside downloaded folder) home->androidstudioprojects->(name of project)->app->src->main->java (i using android studio on ubuntu) . i copied .jar file inside libs folder (inside downloaded folder) home->androidstudioprojects->(name of project)->app->libs folder. opened android studio project, created earlier (it scans barcodes using zxing library) , added these 2 lines import statements in project-: import io.github.johncipponeri.outpanapi.outpanapi; import io.github.johncipponeri.outpanapi.outpanobject; next, used normal commands given in github repository (that have mentioned earlier) along proper api key (i have registered on outpan). next went to, gradle file (module: app) of project, , added line 'depeden...

javascript - Div turns black on hover -

so want div fade div has black background @ 0.5 opacity on it. when hover ignores image in div , fills black fades other div. goes image --> solid black div --> fades second div. https://jsfiddle.net/70e890e6/ html: <div class="box1"> <div class="img_hover_effect"></div> <img src="images/portfolio/charity.png" class="box1_img"> <img src="images/portfolio/charity/2.png" class="box1_img2"> </div> css: .img.img_hover_effect { display: none; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); } jquery: $(document).ready(function(){ $('.box1').on('mouseenter', function() { $('.img_hover_effect').fadein(1000); }); }); you can use jquery hover : $('.box1').hover(function() { $('.hover').fadein(1000); }, function(){ $('.hover').fadeout(1000); }); and css changes : .box1 { ...

python - Django OAuth2 invalid grant_type -

Image
i using django oauth toolkit , create sign_up call - in return gives me response: { "username": "boban16", "client_id": "sxfb8wod5qupdyp5c4pjjhxaqqfpvcw7fka3sumy", "client_secret": "3nurebdpx9ccseevyohpxz76om0keoxfwk2rrqjnk5wvyua1tuf37sh0of473wcgej3tcmfln9kpnp9vkgepwxrarc6iimqi6y34pyvu7otlcxhjs2ssomsp2c0xnxra" } so, trying make call generate token using postman application - request looks this: and response: { "error_description": "invalid credentials given.", "error": "invalid_grant" } this code urls.py urlpatterns = patterns('', url(r'^sign_up/$', signup.as_view(), name="sign_up"), url(r'^login/$', login.as_view(), name="login"), url(r'^o/', include('oauth2_provider.urls', namespace='oauth2_provider')), ) this part settings.py rest_framework = { 'default_authentication_...

html - How to keep entered data of page1 after navigating back from page2 in AngularJS -

i have 3 pages routing. if entered input , getting result on first page, next navigated second page , came second page first page. want see data entered , result also. here code snippet index.html <!doctype html> <html ng-app="scotchapp"> <head> <script src="angular.min.js"></script> <script src="angular-route.min.js"></script> <script src="script.js"></script> </head> <body ng-controller="maincontroller"> <nav class="navbar navbar-default"> <div class="container"></div> <ul class="nav navbar-nav navbar-right"> <li><a href="#"><i class="fa fa-home"></i> home</a></li> <li><a href="#about"><i class="fa fa-shield"></i> about</a></li> ...

math - python long integer division error. how do I fix this? -

this problem arose prime factorization function. when try divide long integer integer. gives value in scientific notation. , not correct answer. 18291821821212182811 / 3 = 6.097273940404061e+18 here, 6.097273940404061e+18 same this, 6097273940404061000 6097273940404061000 * 3 must equal 18291821821212182811 but there 189 integer differences. 6097273940404061000 * 3 189 bigger 18291821821212182811 6097273940404061000 * 3 - 18291821821212182811 = 189 so why not give exact number?? thinking python changes form scientific notation floating point , leads arithmetic error. there way around ? there way can tell python not change floating point during calculation if that's problem. you have use integer division // : 18291821821212182811 // 3 = 6097273940404060937

javascript - Fancybox popup always scrolls on top -

i have implemented fancybox plugin in website, noticed issue: every time click image, opens image correctly, scrolls on top of website, , does'nt let me scroll down when popup opened. can see issue in website here . i tried using option "scrolloutside", doesn't work. thank help! before going solution, notice scrolling not fancybox issue itself. can test through browser console in other pages: $.fancybox("test"); in webpage, have several <div> scrollable pages. maybe can scroll right page. writ scroll solution. first need save page when click it. var thispage = "homepage"; $(".page").click(function(){ thispage = $(this).attr("id"); }); now can scroll page whenever want. instance onclosed : $("a.inline").fancybox({ // ... other configurations ... 'onclosed' : function() { $("html,body").scrolltop($("#"+thispage).offset().top); } })...

android - can i save data of an my app user in a file not data base -

i want save user data on device , don't want use database.can it? app should use data when ever wants you use sharedpreferences: http://developer.android.com/training/basics/data-storage/shared-preferences.html other storage options: http://developer.android.com/guide/topics/data/data-storage.html

java - Weka instance.setValue arrayIndexOutOfBounsException -

good afternoon! have such method: private instances getoneinstanceinstances(map<string, double> attributesmap) { fastvector fvwekaattributes = new fastvector(attributesmap.size() + 1); (string attributename : attributesmap.keyset()) { attribute attribute = new attribute(attributename); fvwekaattributes.addelement(attribute); } fastvector fvclassval = new fastvector(2); fvclassval.addelement(integer.tostring(0)); fvclassval.addelement(integer.tostring(1)); fvwekaattributes.addelement(new attribute("class", fvclassval)); instances instances = new instances("features", fvwekaattributes,1); instances.setclassindex(instances.attribute("class")); instance instance = new instance(fvwekaattributes.capacity()); instance.setdataset(instances); (string attributename : attributesmap.keyset()) { attribute attribute = new attribute(attributename); instance.setvalue(attribute...

c - Why realloc of char** gives Address is 0 bytes after alloc'd -

i have following code: #include <stdio.h> #include <string.h> #include <stdlib.h> int main(int argc, char *argv[]) { char* filename = "file_prefix.txt"; file* file_prefix = fopen(filename, "r"); char buff[1024]; int = 0; char** prefix = null; char c = fscanf(file_prefix, "%s", buff); while ( eof != c ) { printf("%d : %s\n", i, buff); char** temp = realloc(prefix, sizeof(char*) * (i+1)); temp[i] = malloc( (sizeof(char) * strlen(buff)) + 1); strcpy(temp[i], buff ); prefix = temp; memset(buff, 0, sizeof(buff)); c = fscanf(file_prefix, "%s", buff); ++i; } int x = 0; (;x < i; ++x) { printf("%s\n", prefix[i]); } free(prefix); fclose(file_prefix); return 0; } assuming file_prefix.txt exists following valgrind: ==7322== memcheck, memory error detector ==7322== copyright (c) 2002-2013, , gnu gpl'd, julian seward et al. ==7322== ...

php - WordPress "Next Post" URL and Thumbnail -

i noobie. building new theme. need 3 separate data: direct link next post thumb next post name next post url thank help) my code dosent work: <div class="post" style="background: url(<?php next_image_link(); ?>) no-repeat center center;"> <span></span> <div class="title"> <h1> <a href="<?php next_post_link(); ?>"><?php the_title(); ?></a> </h1></div>

c# - Deleting a row using entity framework -

i'm trying delete row table in database keep getting null reference exception . i know code wrote isn't grabbing id number combobox don't know how fix it. here's code have: private void btndelete_click(object sender, routedeventargs e) { try { //select row delete doctor del = ((doctor)cbdocidd.selecteditem); doctor deleted = (from d in mainwindow.nlh.doctors d.doctorid == del.doctorid select d).first(); //delete row db mainwindow.nlh.doctors.deleteobject(deleted); //save database mainwindow.nlh.savechanges(); messagebox.show("doctor deleted"); this.close(); } catch (exception ex) { messagebox.show(ex.message); } } any appreciated. this code used fill combobox: private void window_loaded(object sender, routedeventargs e) { cbdocidd.datacontext = mainwindow.nlh.doctors; } ...

c# - Count items in MongoDB -

how count of items in mongo collection, using 2.x c# driver? i'm trying use countasync, need pass in filter. don't want filter - want returned. you can pass empty document in method db.collection.countasync(new bsondocument());

linux - Recompile a package for debian -

i want recompile ubuntu package use on debian https://launchpad.net/ubuntu/+source/hollywood how can please ? i'm beginner you need original tar-ball package, , "debian" tarball contains scripts , patches needed build package. finding on ubuntu's website hard part. given those, use dpkg-buildpackage (on system comparable target, of course), expects latter untar'd in current directory, along original tar-ball. (i build own packages script stages things arrangement; debian packagers use different scheme).

best solution to get values of multidimensional array in php -

i trying values of multidimensional array this $post = array( 'k'=>'kk', 'l'=>'ll', 'n'=>array( 't'=>'tt', 'n'=>array( 'j'=>'jj', 'h'=>'hh' ) ) ); my approach : $ordered = array(); foreach($post $key=>$value){ if(!is_array($value)){ $ordered[] = $value; }else{ $r = array_walk_recursive($value, function($v,$k) use(&$ordered){ $ordered[] =$v; }); } } expected output: array ( [0] => kk [1] => ll [2] => tt [3] => jj [4] => hh ) i don't know if it's best solution , consider performance , backward compatibility older php $ordered = array(); function myfunction($value, $key){ $ordered[] = $value; } array_walk_recursive($post ,"myfunction") var_dump($ordered); try one. may work condition....

ruby - gem eventmachine fatal error: 'openssl/ssl.h' file not found -

just installed el capitan , can't install gem eventmachine 1.0.7 . openssl @ 1.0.2a-1 . tried use --with-ssl-dir seems ignored. reported github repo well. any suggestions appreciated. thanks. $ ls /usr/local/cellar/openssl/1.0.2a-1/include/openssl/ssl.h /usr/local/cellar/openssl/1.0.2a-1/include/openssl/ssl.h $ gem install eventmachine -v '1.0.7' -- --with-ssl-dir=/usr/local/cellar/openssl/1.0.2a-1/include /users/pain/.rbenv/versions/2.1.2/bin/ruby -r ./siteconf20150612-56154-1hsjz2n.rb extconf.rb --with-ssl-dir=/usr/local/cellar/openssl/1.0.2a-1/include checking rb_trap_immediate in ruby.h,rubysig.h... no checking rb_thread_blocking_region()... yes checking ruby/thread.h... yes checking rb_thread_call_without_gvl() in ruby/thread.h... yes checking inotify_init() in sys/inotify.h... no checking __nr_inotify_init in sys/syscall.h... no checking writev() in sys/uio.h... yes checking rb_thread_fd_select()... yes checking rb_fdset_t in ruby/intern.h... yes checki...

c# - How to process each pixel of the image use Magick.NET maximally quickly? -

i use lib magick.net fot access image file. need precess each pixel on image: magickimage img = new magickimage(@"d:\test\110706m01000509.jpg"); pixelcollection pc = img.getreadonlypixels(0, 0, img.width, img.height); (int x = 0; x < pc.width; x++) for(int y = 0; y < pc.height; y++) { byte[] color = pc.getvalue(x,y); //some actions } but, access color of pixels of image(12000 x 16000) takes more 5 minutes... how more process pixels of image use lib magick.net?

phpunit - Get "Run Focused Test Method" to work in netbeans -

Image
a file, searchtest.php, has: public function testsearchthenbooking(){ ... } when right-click can see "run focused test method" (and "debug focused test method"), greyed out. i realized phpunit netbeans plugin not installed. i've installed that, restarted netbeans, no difference. phpunit commandline working fine, , running , passing function. this answer show working people! https://stackoverflow.com/a/30568731/841830 do need configure project use phpunit, or tell phpunit is, or ... ? yes, need manually download phpunit script , skeleton generator script wget https://phar.phpunit.de/phpunit.phar chmod +x phpunit.phar sudo mv phpunit.phar /usr/local/bin/phpunit wget https://phar.phpunit.de/phpunit-skelgen.phar chmod +x phpunit-skelgen.phar sudo mv phpunit-skelgen.phar /usr/local/bin/phpunit-skelgen and complete tools/options/frameworks & tools form full details installation , configuration can found here . if that, won't ...

javascript - Display JSON data from url using ajax -

we want display names our json file div using javascript. tried lot of things, didn't manage succeed. json data : http://www.smartbustracking.be/json/data.json this tried : <button>get data</button> <div id="resultjson"></div> <script type="text/javascript" language="javascript"> $("button").click(function(){ $.getjson("http://www.smartbustracking.be/json/data.json", function(result){ for(var x = 0; x < result.length; x++){ $.each(result, function(i, field) { $("#resultjson").append(field[x].name); } } }); }); if can ploblem, great thanks in advance ! don't use loop inside loop extract name. your data like [0] = {name:"name1"} [1] = { n...

r - kmeans clustering on the basis of fixed number of variables out of all variables -

i beginner in r , data analysis.i have data-set of around 2500 rows 7 columns .i want cluster data-set 15 centers on basis of first 2 columns(keeping other columns intact clustered-data-set. i need display clustered data-set sorted on basis of third column. can me required syntax ? let csv file name locdata.csv , first 2 columns "lat" , "lon" , third column "date". this should there. first create dataset (alternatively, import csv file ): set.seed(1) df <- data.frame(matrix(rnorm(n=10000, mean=10, sd=20), ncol=8)) names(df)[1:3] <- c("lat", "lon", "date") # use df <- read.csv(..) instead load file require(dplyr) cluster.df <- select(df, lat, lon) # select columns cluster on km <- kmeans(cluster.df, 15) next can extract clusters, using fact kmeans retains original order: # extract clusters , add them original data frame df$cluster = km$cluster # sort on whatever column prefer df %>% ...

javascript - Interpolate HSL Colours -

i building star visualisation engine, , need interpolate values received api. hsl colour stops are: -.63, hsl: 228° 100% 80%, .165, hsl: 224° 100% 90%, .33, hsl: 240° 100% 98%, .495, hsl: 64° 100% 92%, .66, hsl: 52° 100% 82%, .825, hsl: 28° 100% 66%, 2.057, hsl: 6° 95% 65%, each star return colour value between -.63 , 2.057, need function takes value , gets colour along spectrum comprised of above stops. i've had previous cannot life of me figure out, , haven't been able find concise tutorial or walkthrough of interpolating hsl values. way can figure out via external lib, seems ridiculous solution relatively simple. appreciated! a straightforward linear interpolation function in hsb space: function get_color_for(value) { var i, h,s,b,stops = [ [-0.63, [228, 100, 80]], [0.165, [224, 100, 90]], [0.33, [240, 100, 98]], [0.495, [64, 100, 92]], [0.66, [52, 100, 82]], [0.825, [28, 100, 66]], [2.057, [6, ...

database design - Anchor modeling - tie: make first role? -

short question related official anchor modeler. while modeling ties can setup roles properties, 1 of them "first role". what "make first role" option do? see in xml/sql file swaps roles order within tie. purely technical setting or there business case it? a tie represents relationship, in anchor modeling set of roles on type level. sets have no ordering, example {isleasing, thevehicle, withagreement} = {withagreement, thevehicle, isleasing} , names of ties represented strings in our naming convention. create string, order must imposed onto set, , "make first role" way rearrange order. syntactic sugar, , semantics of tie remains same regardless of order of roles in name. so, mentioned example, tie named pe_isleasing_ve_thevehicle_ag_withagreement same tie 1 named ag_withagreement_ve_thevehicle_pe_isleasing . tool prevent creating duplicate ties, should try so. because of way read natural language orderings easier interpret others though, ...

Matlab: Converting a Cell with Double values to String -

i need command converts a={1 2 3} a={'1' '2' '3'} . in other words, want input a={1 2 3} converted {'1' '2' '3'} . here 1 alternative using sprintfc (undocumented helper function) out = sprintfc('%d',cell2mat(a)) output: out = '1' '2' '3' while %d refers integers, might use %.4f (where .4 refers number of decimal digits after decimal point) floating point numbers. for example, out = sprintfc('%.3f',cell2mat(a)) output: out = '1.000' '2.000' '3.000'

php - PHPUnit and Doctrine: How to setup the database -

i'm trying write functional tests symfony2 app. tests interacts database, using, obviously, doctrine. now, setup configuration call test database, empty , has no tables, tests fail. how can build database schema test database before execution of tests? i have tried this namespace appbundle\tests\controller; use symfony\bundle\frameworkbundle\test\webtestcase; class getstartedcontrollertest extends webtestcase { public function setup() { passthru(sprintf('php "%s/console" cache:clear --env=test --no-warmup --no-interaction', __dir__)); passthru(sprintf('php "%s/console" doctrine:database:drop --env=test --force --no-interaction', __dir__)); passthru(sprintf('php "%s/console" doctrine:database:create --env=test --no-interaction', __dir__)); passthru(sprintf('php "%s/console" doctrine:schema:update --force --env=test --no-interaction', __dir__)); } /**...

php - Laravel Undefined index Error in array values display -

i using laravel 4.2. have 2 mysql tables owntable, othertable. getting values these tables through php. my further php code below display values in blade php, if (!empty ($owntable)){ foreach($owntable $owntbl){ $finalvalue['ownvalue']['name'] = $owntbl->name; } } if (!empty ($othertable)){ foreach($othertable $othertbl){ $finalvalue['othervalue']['name'] = $othertbl->name; } } $mydata = array('finalvalue' => $finalvalue); if(.....) { return view::make('display')->with('mydata', $mydata); } and code in display.blade below, <tbody> @foreach($mydata['finalvalue'] $res) <tr> <td>{{{$res['ownvalue']['name']}}}</td> <td>{{{$res['othervalue']['nam...

how to perform batch plots of line? -

my data set this: id cc5d_1 cc5d_2 cc5d_3 cc7d_1 cc7d_2 cc7d_3 ltc5d_1 ltc5d_2 ltc5d_3 ltc7d_1 ltc7d_2 ltc7d_3 sorbitol 10 10 10 50 50 51 100 101 101 102 105 107 glucose 10 10 10 50 50 51 100 101 101 102 105 107 fructose 10 10 10 50 50 51 100 101 101 102 105 107 ……. i want plot lines name of id column(a,b...) , error bar, @ 2 levels(ck,t) , 2 time points. sorry not paste effect picture due less reputation(at least 10). the question how in batch manner? maybe r can it, how? thank you!

json - Swift Errors Thrown from here are not handled -

i have had code working in xcode 6 since got xcode 7 cannot figure out how fix this. let jsonresult line has error says error thrown here not handled. code below: func connectiondidfinishloading(connection: nsurlconnection!) { let jsonresult:nsdictionary = try nsjsonserialization.jsonobjectwithdata(self.bytes, options: nsjsonreadingoptions.mutablecontainers) as! nsdictionary print(jsonresult) let number:int = jsonresult["count"] as! int print(number) numberelements = number let results: nsdictionary = jsonresult["results"] as! nsdictionary let collection1: nsarray = results["collection1"] as! nsarray thanks if @ definition of jsonobjectwithdata method in swift 2 throws error. class func jsonobjectwithdata(data: nsdata, options opt: nsjsonreadingoptions) throws -> anyobject in swift 2 if function throws error have handle do-try-catch block here how works func connectiondidfinishloading(connecti...

javascript - Display read more button after 200 characters -

i use code display text. i want display read more button after 200 characters, display other text of div. , want display read less button, when text displayed. how can achieve that? code: <div class="reviewtekst"> <p> text </p> </div> you need inspect first length of text if greater 200. $('.reviewtekst').each(function() { var $ptag = $(this).find('p'); if($ptag.text().length > 200){ .... } } you need copy original text , take first 200 caracters, after append div. have 2 p tags, 1 preview other 1 full text. append links , bind click event on them show/hide full text. can take @ jsfiddle: https://jsfiddle.net/8cm67cun/

DRY ruby on rails loops -

i trying loop through users , sum attribute act_points associated post_activites , assign , save users table attribute total_points . code below works me doesn't follow dry. <% @users.order("total_points desc").each |u| %> <p><% u.total_points = u.post_activities.sum(:act_points).round(2) %> </p> <% u.total_points %> <% u.save %> <%end%> <% @users.order("total_points desc").each |u| %> <p><% u.total_points = u.post_activities.sum(:act_points).round(2) %> </p> <%= u.total_points %> <%end%> any suggestions on how combine these loops or shorten them? you can refactore code in way: # user.rb def actual_points post_activities.sum(:act_points).round(2) end def update_total_points update(total_points: actual_points) end # in controller (change index method) def index @users = user.order("total_points desc") @users.find_each |user| user....

ios - How to convert unicode hex number variable to character in NSString? -

now have range of unicode numbers, want show them in uilabel, can show them if hardcode them, that's slow, want substitute them variable, , change variable , relevant character. example, know unicode u+095f, want show range of u+095f u+096f in uilabel, can hardcode like nsstring *str = [nsstring stringwithformat:@"\u095f"]; but want nsinteger hex = 0x095f; [nsstring stringwithformat:@"\u%ld", (long)hex]; i can change hex automatically,just using @"%ld", (long)hex , know how implement that? you can initialize string buffer of bytes of hex (you provide pointer). point is, , important thing notice provide character encoding applied. should notice byte order. here's example: uint32 hex = 0x095f; nsstring *unicodestring = [[nsstring alloc] initwithbytes:&hex length:sizeof(hex) encoding:nsutf32littleendianstringencoding]; note solutions using %c format fine long use them 16-bit unicode characters; 32-bit uni...

Java Eclipse Class Comparing Marks And Displaying Who Failed -

in code want compare 4 test students , display failed. need in failed class. topper class fine. import java.io.ioexception; import java.util.arraylist; import java.util.scanner; public class studentclass { static arraylist<student> list = new arraylist<student>(); static void student() { student topper = list.get(0); for(int i=1;i<list.size();++i){ if(topper.marks<list.get(i).marks){ topper = list.get(i); } } system.out.println("tooper : "+topper.name); } static void failed1(){ if(list.get(i)<=35 ){ } } // system.out.println("this student failed" +); public static void main(string[] args) { // todo auto-generated method stub student s = new student(); s.name = "test 1"; s.roolno = 1; s.marks = 30.5f; list.add(s); student x = new student(); x.name = "test 2"; x.roolno = 2; x.marks = 32.5f; list.add(x); student y = new student(); y.name = "test 3"; y.roolno = 3; y.marks = 80.5f; list.add(y); stud...

c# - Exception handling in return value methods -

i'm working on method should follow logic: prompt user enter number console try convert input integer if successful, return integer if unsuccessful, write error message console , restart method here's have: static int getplayers() { int players = 0; console.write("how many people playing?"); try { players = convert.toint16(console.readline()); } catch (exception e) { console.write(e.message + "\n" + "----------"); getplayers(); } return players; } the problem simple, "not code paths return value." can want, it's going have couple ugly conditional statements reflect how of amateur am. i'm looking elegant, professional-grade solution me learn how handle type of logical sequence in future. thank in advance! you have return result of second call of method. if call method without returning value, result 0 (if error has been made)....

Error: 404 Page not found in codeigniter Bonfire logs file on every page load -

i new using codeigniter. i'm using codeigniter bonfire framework creating application. every time when load page, logs file generate error: error - 2015-06-10 05:30:12 --> 404 page not found --> error - 2015-06-10 05:30:18 --> 404 page not found --> how solve error , create 404 page in application? here routes $route['default_controller'] = "restaurant"; $route['404_override'] = ''; $route['login'] = 'users/login'; $route['register'] = 'users/register'; $route['logout'] = 'users/logout';

java - Shortening a piece of code gives an error; How do I solve this issue? -

this question has answer here: a final counter in loop? 6 answers i have piece of code in method: switches[0].addmouselistener(new mouseadapter(){ public void mouseclicked(mouseevent e) { if(switchstate[0] == false) { if((e.getx() >= offbuttonleft && e.getx() <= offbuttonright) && (e.gety() >= offbuttontop && e.gety() <= offbuttondown)) switchstate[0] = true; }else { if((e.getx() >= onbuttonleft && e.getx() <= onbuttonright) && (e.gety() >= onbuttontop && e.gety() <= onbuttondown)) switchstate[0] = false; } paintstuff(); } }); switches[1].addmouselistener(new mouseadapter(){ public void mouseclicked(mouseevent e) ...

Outlook 2013 VSTO: Determine which calendar an AppointmentItem is on? -

in outlook 2013 in calendar view, when appointmentitem selected, need able determine if item on current user's calendar, or if have selected item else's shared calendar. if john doe current user, need check if selected appointment on john's calendar, or on else's. (i need disable button on ribbon if have selected item on else's calendar) how check this? the key folder object explorer.currentfolder via application.activeexplorer. shared folders have folder.entryid value duplicated in folder.folderpath, while non-shared folders have actual folder path value. you can use namespace.getshareddefault if want proper reference shared folder.

android - Unable to display the created CustomView -

Image
i've been trying create customview. following tutorial , did directed when tried run code customview not displayed on android screen. code attrs.xml is:- <?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="timeview"> <attr name="text" format="string"/> <attr name="setcolor" format="boolean"/> </declare-styleable> </resources> here code customview i.e timeview.java :- package com.example.custom; import java.text.simpledateformat; import java.util.calendar; import android.content.context; import android.content.res.typedarray; import android.graphics.color; import android.util.attributeset; import android.widget.textview; public class timeview extends textview{ public string titletext; public boolean color; public timeview(context context) { super(context); settimeview(); ...

how to join multiple table in java using eclips -

if write code this preparedstatement pre1=cn.preparestatement("insert registration(name,contactno,lid)values(?,?,'select lid login email="+email+" , password="+pass+"'"); its give error incorrect syntax near 'select lid login email="" , password=1233456'. please me remove error i think you're looking subquery . , can bind email , password too. also, should close statement (s). like, string sql = "insert registration(name,contactno,lid) values " + "(?,?,(select lid login email=? , password=?))"; preparedstatement pre1 = null; try { pre1 = cn.preparestatement(sql); // ... pre1.setstring(3, email); pre1.setstring(4, pass); } catch (exception e) { e.printstacktrace(); } { if (pre1 != null) { try { pre1.close(); } catch (exception e) { e.printstacktrace(); } } } }

greendao - Green Dao bi-directional One To One mapping -

i'm using greendao in android app , create bi-directional one-to-one mapping. however don't see how can achieved unless have 2 foreign key properties on both entities, not ideal. ideal if 1 entity owns relationship. did come across problem? for decided workaround create bi-directional 1 many mapping , create custom method on 2nd entity returns entity of other type. not ideal, works!

javascript - Form submitting even when it is returning false -

i can't seem stop form submitting, when shown returning false. please me spot out error? here html code: <form role="form" onsubmit="return login()" action="03_select_survey.html"> <!-- username --> <div class="form-group"> <label for="user">username:</label> <input type="text" class="form-control" id="user" placeholder="enter username"> </div> <!-- password --> <div class="form-group"> <label for="pwd">password:</label> <input type="password" class="form-control" id="pwd" placeholder="enter password"> </div> <!-- submit button --> <button type="submit" class="btn btn-primary btn-lg">submit</button> and here javascript code: function login() { "use strict"; // variables var userna...

angularjs - Angular and cloudfront with Safari -

we've setup angularjs application on cloudfront has asset files on s3 storage , there used via cloudfront ssl , performance. we have identical setup described in guide https://rossfairbanks.com/2015/01/30/integrating-angular-s3-cloudfront.html as used same post create our own setup, seems though works on browsers except safari. on safari, when visiting url directly on given path or refreshing sub pages, ui-router redirect user page landing page. for staging though, have same setup running directly on s3 without cloudfront in middle hence no ssl. but, yet seems work on safari so, problem seem issue cloudfront , safari more specific. can advise on cause? , how can solve it? update : issue might related bug https://bugs.webkit.org/show_bug.cgi?id=24175 angular on aws (cloudfront/s3) safari i figured out need use https in order safari refresh correctly. can tell s3 redirect https protocol , problem gets solved: <redirect> <protocol>https...

How detect infinite loop in Java? -

i run java program, , doesn't ends in long time. guess may infinite loop in code, can't see code(can't modify it). how judge it's in infinite loop or not? it's interview question , answer judge pc(program counter) in loop or not. interviewer give me hint use stack , heap of program ... in theory, can't. that's halting problem. in practice, can check cycles in call stack. java should crash once runs out of memory , dump stack trace. tedious, maybe potentially useful.

PHP, mysql encoding UTF-8 -

Image
i'm making basic php & mysql searching. our country use character encoding utf-8 or euc-kr . when input keyword english, result shown well. but, input korean keyword, result doesn't shown on screen. (result count doesn't shown) i'm coding on eclipse pdt, every html,php document's encodings euc-kr. set property. , mysql's table collation euckr_korean. don't know do. i'm newbie on php. code simple. there 2 document. index.html <body> <form action="./search.php" method="get"> <label> search <input type="text" name="keywords"> <input type="submit" value="search"> </label> </form> </body> search.php <?php $db = new mysqli('localhost', 'root', 'apmsetup', 'consen'); if(isset($_get['keywords'])){ $keywords = $db->escape_string($_get['k...