Posts

Showing posts from July, 2012

Kotlin - How to make field read-only for external classes -

i have following kotlin class on android: class thisapplication: application() { lateinit var network: inetwork override fun oncreate() { super.oncreate() network = network() } } now, external class can inetwork reference doing: application.network however, makes possible external class overwrite value: application.network = mynewnetworkreference i want avoid second option. unfortunately, can't make field val because initialization needs happen inside oncreate callback. i thought making field private , exposing through function, this: private lateinit var network: inetwork fun getnetwork() = network however, whoever calls getnetwork() can still assign new value it, so: application.getnetwork() = mynewnetworkreference how can make network field read-only external classes? or better, there way make val though can't initialize inside constructor? to restrict access external classes, can change visibility of acce...

linux - Credit-Based Process Scheduling algorithm -

i've been trying implement in java simulation of the credit based scheduler algorithm not understand logic of algorithm i referring : credit-based algorithm – each task has # of credits associated – on each timer interrupt: • each timer interrupt: running task loses 1 credit • if credits task == 0, task suspended • if tasks have 0 credits: – re-credit: every task gets credits = credits/2 + priority choose next task run: pick 1 credits my question : when credits = 0 :====> use formula recredits processes credits = credits/2 +priority how can use credits since equals 0 ?, should use self-defined table of credits ? or misunderstanding help, please?

javascript - Write a function called 'maker' that creates an array and fills that array with numbers 1 to 25, then returns the array -

question write function called 'maker' creates array , fills array numbers 1 25, returns array i'm stuck on problem, i've watched bunch of videos, , read various forms, can't seem figure out. can me? my attempt var myarray = [1-25] function maker(arr) { return myarray } try this: function maker() { var myarray = []; (var = 0; < 25; i++) { myarray[i] = + 1; } return myarray; } hope helps!

C++ how to compact fancy for-loops -

if 1 lazy rewrite fancy loop on variable u, 1 can define macro this: #define forloop(u) (int u = 0; u < n; u++) now, let's want this for (int u = 0; u < n; u++) { class& var_u = somefunctionof(u) ... code using var_u ... } and let's need @ several places in code, , lazy rewrite it, because loop involves complicated conditions on multiple variables. how can compress macro ? feel annoying put 1 { in macro because whatever ide using break syntax highlighting , everything... i had idea: define template: template <typename loop> void forloop(int u, const loop& loop) { (int u = 0; u < n; u++) { class& var_u = somefunctionof(u) loop(u, var_u); } } so have write: forloop([&](int u, class& var_u){ ... code using var_u ... }); i know, i'm weird. idea? inlined 100% of time? not lose performance doing instead of regular loop? performance critical in case. other way thought about: #define fo...

Why Java EE jsessionID changed after a click -

i'm learning java ee servlets. when log in page http://localhost:8080/test/login jsessionid a. click link http://localhost/test/buy?book=java&price=99.9” , jsessionid changed b. please give me guidance.

java - Eclipse Neon.3 / error dialog window pops up after clicking on WildFly @ Servers-Tab -

i'm asking help: eclipse neon.3 release (4.6.3): everytime when click in servers-tab on wildfly 10 server error dialog window, there no errors in console-output. deploying , other functions in eclipse behave fine. but how rid of error dialog popup?: an error has occurred. see error log more details. bad type on operand stack exception details: location: com/spotify/docker/client/defaultdockerclient.copycontainer(ljava/lang/string;ljava/lang/string;)ljava/io/inputstream; @43: invokevirtual reason: type 'com/fasterxml/jackson/databind/node/textnode' (current frame, stack[2]) not assignable 'com/fasterxml/jackson/databind/jsonnode' current frame: bci: @43 flags: { } locals: { 'com/spotify/docker/client/defaultdockerclient', 'java/lang/string', 'java/lang/string', 'javax/ws/rs/client/webtarget', 'com/fasterxml/jackson/databind/node/jsonnodefactory' } stack: { 'com/fasterxml/jackson/dat...

java - ConstraintViolationException: Validation failed for classes [....entities.WalletInfo] during persist -

Image
i work spring mvc restful app , constraintviolationexception while persisting. error message provided below, exception in thread " starting" javax.validation.constraintviolationexception: validation failed classes [mobi.puut.entities.walletinfo] during persist time groups [javax.validation.groups.default, ] list of constraint violations:[ constraintviolationimpl{interpolatedmessage='may not null', propertypath=id, rootbeanclass=class mobi.puut.entities.walletinfo, messagetemplate='{javax.validation.constraints.notnull.message}'} constraintviolationimpl{interpolatedmessage='may not null', propertypath=currency, rootbeanclass=class mobi.puut.entities.walletinfo, messagetemplate='{javax.validation.constraints.notnull.message}'} ] @ org.hibernate.cfg.beanvalidation.beanvalidationeventlistener.validate(beanvalidationeventlistener.java:140) @ org.hibernate.cfg.beanvalidation.beanvalidationeventlistener.onpreinsert(beanvalidat...

Update values of a specific column of a specific row. Android SQLite -

i have recyclerview cardholder inflates using values of 'name' table 'ordertable'. cardholder have edittext displays values of column 'quantity' in sqlite database. i have button update database every changes in edittext. i have table ordertable id name quantity 1 order1 1 2 order2 1 3 order3 1 4 order4 1 being more specific, how can update quantity of order2 on onbuttonpressed new values of edittext. edit... i have tried code nothing happened button update values public void addbuttonclick(textview tv_cardrowname_atc, textview tv_currentprice_atc, edittext et_quantity_atc, int position) { int thisquantity = integer.parseint(et_quantity_atc.gettext().tostring()); thisquantity++; string ordername = tv_cardrowname_atc.gettext().tostring(); string oldquantity = et_quantity_atc.gettext().tostring(); string new...

styles - How to render a star rate component in react-native? -

Image
how can create half colored star? <image source={require('../star.png')} style={{ height: '100%', aspectratio: 1, tintcolor: 'blue', backgroundcolor: 'transparent' }} /> is possible have background view , use image mask? tried following fails. <view style={styles.container}> <view style={{ position: 'absolute', backgroundcolor: 'blue', width: '80%', height: '100%' }} /> <image source={require('../star.png')} style={{ height: '100%', aspectratio: 1, tintcolor: 'transparent', }} /> </view> you can use component this. should find image of star out of stars must filled color , background color of stars must trasparent. assume width of each star 30 in example. should pass rate value prop export default class starrate extends component { render() { r...

javascript - Function for mouse near an element in jQuery -

i want track , show tooltip when mouse near table head element. works mouseenter event, want show tooltip before mouseenter , when gets near. want remove tooltip after mouseout distance table head. this code. $('thead').mouseenter(showtooltip); $('thead').mouseout(removetooltip); how can jquery? this works. first parameter can jquery object. second parameter nearness object, in case 20px . demo: http://jsfiddle.net/thinkingstiff/lpg8x/ script: $( 'body' ).mousemove( function( event ) { if( isnear( $( 'thead' ), 20, event ) ) { //show tooltip here } else { //hide here }; }); function isnear( element, distance, event ) { var left = element.offset().left - distance, top = element.offset().top - distance, right = left + element.width() + 2*distance, bottom = top + element.height() + 2*distance, x = event.pagex, y = event.pagey; return ( x ...

amazon web services - Issue in invoking AWS Lambda function with API Gateway -

i have created aws lambda function , api gateway invoke function. in resource tab of apigateway, if invoke test, test passed , return 200 status if deploy api , invoke url mentioned there, got following error: {"message":"missing authentication token"} please let me know if need pass more information. if methods defined on child resources , not on root resource itself, choosing invoke url link return {"message":"missing authentication token"} error response. in case, must append name of specific child resource invoke url link. means along url generated api gateway append resourse name.

javascript - jQuery sometimes doesn't work(Ruby on Rails) -

i have rails 5.1.3 application(a facebook clone more precise.) when page loads, fire anonymous function grab of "comment" & "reply" buttons. these buttons responsible revealing comment/reply forms. the problem i'm having this, when use pagination grab additional posts ajax, fire exact same functions again, this time named updatebuttons() , however, works, doesn't. here's application.js. loads initial buttons on $(document).ready(function(( {...}) $(function() { if ($(".search")) { tabs = $("li.tab").toarray(); tabs.foreach(function(item) { item.addeventlistener("click", function(e) { tab = $($(e.target)).parents("li").attr("data-panel"); $("ul#list li").not(".hidden").toggleclass("hidden"); $("." + tab).toggleclass("hidden"); }) }) } // initial grab of comment buttons revealin...

speech to text - Google SpeechClient service's authorisation does not recognise the environment variable set. -

i have been trying use speechclient in 1 of applications running on remote debian machine.i have set environment variable google_application_credentials value of path json key file(echo $google_application_credentials prints value of path).i have service account created active billing account too. when run application, still complains environment variable looking not set. on local(mac) setup, got around problem downloading , installing gcloud sdk.following that, ran gcloud auth activate-service-account --key-file [key_file] is installing sdk necessary always.should doing again on debian instance remote machine. you can try set environment variable in /etc/environment file. then, have logout/reboot instance affect variable. also, need confirm echo command.

PHP removing an array element and inserting it into another array -

i have 2 arrays in same form below; examples sake, lets call them $array1 , $array2 array ( [element1] => array ( [id] => 11 [morethings] => 145 [somemore] => namehere ) [element2] => array ( [id] => 11 [morethings] => 145 [somemore] => namehere ) [element3] => array ( [id] => 11 [morethings] => 145 [somemore] => namehere ) ) what need take element2 first array , insert array2 newelement2 i have following below keeps returning nothing @ in array2 $searcharray = array_search('element2', $array1); array_splice($array2, $searcharray, 1, array('newelement2')); any appreciated. for assign value can $array2['element2'] = $array1['element2']; (this append or repalce entry elemet2 in $array2) and remove value unset($array1[...

php - Facebook Login works in localhost but getting error in server side -

checked files name , other required information (such credentials) , spelled correctly. have created separate app localhost , server testing. here error getting when user tried login facebook on live server failed open stream: http request failed! http/1.1 400 bad request in facebook login

r - Linetypes missing for one group ggplot2 -

Image
i have following data: date, name, bin,group, value 2017-08-19,a1,0,1,302 2017-08-19,a3,0,1,35 2017-08-19,a4,0,1,33 2017-08-19,a6,0,1,43 2017-08-19,p1,0,0,76 2017-08-19,i3,0,0,23 2017-08-19,cl,1,1,73 2017-08-19,c,1,0,2 2017-09-19,a1,0,1,302 2017-09-19,a3,0,1,35 2017-09-19,a4,0,1,33 2017-09-19,a6,0,1,43 2017-09-19,p1,0,1,76 2017-09-19,i3,0,1,23 2017-09-19,cl,1,1,73 2017-09-19,c,1,1,2 for reason ending plot not show linetype 1 of groups. here code: p <- df %>% ggplot(aes(y=value,x=date,color=name))+ geom_point(aes(shape=factor(bin)))+ geom_line(aes(linetype=factor(group)))+ geom_hline(aes(yintercept = 0))+ theme_minimal() p you can see image below 1 of linetypes not showing. how other linetype show? the reason lines aren't showing name 's there 2 group 's. result, ggplot doesn't ones pick showing lines , apparently decides plot nothing @ all. a possible solution change group -value first 1 of each name , plot: df %>% ...

android - Angular 4 App - Allowing customers to link their bank accounts -

i know if there solution allows me create app allows users sign in. can link own bank account via stripe (stripe been integrated app). the app accept payments , payments made go stripe account. i not need code whole app or stripe integration guidance on how can implemented. i have had @ following stripe resources - https://stripe.com/docs/stripe.js#bank-account-createtoken however not sure if there needs 1 main stripe account (which create) , sub accounts underneath (which users create) or if each user have own stripe account (only accessible them). also there special need implement when trying configure automated payouts or handled stripe directly. is possible charge handling fee (for example 2%) payments made , if there specific method integration needs happen or can happen normal stripe integration. app using following, angular 4 ionic 3 built ios , android. you can using stripe native plugin .here plugin's repo . import { stripe } '@ionic-nat...

setting up django celery error running instance -

i'm learning how setup django-celery , i'm getting error [tasks] . revamp.celery.debug_task [2017-08-20 05:58:06,216: error/mainprocess] consumer: cannot connect amqp://guest:**@127.0.0.1:5672//: [errno 111] connection refused. trying again in 2.00 seconds... [2017-08-20 05:58:08,230: error/mainprocess] consumer: cannot connect amqp://guest:**@127.0.0.1:5672//: [errno 111] connection refused. trying again in 4.00 seconds... [2017-08-20 05:58:12,245: error/mainprocess] consumer: cannot connect amqp://guest:**@127.0.0.1:5672//: [errno 111] connection refused. trying again in 6.00 seconds... [2017-08-20 05:58:18,263: error/mainprocess] consumer: cannot connect amqp://guest:**@127.0.0.1:5672//: [errno 111] connection refused. trying again in 8.00 seconds... [2017-08-20 05:58:26,283: error/mainprocess] consumer: cannot connect amqp://guest:**@127.0.0.1:5672//: [errno 111] connection refused. trying again in 10.00 seconds... [2017-08-20 05:58:36,312: error/mainprocess] ...

jquery - How can i make my image show fade in before falling? -

i'm writing function make pictures on photographer's site fall , down reason function isn't working. need images hidden , fadein, fall towards bottom. function falls fine when added them being hidden , .show() image won't reveal itself. can me? <html> <head> <title> black pro pix | professional photography </title> <meta charset="utf-8"> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <link rel="stylesheet" href="blackpropixfallen.css"> <!-- satisfy google font --> <link href="https://fonts.googleap...

c++ - Using operator[] to access a private std::map of unique_ptr -

i have class private std::map of unique_ptr: class myclass{ std::map <keytype, std::unique_ptr<my_type>> my_map; ... }; i chose unique_ptr because my_map sole owner of my_type objects. i expose operator[] public member function access (perfect forwarding) my_map. like: // my_class of type myclass auto ptr = my_type_factory(...); // my_type_factory returns std::unique_ptr<my_type> .... my_class[1] = std::move(auto_ptr); i have tried various possible definitions of operator[] : class myclass{ .... public: auto operator[](keytype && key) { return my_map[std::forward<keytype>(key)]; } // or return & my_map[...]; }; but doesn't work, in end invoking deleted copy constructor of unique_ptr. just move forward, if move my_map public interface have made tests pass, cheating of course, since trying refine modern c++ skills , think there principle have not grokked yet unique_ptr , move. so question is: how use std::unique_ptr's in ...

Numpy and xlrd module for python 2.5 -

i have 2 questions, first, want use numpy module python version 2.5, run "numpy-1.6.1.win32-py2.5.exe" , numpy module added site-packages folder, when import numpy in python shell, it's ok when import in program , run it, error follows: syntaxerror: 'import *' not allowed 'from .' second, want use xlrd module functions, code follows: file_location=r'c:\users\n.jahan\desktop\python_test_real.xlsx' workbook=xlrd.open_workbook(file_location) i error below: biff_version = bk.getbof(xl_workbook_globals) file "c:\python25\lib\site-packages\xlrd\__init__.py", line 1323, in getbof raise xlrderror('expected bof record; found 0x%04x' % opcode) xlrderror: expected bof record; found 0x4b50 can me? thanks.

c# - How to include a library in .NET Core 2.0 -

Image
i don't know .net yet, quess i'm missing obvious. i created library (targeted dll, set .net standard 2.0), packaged both dll , nuget package. want use library in project, on asp.net core 2.0. how should it? i on linux vm, use vs code, therefore prefer solution without using full visual studio. tried solutions using full visual studio, didn't work me, because haven't found reference explorer nowhere. you have reference library in csproj file an empty csproj file this: <project sdk="microsoft.net.sdk"> <propertygroup> <outputtype>exe</outputtype> <targetframework>netcoreapp1.1</targetframework> </propertygroup> </project> now, can have 2 types of references project reference - have project serves class library in solution , want reference directly <projectreference include="..\..\src\mylib.csproj" /> package reference - have link nuget package <packa...

vue.js - Move Vue JS project from localhost to a public server -

i finished basic project in vue js, on localhost server. now, want move content localhost public server. can solve problem? check out article how deploy vue js project heroku https://medium.com/@sagarjauhari/quick-n-clean-way-to-deploy-vue-webpack-apps-on-heroku-b522d3904bc8

python - Error with PIL import Image, and pytesser import -

i new python. attempting create python ocr program, , following tutorial online it. here recommended code use: from pil import image pytesser import * image_file = 'menu.tif' im = image.open(image_file) text = image_to_string(im) text = image_file_to_string(image_file) text = image_file_to_string(image_file, graceful_errors=true) print "=====output=======\n" print text the tutorial link found here . getting error when running code however. pytesser import * importerror: no module named 'pytesser' i have followed instructions, installing ocr here , pytesser library here code(dot)google(dot)com/archive/p/pytesser/downloads (sorry because <10 rep can't post more 2 links). this (see gyazo below) screenshot of installation files far, "pytesser_v0.0.1" pytesser folder, "tesseract-master" found on github (probably not relevant), , "tessinstall" folder installed tesseract , pyimgr.py file attempting run. gyazo...

osx - how to control volume with python3? -

i wanted write alarm program, waking in mornings. want play sound loud possible, needs raise volume 100%. asked how change volume python? . @macmoonshine suggest me use 'applescript'. , worked me, works on python2(error on python3) and(not sure) works apple. how can write program can control volume in python3 without using applescript? i'd appreciate help(;

ios - RLMException "Realm at path ' ' already opened with different encryption key" after writeCopy(toFile:,encryptionKey:) -

i'm trying change encryption key realm database using writecopy(tofile:, encryptionkey:) , below: public static func updateencryption(fornewkey newkey: string, witholdkey oldkey: string, completion: (() -> void)) { let defaulturl = backup.realmcontainerurl let defaultparenturl = defaulturl.deletinglastpathcomponent() let compactedurl = defaultparenturl.appendingpathcomponent("default-compact.realm") let oldkeydata = oldkey.pbkdf2sha256(keybytecount: 64) let newkeydata = newkey.pbkdf2sha256(keybytecount: 64) let oldencryptionconfig = realm.configuration(fileurl: backup.realmcontainerurl, encryptionkey: oldkeydata) autoreleasepool { { let oldrealm = try realm(configuration: oldencryptionconfig) try oldrealm.writecopy(tofile: compactedurl, encryptionkey: newkeydata) oldrealm.invalidate() try filemanager.default.removeitem(at: defaulturl) try filemanager.default.movei...

doctrine2 - Adding in an innerJoin a where clause on the many to many joinning table -

i have existing query join: public function findclientsandtheirusers($user_id, $search) { $query = $this->getentitymanager()->createquerybuilder() ->select('c.client_id, c.title, u.user_id, u.email') ->from('application\entity\user', 'u') ->innerjoin('u.clients', 'c') ->innerjoin('c.users', 'cu') ->andwhere("cu.user_id = {$user_id}") ->groupby('c.client_id') ->orderby('c.title, u.email', 'asc'); return $query->getquery()->getresult(\doctrine\orm\query::hydrate_array); } resting on these tables: client | client_id | int(10) unsigned | no | pri | null | auto_increment | | title | tinytext | no | | null | | user | user_id | int(10) unsigned | no | pri | null | auto_increment | | email | varchar(255) | no | uni | null ...

ubuntu - SSL Certificate verify failed in Telegram Webhook -

i trying set webhook telegram bot , i'm facing issue telegram ssl certification: {"ok":true,"result":"url":"https://example.com:443/index.php","has_custom_certificate":true,"pending_update_count":2,"last_error_date":1503222412,"last_error_message":"ssl error {337047686, error:1416f086:ssl routines:tls_process_server_certificate:certificate verify failed}","max_connections":40}} i bought ssl certificate comodo supported telegram , tired possible ports, , uploaded .pem using command: curl -f "url=https://example.com:443/harfbeme/index.php" -f "certificate=@/etc/apache2/ssl/apache.pem" https://api.telegram.org/bottokenid/setwebhook tried telegram method described here , got same error. checked this page , server met every requirements. any idea why certificate verify failed error? are sure after buying ssl , setting on domain? ssl domain , w...

java - Cant set text to EditText in DialogFragment -

i have button in listview row when click on want dialogfragment open , set text of edit text (that located inside dialogfragment) string. the problem is: app shut down when comes line of settext method. this code use open dialogfragment , set text it. public void onclick(view v) { fragmentmanager manager = getfragmentmanager(); view parentrow = (view) v.getparent(); listview listview = (listview) parentrow.getparent(); final int position = listview.getpositionforview(parentrow); trempdata data = adapter.getitem(position); //from here im getting data want set edit text. addtremp trempdialog = new addtremp(); trempdialog.show(manager, "addtremp"); trempdialog.from.settext(data.get_from()); trempdialog.to.settext(data.get_to()); trempdialog.date.settext(data.get_date()); trempdialog.time.settext(data.get_time()); trempdialog.extra.settext(data.get_extras()); } hope me. thanks. your app surely crash due null...

Using a nested function as the selector of an action - swift -

this code: func didselectlabel() { let label = uilabel(frame: cgrect(x: 0, y: 0, width: 50, height: 30)) label.center = viewforedit.center label.textalignment = .center label.isuserinteractionenabled = true func userdragged(gesture: uipangesturerecognizer) { let loc = gesture.location(in: self.viewforedit) label.center = loc } gesture = uipangesturerecognizer(target: self, action: userdragged(gesture:)) label.addgesturerecognizer(gesture) let alert = uialertcontroller(title: "write text", message: "", preferredstyle: .alert) let continueaction = uialertaction(title: "continue", style: .default) { (uialertaction) in label.text = alert.textfields?[0].text } let cancelaction = uialertaction(title: "cancel", style: .cancel, handler: nil) alert.addtextfield { (textfield) in textfield.placeholder = "write here" } alert.addaction(con...

python - How do I test one variable against multiple values? -

i'm trying make function compare multiple variables integer , output string of 3 letters. wondering if there way translate python. say: x = 0 y = 1 z = 3 mylist = [] if x or y or z == 0 : mylist.append("c") elif x or y or z == 1 : mylist.append("d") elif x or y or z == 2 : mylist.append("e") elif x or y or z == 3 : mylist.append("f") which return list of ["c", "d", "f"] is possible? you misunderstand how boolean expressions work; don't work english sentence , guess talking same comparison names here. looking for: if x == 1 or y == 1 or z == 1: x , y otherwise evaluated on own ( false if 0 , true otherwise). you can shorten to: if 1 in (x, y, z): or better still: if 1 in {x, y, z}: using set take advantage of constant-cost membership test ( in takes fixed amount of time whatever left-hand operand is). when use or , python sees each side of operator s...

swift - WKWebView disable right click menu -

Image
i have wkwebview , want disable/remove right click menu: i found similar issues: webview load custom context menu cocoa webview - disable interaction but cant find optional func webview(_ sender: webview!, contextmenuitemsforelement element: [anyhashable : any]!, defaultmenuitems: [any]!) -> [any]! method in wkuidelegate or wknavigationdelegate you can this, not swift/objc side. intercept 'oncontextmenu' event on html code, example: <body oncontextmenu='contextmenu(event)'> then javascript : function contextmenu(evt) { evt.preventdefault(); } i deduced following post explain how customize menu: how can context menu in wkwebview on mac modified or overridden? regards

r - Converting from Data Frame to Zoo Issue with rows/columns -

i trying convert df zoo. df has 2 columns, first date, , second values. i use hp <- read.zoo(df, header = true, format = "%y-%m-%d", fun = as.yearmon) when seems convert vector whereby each column has both date , value, instead of having date index. when run head(hp) get: jan 1991 feb 1991 mar 1991 apr 1991 may 1991 jun 1991 53051.72 53496.80 52892.86 53677.44 54385.73 55107.38 and running hp[1] gives: jan 1991 53051.72 what doing wrong when converting? thanks.

vba - How to reference values in a series of closed Excel workbooks? -

i have been trying while, need same values 5 years worth of daily workbooks. labelled sequentially (2017.08.14, 2017.08.15, 2017.08.16 etc), have tried several formulas insert full address string , tend end ref! quite happy use vba solution, or approach doesn't involve manually opening , copying several values on 1500 spreadsheets. the answer feel might closest when attempted; =indirect("'s:\reports\2017["&e2&"]totals'!$c$17") e2 refers cell containing date string today, , c17 tthe target cell in other workbook, despite fact following step step produces =indirect("'s:\reports\2017[2017.08.19]totals!$c$17) still produces ref!, though typing formula in cell works fine.

MemoryError when passing big QuerySet from Views to Template (Django, PostgreSQL) -

i'm building gis-related web application, , way displays contents of database on map pretty straightforward: view collects several (currently 122) geojson files , passes them template. template iterates of them , displays them (using leaflet). however, cannot manage make work, every attempt results in memory error. the database i'm using postgresql one, in case helps. i'm using textfield in model, possible source of issue? any advice appreciated :) the view: geodata = geojsondata.objects.filter(connection = my_con).iterator() view = "map" return render(request, "map.html", {'geojsondata': geodata}) the template: {% dat in geojsondata %} {% dat.name name %} {% dat.geodata gj %} {{gj}} l.geojson(name).addto(map); {% endwith %} {% endwith %} {% endfor %} the model: class geojsondata(models.model): name = models.charfield(max_length=2000, unique=true) connection= models.foreignkey(connection, related_name='connecti...

How to cast binary into a string in python -

for infosec projects i'm using strings kind of byte array. commonly done in vulnerability testing. in building byte array, want concatenate printable characters , nonprintable characters. this not question of conversion, want cast type. write function or method around chr(), there must better way. >>> print "a"*10 + chr(0x20) + "b"*10 aaaaaaaaaa bbbbbbbbbb e.g., if have large binary array insert? >>> print "a"*10 + 0xbeef + "b"*10 traceback (most recent call last): file "<stdin>", line 1, in <module> typeerror: cannot concatenate 'str' , 'int' objects >>> print "a"*10 + 0xbeefbeefbeefbeefbeefbeef + "b"*10 traceback (most recent call last): file "<stdin>", line 1, in <module> typeerror: cannot concatenate 'str' , 'long' objects i may using wrong data types here because i'm pretty sure i'm not ...

java - org.postgresql.util.PSQLException: ERROR: column user0_.id does not exist - Hibernate -

Image
i have model class mapped postgres database using hibernate. model class is: @entity @table(name="user") public class user { @id @generatedvalue @column(name="id") private long id; @column(name="username", unique=true) private string username; @column(name="email") private string email; @column(name="created") private timestamp created; public user(long id, string username, string email) { this.id = id; this.username = username; this.email = email; } } i try retrieve user username "adam" using below query: tx = session.begintransaction(); typedquery<user> query = session.createquery("from user u u.username = :username", user.class).setparameter("username", "adam"); user = query.getsingleresult(); i exception says: org.postgresql.util.psqlexception: error: column user0_.id not exist my database bash ...

javascript - update a function defined in html file from a js file -

i defined function in html file returns center of map: <script> rf = function (){ return map.getcenter().wrap(); }; </script> <script src='./f.js'></script> then call function "f.js", by: var center = (rf()) the problem when move map center same before. thanks ps: function works in console. when move map should run center = (rf()) set center again because center not change result of map.getcenter().wrap()

angularjs - New to Typescript & Angular problems with Http Post -

Image
i'm new angular , typescript , try create simple login page. i've created service in typescript invoked when user presses 'login' button. textboxes contains username , password bound correctly model, when send request backend written in c#, not hit breakpoint suspect because of format of message being sent on wire. so using postman , i'm able invoke service , access_token when exporting request code in postman nodejs variant like: var request = require("request"); var options = { method: 'post', url: 'http://localhost:8081/login', headers: { 'postman-token': '34dd4d0f-ff16-db4f-ebae-dab945729410', 'cache-control': 'no-cache', 'content-type': 'application/x-www-form-urlencoded' }, form: { username: 'test', password: 'test', grant_type: 'password' } }; request(options, function (error, response, body) { if (error) throw new error(error); ...

java - Do Hibernate table classes need to be Serializable? -

i have inherited websphere portal project uses hibernate 3.0 connect sql server database. there 130 hibernate table classes in project. implement serializable. none of them declare serialversionuid field, eclipse ide shows warning of these classes. is there actual need these classes implement serializable? if so, there tool add generated serialversionuid field large number of classes @ once (just make warnings go away) ? is there actual need these classes implement serializable? the jpa spec (jsr 220) summarizes pretty (the same applies hibernate): 2.1 requirements on entity class (...) if entity instance passed value detached object (e.g., through remote interface), entity class must implement serializable interface. so, strictly speaking, not requirement unless need detached entities sent on wire tier, migrated cluster node, stored in http session, etc. if so, there tool add generated serialversionuid field large number of classes @ ...

Nested JSON Object with array in PHP -

i want json object follows in personal, address , itm have sequence of json object. { "id": "1", "state": "12", "personal": [ { "name": "abc", "contact":"1111111" "address": [ { "line1": "abc", "city": "abc", "itm": [ { "num": 1, "itm_detatils": { "itemname": "bag", "rate": 1000, "discount": 0, } } ], "status": "y" } ] } ] } but getting result follows in want json array @ address , itm_details. { "id": "1", "state": "12", "personal": [ { "name...

javascript - Printing a PDF file in Django -

i want create in django project physically prints pdf file in filefield of model object onto paper. so: class pdf(models.model): pdf = models.filefield(upload_to='pdffiles/', blank=true, null=true} the main thing want make link creates popup using javascript contains input field user puts name of pdf object's filefield , button says "print" triggers physical printing function (including opening print dialog box). supposed use forms or views in order make function, , if i'm supposed use javascript activate printing function, how it? thanks. edit: i'm thinking of using print.js. tell me how implement print.js in django project? files git repository need insert , how link them templates? if following question , think can using solution; in views.py from django.conf import settings django.shortcuts import get_object_or_404 yourapp.models import pdf def pdf_viewer(request, pk): obj = get_object_or_404(pdf, pk=pk) pdf_full_pat...

positioning - OpenCV: Tracking movement of phone device -

i'm looking track of phone device running app has moved, , if direction. i'm thinking incoming frames camera need analyzed track movement? i've looked around internet , have not going regarding this. assist me or point me towards right direction?

c# - How can I set cursor position with OpenTK? -

i working on fps camera latest version of opentk (2.0.0.0) , want use mouse delta movement control pitch/yaw of camera. need reposition cursor center of window cannot find way set cursor position. looked under gamewindow.mouse , gamewindow.cursor , found way cursor position, not set it. how set cursor position ?

javascript - How to filter elements from an array until specific string -

i'm trying filter out elements array until specific string, in case day names (mon, tue, wed etc.) variable: var day = new date(reservation.startdate); i have array of elements , i'm using the push() method add them inside array. here array: console.log(json.stringify(arraydata, null, 4)) [ "<b>mon</b>", "<b>aut14</b>", "<b>kl25ab55200-3001</b>", "<b>mon</b>", "<b>aut15</b>", "<b>kc23dk20010-3003</b>", "<b>tue</b>", "<b>ti14</b>", "<b>kl04bt10110-3001</b>", "<b>tue</b>", "<b>aut15</b>", "<b>kl25ab10451-3001</b>", "<b>tue</b>", "<b>aut13</b>", "<b>aut13</b>", "<b>kl25...

html - Div box not displaying right away down to the previous -

i made div blocks if 1 of block inside row more higher ( more data inside block ) next row blocks display not right away col-md-4 block after previous col highest block. see in picture. how remove space between first row blocks? :) code : <div class="row"> <div class="col-md-4">box</div> <div class="col-md-4">box</div> <div class="col-md-4">box longer</div> <div class="col-md-4">box</div> <div class="col-md-4">box</div> <div class="col-md-4">box</div> </div>

ios - Building app fails on iPhone but succeeds on simulator -

i trying create app scan business cards. made project , building fine , working. included tesseract library cocoapods , started giving me errors linker command failed error , that. turned bitcode off suggested. worked fine ios simulators when select real device or generic device, again gives me same error. don't know problem is. tried lot of solutions couldn't 1 work. clang: error: linker command failed exit code 1 (use -v see invocation) i unable figure out. took day , couldn't work. can please tell me how solve it. have iphone 5s using testing. please me through problem.