Posts

Showing posts from August, 2014

reactjs - Browserify Error { [Error: Cannot find module 'classNames' -

when run npm start on react project following error: browserify error { [error: cannot find module 'classnames' '/home/nuwan/nuclei/rollingright/location-admin'] stream: labeled { _readablestate: readablestate { highwatermark: 16, buffer: [], length: 0, pipes: [object], pipescount: 1, flowing: true, ended: false, endemitted: false, reading: true, sync: false, needreadable: true, emittedreadable: false, readablelistening: false, objectmode: true, defaultencoding: 'utf8', ranout: false, awaitdrain: 0, readingmore: false, decoder: null, encoding: null, resumescheduled: false }, readable: true, domain: null, _events: { end: [object], error: [object], data: [function: ondata], _mutate: [object] }, _eventscount: 4, _maxlisteners: undefined, _writablestate: writablestate { highwatermark: 16, objectmode: true, needdrain: false, ending:...

google apps script - How to Know the requesting IP with GAS? -

i have created google apps script import data database(rds/aws) google spreadsheet. created trigger execute script, however, keep getting connection errors. it's completed when execute specific method on google apps script. now want know if it's because requesting ip different between when running trigger , hands. how can know requesting ip when execute hands , when script's run automatically trigger? thank you. you cannot know it. you must check if script running many times in day, because servers block access.

javascript - Load image behind oauth2-authentication -

i develop javascript application uses oauth2 authentication. want load/show image server behind authentication mechanism. therefor send xmlhttp-request rest-server , uri of image response. after request try append uri src of image , application responds 401. how can tell browser reuse authentication image well? this part of xmlhttp-request getting uri. var xhr = new xmlhttprequest(); xhr.open("get", url, true); xhr.setrequestheader('content-type', 'application/json; charset=utf-8'); xhr.setrequestheader('authorization','bearer '+token); xhr.send(null); xhr.onreadystatechange = function() { console.log(xhr); if (xhr.readystate == 4 && xhr.status == 200) { var img = document.createelement('img'); img.src = xhr.responseurl; document.body.appendchild(img); } } did forgot something? an image static file , doubt you're going able oauth2 protection when request via simple u...

html - What does it mean by "host bootstrap by yourself"? -

i'm getting starting bootstrap , followed website says there 2 ways start using bootstrap on own web site. can download bootstrap getbootstrap.com or include bootstrap cdn also later you want download , host bootstrap yourself then if don't want download , host bootstrap yourself, can include cdn (content delivery network). what mean process hosting css/js file means put on own website/server. means people download website every time open up. (unless it's cached locally browser, @ least first time) cdn used people have files in cache other website visited using same cdn. (for example, google font) drastically reduces loadtimes first time visitors, risk delays out of control loading external website (if it's out, yours won't work properly!) so it's speed vs risk thing, basically.

javascript - Pagination withOUT jQuery. How can I select a range of elements with the same class? Does my logic make any sense? -

i working on project , want create pagination feature list of students. there 54 students , want show no more 10 per page. the class of list ( ul ) "student-list" , class of individual students ( li ) "student-item" . of course, need create buttons @ bottom of page link respective pages. my intuition tells me link each button number. if button pressed display required range of students. i want setting student-item 's hidden. based on button clicked, can set range of student-item 's visible. how can this? possible without jquery? here pseudocode. please not give away!: //problem: shows many people per page //solution: incorporate pagination , add search functionality var studenttotal = document.getelementsbyclassname("student-item").length; var pagecount = math.ceil(studenttotal/10); var pagenum; var buttonnum = pagecount; console.log(studenttotal); console.log(pagecount); //add pagination feature var displaypage = functio...

c++ - Call OpenCV CvSVMParams in Objective-C -

i want implement svm algorithm using opencv in ios can not call methods in objective-c. how call opencv cvsvmparams in objective-c. when tried shows error 'unknown type name cvsvmparams' edited: understand mistake using old version of opencv fixed that. compiler says opencv error: assertion failed (samples.cols == var_count && samples.type() == cv_32f) in predict, file /volumes/linux/builds/precommit_ios/opencv/modules/ml/src/svm.cpp, line 1919 libc++abi.dylib: terminating uncaught exception of type cv::exception: /volumes/linux/builds/precommit_ios/opencv/modules/ml/src/svm.cpp:1919: error: (-215) samples.cols == var_count && samples.type() == cv_32f in function predict #import "customobject.h" #import <opencv2/opencv.hpp> #import <coregraphics/coregraphics.h> #import <uikit/uikit.h> using namespace cv; @implementation customobject - (void) supportvectormachine { float labels[10] = { 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, ...

string - Show user position on 2D maze - Python -

i have task must print maze provides user's position. position can dependent on generated position function. mean position can have many different possibilites. i tried use slicing combination of .replace method able change character user's position symbolled 'a'. see code below, doing wrong here? def print_maze(maze, position): """ returns maze string text file , position of player print_maze(str, int) -> object """ p1 = position[0] p2 = position[1] position = position_to_index((p1,p2), len(maze)) line in maze: maze = maze[:position].replace(' ', 'a') + maze[position:] line in maze: maze.strip().split('\n') print(maze) for result far, is: >>> maze = load_maze('maze1.txt') >>> print_maze(maze, (1,1)) ##### #aaz# #a### #aap# ##### it seems you're making harder need be. rather load maze 1 string, read array. .strip() 1 in load_maze rather e...

javascript - Jtable error while deleting -

Image
ihis first attempt jtable . , works fine,except delete option. giving error: "error occurred while communicating server" <script> $(document).ready(function () { $("#department_v").jtable({ title: 'department entry', selecting: true, //enable selecting multiselect: true, //allow multiple selecting selectingcheckboxes: true, //show checkboxes on first column paging: true, //enables paging pagesize: 10, //actually not needed since default value 10. sorting: true, //enables sorting defaultsorting: 'id asc', //optional. default sorting on first load. actions: { listaction: '/frmadmin.aspx/departmentlist', deleteaction: '/frmadmin.aspx/deletedepartment', createaction: '/frmadmin.aspx/crea...

elasticsearch - Get plugin version installed in logstash -

is there way find specific logstash plugin version ? i'm able list plugin using bin/logstash-plugin list 'logstash-input-kafka' , , in of bin/logstash-plugin , wasn't able find flags find version of plugin installed in logstash. to find version of plugin, can list vendor/bundle/jruby/1.9/gems/ folder , you'll see plugin versions you're running. instance, on logstash 2.3.2, you'd see logstash-input-kafka plugin: ls -la vendor/bundle/jruby/1.9/gems | grep "logstash-input-kafka" > logstash-input-kafka-2.0.8 you can find version number in gemspec file inside plugin folder. to find logstash version: with logstash 2.x, can run this: bin/logstash version with logstash 5.x (still in alpha stage), can run this: bin/logstash -v update in meantime, found --verbose flag documented here . can append specific plugin name. goes this: bin/logstash-plugin list --verbose logstash-input-kafka will yield logstash-input-kaf...

c# - Null exception happens during an event trigger -

this question has answer here: what nullreferenceexception, , how fix it? 32 answers so, been trying learn c# bit more ran wall when trying figure out how use events correctly. needless say, keep getting null reference exception thrown when event trigger when value inputed event isn't null. appreciated. code: public delegate void performdespoit(int value); class bank { private int savingsgoal = 500; private int balance; //private int deposit; public event performdespoit valuechanged; public event performdespoit savingsreached; public int dep { set { this.balance = value; this.valuechanged(balance); if (balance > savingsgoal) { this.savingsreached(balance); } } } } class program { static void main(string...

php - how to check data from 1 multidimensional array in other multidimensional array -

i have 2 multidimensional array. first 1 $voucher_menu return following array : this 1 print_r : array ( [menu_0] => array ( [menu_id] => 521 [qty] => 1 [choice] => array ( [0] => 1 [1] => 6 ) ) [menu_1] => array ( [menu_id] => 525 [qty] => 2 [choice] => array ( [0] => 8 ) ) [menu_2] => array ( [menu_id] => 520 [qty] => 3 [choice] => array ( ) ) ) and second 1 $item_cart return following array : array ( [menu_0] => array ( [menu_id] => 517 [qty] => 1 [choice] => array ( [0] => 11 [1] => 12 ) ) [menu_1] => array ( [menu_id] => 525 [qty] => 1 [choice] => array ...

java - Android signup/signin -

i'm beginner android app development.so decided go simple app(signin/signup).i don't know causes error here full code.when click on signup or signin button causes "unfortunately app stopped running error". plz point out me in right direction. mainactivity.java package com.example.kyokesh.ams1; import android.app.activity; import android.content.intent; import android.database.cursor; import android.database.sqlite.sqlitedatabase; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext; import android.widget.toast; public class mainactivity extends activity { edittext email,password; button signup, signin; sqlitedatabase db; cursor c; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); email = (edittext) findviewbyid(r.id.etemail); password = (edittext) find...

java - android in onPreviewFrame method of image distortion . I will save the image to the SDcard in the following picture -

camera image data: previewcallback previewcallback = new previewcallback() { @override public void onpreviewframe(byte[] data, camera camera) { synchronized (nv21) { system.arraycopy(data, 0, nv21, 0, data.length); isnv21ready = true; } } }; save image: public void decodetobitmap( byte[] data, int mindex, int camera) { try { bitmap mbitmap = null; camera.parameters parameters = mcamera.getparameters(); int format = parameters.getpreviewformat(); if (format == pixelformat.ycbcr_420_sp || format == pixelformat.ycbcr_422_i) { int w = parameters.getpreviewsize().width; int h = parameters.getpreviewsize().height; int[] = new int[data.length]; decodeyuv420sp(i, data, w, h); mbitmap = bitmap.createbitmap(i, w, h, bitmap.config.argb_8888); } else if (fo...

hibernate @formula select only field -

i following tutorial on hibernate , have field on entity should select only. however, upon save of entity filed in insert query , ending on error. please assist. @entity @table(name="finances_user") @access(value=accesstype.property) public class user { ... private date birthdate; @formula("lower(datediff(curdate(), birth_date)/365)") private int age; @column("birth_date") public int getage() { return age; } public void setage(int age) { this.age = age; } ... } i have tried below well, @formula(value = "select lower(datediff(curdate(), birth_date)/365) finances_user l l.user_id = userid") below error stack, field 'age' used in insert query. should select field. debug - insert finances_user (age, birth_date, created_by, created_date, email_address, first_name, last_name, last_updated_by, last_updated_date, user_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) debug - not ex...

java - How do I specificy the order of execution for methods in my testing? -

i have .java file called mytest.java , inside of have 2 test methods (in order created) called: public void testgrabsubdevicedata(){ // , assert } public void testsubdevice(){ // again , assert } for reason executes "testsubdevice()" method first, , there must sort of alphabetical method execution set. how turn off executes in order placed it? edit: this eclipse jee neon , maven plugin. you can use import org.junit.fixmethodorder; @fixmethodorder(methodsorters.name_ascending) public class whatevertest { this guarantee junit runs test in specific order. there aren't many such orders; 1 fits needs. but word of warning: bad practice! fixing execution order should when have reasons so. finally: read java naming style guides. class names start uppercase; always; tests.

ruby on rails 5 - By filling in the code marked FILL_IN in Listing 3.42, write a test for the root route -

adding root route in listing 3.41 leads creation of rails helper called root_url (in analogy helpers static_pages_home_url). filling in code marked fill_in in listing 3.42, write test root route. listing 3.41: setting root route home page. config/routes.rb rails.application.routes.draw root 'static_pages#home' end listing 3.42: test root route. green test/controllers/static_pages_controller_test.rb require 'test_helper' class staticpagescontrollertest < actiondispatch::integrationtest test "should root" fill_in assert_response fill_in end end what should fill_in? tried static_pages_root_url, root_url. rails test fails. f failure: staticpagescontrollertest#test_should_get_root [/home/ubuntu/workspace/sample_app/test/controllers/static_pages_controller_test.rb:12]: <root | ruby on rails tutorial sample app> expected <home | ruby on rails tutorial sample app>.. expected 0 >= 1. e error: staticpagescontrollertest#t...

php mkdir will only work when creating a folder inside a 777 folder -

i have folder called 'folders'. want create folder inside 'folders' called 'folder' mkdir() however folder fails create when 'folders' set 755. may can mkdir work making 'folders' 777. typical or there else wrong? shouldn't able on 755, isn't 777 security risk? a 777 permission on directory means everyone has access read/write/execute (execute on directory means can ls of directory). try 1 below if fails create folder inside folder. <?php // desired folder structure $structure = './folders/folder/'; // create nested structure, $recursive parameter // mkdir() must specified. if (!mkdir($structure, 0755, true)) { die('failed create folders...'); } ?>

python - How to optimize models.objects.all() -

views def vms(request): user = request.user servers = list.objects.all() return render_to_response( 'vmserver/all_vms.html', { 'list': servers, 'user': user, } ) template {% vm in list %} <tr class="odd gradex"> <td><a href="/vmserver/vms/{{ vm.id }}/$">{{ vm.list_name }}</a></td> <td>{{ vm.ip }}</td> <td>{{ vm.app_name }}</td> <td>{{ vm.cpu }}</td> <td>{{ vm.mem }}</td> <td>{{ vm.total_hard_disk }}</td> <td>{{ vm.os }}</td> <td>{{ vm.power_status }}</td> in models.list, there has 2 thousands of objects, since it's in render layer. how speed rendering. the template used datatables bootstrap's plugin, auto pagination, still slowly this code of models. models.list class list(models.model): instance_uuid = models.charfield(verbose_name=...

Gulp: Rename certain file from source directory while copying -

i copy folder destination , rename file in same process. gulp.task('deploy', function () { gulp.src(['xxx/**/*']).pipe(gulp.dest('yyy')); }); i able copy folder on fine how go renaming file? source folder structure: - xxx (root) - scripts - config - app.config.local.js (would rename file app.config.js) - app.config.dev.js you can use gulp-rename plugin rename files , gulp-if plugin make sure renaming applied 1 particular file: var gulp = require('gulp'); var rename = require('gulp-rename'); var _if = require('gulp-if'); gulp.task('deploy', function() { return gulp.src(['xxx/**/*']) .pipe(_if('**/app.config.local.js', rename({basename:'app.config'}))) .pipe(gulp.dest('yyy')); });

android - Trying to make a map -

private void setupmapifneeded() { // null check confirm have not instantiated map. if (mmap == null) { // try obtain map supportmapfragment. mmap = ((supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map)) .getmap(); // check if successful in obtaining map. if (mmap != null) { setupmap(); } } } "for odd reason area says .getmap() isnt working. can help." try removing .getmap() part , putting getmapasync() instead. private void setupmapifneeded() { // null check confirm have not instantiated map. if (mmap == null) { // try obtain map supportmapfragment. mmap =((supportmapfragment)getsupportfragmentmanager().findfragmentbyid(r.id.map)); mapfragment.getmapasync(this); // check if successful in obtaining map. if (mmap != null) { setupmap(); } } }

.net - Datagridview with checkbox -

i have tried this, not getting selected value grid view string data = ""; foreach (gridviewrow row in gridview5.rows) { if (row.rowtype == datacontrolrowtype.datarow) { checkbox chkrow = (row.cells[0].findcontrol("chkctr") checkbox); if (chkrow.checked) { string brand_name = row.cells[1].text; string market_name = row.cells[2].text; string usc = row.cells[3].text; string manufacture = row.cells[4].text; data = data + brand_name + " , "; //;+ market_name + " , " + usc + ","+manufacture+""; gvrproducts.visible = true; gvrproducts.datasource = data; // listbox1.databind(); gvrproducts.databind(); } } } please help gridview requires data source control such linqdatasour...

json - gzip compression to http responseWriter -

i'm new go. playing rest api. cant same behavior out of json.marshal json.encoder in 2 functions have i wanted use function gzip responses: func gzipfast(a *[]byte) []byte { var b bytes.buffer gz := gzip.newwriter(&b) defer gz.close() if _, err := gz.write(*a); err != nil { panic(err) } return b.bytes() } but function returns this: curl http://localhost:8081/compressedget --compressed --verbose * trying 127.0.0.1... * connected localhost (127.0.0.1) port 8081 (#0) > /compressedget http/1.1 > host: localhost:8081 > user-agent: curl/7.47.0 > accept: */* > accept-encoding: deflate, gzip > < http/1.1 200 ok < content-encoding: gzip < content-type: application/json < date: wed, 24 aug 2016 00:59:38 gmt < content-length: 30 < * connection #0 host localhost left intact here go function: func compressedget(w http.responsewriter, r *http.request, ps httprouter.params) { box := box{width: 10, he...

javascript - Get Object based on Key Value in Angular ui-router state params -

i trying retrieve object in firebase based on 1 of objects key values in ui-router $stateparams. example: firebase structure: "businesses" : { "-kp_xebaya8oln6wousx" : { "category" : "restaurant", "link" : "urlfriendly", "name" : "some restaurant" }, the link page so: website.com/food/restaurants/urlfriendly in app.js: .state('food.restaurants.item',{ url: '/:item', templateurl: function($stateparams){ return 'pages/business.html' }, controller: function($scope, $firebasearray $stateparams){ var sref = firebase.database().ref().child("businesses"); $scope.restarants = $firebasearray(sref); var matches = $scope.restaurants.filter(function(val, index, array){ return val.link === $stateparams.item; ...

javascript - Jquery background slide down -

i wondering if possible change make div follow size of table cell? @ moment can display above div. have far. https://jsfiddle.net/amosangyongjian/mmqasf5t/54/ $(document).ready(function(){ $("td").hover(function(){ $(this).find(".expand").slidedown("slow"); },function(){ $(this).find(".expand").slideup("slow"); }); }); jsfiddle example td { width:100px; height:100px; position:relative; /* add */ } .expand { display:none; position:absolute; top:0; left:0; width:100%; height:100%; /* add */ z-index:1; background:red; /*height:auto; width:100%; remove */ overflow:hidden; } .static { position:absolute; z-index:0; background:yellow; text-align:center; } and here's cleaner solution minor changes in html, css, jquery jquery(function( $ ) { $("td").hover(function() { $(this).find(".expand").stop().slidetoggle("slow"); }); }...

html - Height 100% along with Width 100% is causing issue on mobile devices -

i've found ton of posts , questions on mobile width/height. top 2 answers use media queries, or use vh/calc(). other issue i've seen numerously mis-understanding of width/height(100%) vs width/height(auto) use of margins/padding/borders. i've run seems unique, flood of mobile issues, have feeling somewhere out there answer already. if you've seen this, please point correct question/answer. i've created black glass along element use image previewer. glass , image have width("100%") , height("100%") without padding, margin, or border. on computer, looks perfect. on mobile device, dimensions can thrown off , background shows through. if remove height("100%") on images taller wide, resizes entire element. if image wider tall, removing width("100%") causes grow appropriately again too. however, doesn't solve issue because without width or height cap @ 100%, larger images overflow. i first noticed issue on cellph...

javascript - UI-router empty param causes navigation to wrong route -

this should simple can't figure out. i have 2 routes: $stateprovider .state('users', { url: '/users', views: {'@': { templateurl: 'templates/users.tpl.html', controller: 'usersctrl users' }} }) .state('users.edit', { url: '/{userid}', views: {'@': { templateurl: 'templates/edituser.tpl.html', controller: 'edituserctrl edituser' }} }); this works fine if use ui-sref or $state.go navigate "users" state name, if type domain.com/users/ url bar goes edit state empty userid parameter though there nothing after trailing stash. normally wouldn't problem firing edituser route no userid causes console errors pain fix. is fixable? take post: https://github.com/angular-ui/ui-router/issues/50 and link referenced in post: https://github.com/angular-ui/ui-router/wi...