Posts

Showing posts from March, 2013

javascript - why only height is adjustable of parent div if child div is resizeable? -

i new in html development . sharing simple code have 2 div . 1 div parent div , second div it's child div .so problem when resizing child div height adjustable when resizing chid div right side width of parent div not adjustable want . please me . following code : <div style='border:1px solid;padding:20px;width:auto;height:auto;'> <div style="resize: both;overflow:auto;border:1px solid;width:500px;height:200px;"/> </div> you have use display: inline-block . .first { border:1px solid; padding:20px; width:auto; height:auto; display: inline-block; } .second { resize: both; overflow:auto; border:1px solid; width:500px; height:200px; } <div class="first"> <div class="first"> <div class="second"></div> <br> <div class="second"></div> </div> </div>

python - Why am I getting SQLAlchemy Error "__table_args__ value must be a tuple, dict, or None" -

i have following sqlalchemy model. has been migrated database: class myclassa(db.model, timestamp): a_id = db.column(db.integer, nullable=false, primary_key=true) b_id = db.column(db.integer, db.foreignkey(c.c_id), nullable=false) d = db.column(db.string(1024)) e_id = db.column(db.integer, db.foreignkey(e.e_id)) now want add uniqueness constraint across second , fourth fields. add following line model: __table_args__ = db.uniqueconstraint('b_id', 'e_id', name='unique_constraint_bid_eid') but when try migrate it, following error: sqlalchemy.exc.argumenterror: __table_args__ value must tuple, dict, or none why getting error? , how can fix it? tried putting right side of equation in parenthesis, didn't fix it. table_args supposed tuple, dict, or none error code suggests. if make tuple must put value in parenthesis , have comma in there @ end: try: __table_args__ = (db.uniqueconstraint

mysql - Give argument php function to show database results in another file -

hello gays have php code connect database works fine. $servername = "localhost"; $username = "root"; $password = ""; $dbname = "cv"; // create connection $conn = new mysqli($servername, $username, $password, $dbname); mysqli_set_charset($conn,"utf8"); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } $sql = "select * services"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "id: " . $row["id"]. " - name: " . $row["service_name"]. " " . $row["service_desc"]. "<br>"; } } else { echo "0 results"; } $conn->close(); my question is: how create function getservices() , give argument show results in php file using foreach or while, this: <?

c - Not able to build the kernel driver natively -

i building kernel on test machine on have insert module. makefile : obj-m += my-driver-module.o all: make -c /lib/modules/$(shell uname -r)/build m=$(pwd) modules clean: make -c /lib/modules/$(shell uname -r)/build m=$(pwd) clean but getting error : make[1]: *** /lib/modules/4.4.16-bone11/build: no such file or directory. stop. makefile:4: recipe target 'all' failed make: *** [all] error 2 i checked in /lib/modules/4.4.16-bone11/ directory in test machine , found build symbolically linked sources(path development machine) built kernel test machine : build -> path-in-my-development_machine-kernel-location-for-test-machine>/bb-kernel/kernel i downloaded headers using command : sudo apt-get install linux-headers- uname -r , able build module same makefile when trying insert it says : insmod: error: not insert module my-driver-module.ko: invalid module format how can resolve it. driver works expected when cross-compiled , inserted.

java - Hibernate: how to set relations (annotations) in a more complex model? -

i have following simplified model: business - (1:n) - assignment - (n:1) - process the model classes have following annotation: business @lazycollection(lazycollectionoption.false) @onetomany(mappedby = "business", cascade = cascadetype.all, orphanremoval = true) private list<assignment> assignments; assignment normally 1 avoid creating separate model class here, because business , process have n:m relation. need add attributes assigment itself. @manytoone @joincolumn(name = "business_id") private business business; @manytoone @joincolumn(name = "process_id") private process process; process @lazycollection(lazycollectionoption.false) @onetomany(mappedby = "process", cascade = cascadetype.all) private list<assignment> assignments; requirements when business or process deleted, want assignments deleted (but not partner of relation on @onetomany side) when assignment deleted, not want remove both @onetomany

javascript - How to remove the line/rule of an axis in Chart.js? -

Image
i managed remove horizontale lines/rules in chart using this: scales: { xaxes: [{ gridlines: { display: false } }] } but want rid of rule/bar represents y-axis well. but want keep labels : unfortunately can't find option that. can remove whole axis including labels. i'm using chart.js 2.3. i found way remove line. it's called border of axis , there's option it, see "grid line configuration" : scales: { yaxes: [{ gridlines: { drawborder: false, } }] }

Is there way to package Tensorflow for c++ api? -

i've been developing c++ project using tensorflow c++ api. execute created tensorflow's graph python. build using bazel tensorflow code now. think it's inefficient way. i want tensorflow library , header files, , compile project using cmake. i know how build shared library. bazel build -c opt --config=cuda //tensorflow:libtensorflow.so command make libtensorflow.so file. can't find header files build project. is there way package tensorflow library c++? such mvn package command. when building against shared library, headers use in $project_home/bazel-genfiles . adding $project_home/bazel-genfiles linker header list should enough.

python matplotlib : plot vertical_barplotcolor with classes -

Image
i'm looking tips or 2 make vertical parallel barplot (or rectangles) different colours according data. example, plot of data = [1,1,1,2,2,1,3,3,3,2,2,2,3,3,3,3] like: that done matplotlib. following code produces result above import matplotlib.pyplot plt import numpy np data = [1,1,1,2,2,1,3,3,3,2,2,2,3,3,3,3] col= [none, '#1620c0', '#e11239', '#2f9007' ] colors = [col[d] d in data] fig = plt.figure(figsize=(5,4)) ax = fig.add_axes([0,0,1,1]) # create bar plot # postions of bars , 1 in height , 1 in width , color according data, no line ax.bar(np.arange(len(data)), np.ones(len(data)), np.ones(len(data)), color=colors, linewidth=0 ) plt.axis('off') plt.show() update: in case need picture of 8 x 5000 pixels, need make sure save according resolution. following code produces png image of dimensions 8 x 5000. import matplotlib.pyplot plt import numpy np data = np.random.randint(1,4, 5000) col= [none, '#1620c0&

error in editting binary file using sed command -

i trying remove lines in binary file(.bam) , make new 1 small example. tried sed command did not work , gave nothing. have this(when print using command : samtools view -h myfile.bam ) @sq sn:5 ln:151834684 @sq sn:6 ln:149736546 @sq sn:7 ln:145441459 @sq sn:8 ln:129401213 @sq sn:9 ln:124595110 @sq sn:gl456210.1 ln:169725 @sq sn:gl456211.1 ln:241735 @sq sn:gl456212.1 ln:153618 @sq sn:gl456213.1 ln:39340 @sq sn:gl456216.1 ln:66673 @sq sn:mt ln:16299 @sq sn:x ln:171031299 and want this: @sq sn:5 ln:151834684 @sq sn:6 ln:149736546 @sq sn:7 ln:145441459 @sq sn:8 ln:129401213 @sq sn:9 ln:124595110 @sq sn:mt ln:16299 @sq sn:x ln:171031299 here command used: samtools view -h accepted_hits.bam | sed -v 's/sn:gl456210.1/' | samtools reheader - accepted_hits.bam > mybamfile.reheadered.bam and when tried -e instead of -v gave error: sed: -e expression #1, char 16: unterminated `s' command

view - The best practices for aggregation and storing aggregated data in SQL SERVER -

i have table playercards(football cards, yellow/red) many rows. 3 rows example : id | playerid | matchid | cardtype | minute ------------------------------------------- 1 | 10 | 134 | yellow | 56 2 | 12 | 134 | red | 89 3 | 11 | 134 | yellow | 71 i have table playergoals many rows. 3 rows example id | playerid | matchid | goaltype | minute | assitid ----------------------------------------------------- 1 | 10 | 134 | penalty | 34 | null 2 | 12 | 134 | null | 44 | 16 3 | 11 | 134 | null | 48 | 18 and there other table player's actions data. i need show website users variations of aggregated data. example: for each match each users numbers of goals, cards, playedminutes , on. sum of goals in season, sum of cards, minutes etc. avg of goals per match, avg of cards. data updated after end of match. each player every 3-5 days. i need best practices, adv

Why my Python Click command is not working? -

here project code structure: pynique ├── cli │   ├── __init__.py │   └── pynique_ops.py ├── pynique │   ├── __init__.py ├── readme.md ├── setup.cfg └── setup.py my setup.py content is: from setuptools import ( find_packages, setup ) print find_packages() setup( name='pynique', version='0.1.1.dev1', description='pynique app', classifiers=[ 'development status :: 2 - pre-alpha', 'license :: osi approved :: mozilla public license 2.0 (mpl 2.0)' ], packages=find_packages(exclude=['tests']), include_package_data=true, install_requires=[ 'jinja2', 'pyyaml', 'click' ], entry_points=''' [console_scripts] start-pynique=pynique.cli.pynique_ops:start ''', ) i've done inside pynique top folder project: - pip install -e . but start-pynique not working, throws error: traceback

makefile - How to remove file name extension in a loop with Make? -

assume there directory contains foo.c , bar.c , makefile . content of makefile is: loop: @for f in $(wildcard *.c) ; \ echo $$f ; \ echo $(basename $$f); \ done running make prints out following text: bar.c bar.c foo.c foo.c what want is: bar.c bar foo.c foo so seems basename has no effect in loop. how can make basename work? your loop not working in make , it's bash loop. if want similar behavior in make eeze, can have loop: $(foreach f, $(wildcard *.c), \ echo $f; \ echo $(basename $f);) or loop: $(foreach f, $(wildcard *.c), \ $(info $f) \ $(info $(basename $f))) the bash eese way strip prefix is: loop: @for f in $(wildcard *.c) ; \ echo $$f ; \ echo $${f%.c} ; \ done

python - multiprocessing.Process hangs -

edited: question needs more info... my code launches several process one: def my_process_executor(req, semaphore=none): try: p = multiprocessing.process(target=do_stuff,args=(req,)) p.daemon = false p.start() p.join(max_seconds_waiting_for_process) if p.is_alive(): # time running, kill it! p.terminate() p.join() finally: if semaphore: semaphore.release() when "semaphore" none, works fine, ton of concurrent processes. but when "semaphore" has value: semaphore = threading.boundedsemaphore(5) sometimes subprocess never starts. despite process.is_alive() returns true, do_stuff doesn't anything. any idea? what's happening here? pay attention do_stuff not check semaphore. doesn't hangs due "red light" on semaphore. code running on ubuntu 14.04.4 lts , python 2.7

elk stack - elasticsearch x-pack not playing nicely with nginx reverse proxy -

i using nginx reverse proxy secure elk stack , working fine. recently, decided install x-pack monitoring features. however, not want use it's security features have nginx. but, these settings(in both elasticsearch.yml , kibana.yml) aren't working out, still getting xpack login prompt xpack.security.enabled: false . how disable x-pack log-in prompt. moreover, how getting prompt without first needing authenticate myself nginx reverse proxy?

ios - Xcode 8 - Could not build module 'CoreFoundation' in ios10 -

Image
using xcode 8 . ios 10 objective-c pod file consist :- pod 'xmppframework' i want integrate xmppframework in project. installed pods. after installing pods when open xworkspace . these errors comes. podfile :- uncomment next line define global platform project platform :ios, ‘8.0’ target 'roj' # uncomment next line if you're using swift or use dynamic frameworks # use_frameworks! # pods roj pod 'xmppframework' target 'rojtests' inherit! :search_paths # pods testing end target 'rojuitests' inherit! :search_paths # pods testing end end these errors comes in project see image try solution in build settings ;

javascript - Multiple Contrllers in UI-router -

i have application uses angularjs , use ui-rourer routing i need have multiple controller single page, possible ? this route.js code .state(route.appgroup, { abstract: true, views: { 'content@': { templateurl: global.viewpath + '/index.html', controller: 'appctrl' } } }) i need .state(route.appgroup, { abstract: true, views: { 'content@': { templateurl: global.viewpath + '/index.html', controller: 'appctrl,mainctrl' } } }) can help? each view , has controller . and while state can have more views (differently named) - each view can have 1 contro

I want to fetch macros name in excel 2007 and save it in text file automatically using vbscript -

i want fetch macros name in excel 2007 , save in text file automatically using vbscript. done using vb6 here code private sub form_load() ' declare variables access excel workbook. dim objxlapp excel.application dim objxlworkbooks excel.workbooks dim objxlabc excel.workbook ' declare variables access macros in workbook. dim objproject vbide.vbproject dim objcomponent vbide.vbcomponent dim objcode vbide.codemodule ' declare other miscellaneous variables. dim iline integer dim sprocname string dim pk vbext_prockind dim macro_name string dim ifileno integer dim integer open "d:\file\macro.txt" append #1 ' open excel, , open workbook. set objxlapp = new excel.application set objxlworkbooks = objxlapp.workbooks set objxlabc = objxlworkbooks.open("c:\users\macro\macros.xls") ' empty list box. list1.clear ' project details in workbook. set obj

javascript - Property file for js and pom.xml -

i need maintain jquery , knockout versions across project. want have single property file version information read js files pom.xml (maven file). how can achieve this? type of property file should create e.g. json, xml or properties? how access js , pom.xml?

objective c - iOS: Open a Calendar app New Event screen with populated date -

is possible redirect user calendar app new event screen programmatically populated start , end dates? aware of introduction calendars , reminders , seems overkill. have tried calshow:// , didn't seem work either or couldn't find correct scheme. @import eventkit; @import eventkitui; then present eventkit using this: - (ibaction)scheduleclicked:(id)sender { ekeventstore *eventstore = [[ekeventstore alloc]init]; if([eventstore respondstoselector:@selector(requestaccesstoentitytype:completion:)]) { [eventstore requestaccesstoentitytype:ekentitytypeevent completion:^(bool granted,nserror* error){ if(!granted){ nsstring *message = @"hey! project can't access calendar... check privacy settings let in!"; dispatch_async(dispatch_get_main_queue(), ^{ // present alert warning. }); }else{ ekeventeditviewcontroller *addcontroller = [[ekeventeditviewcontroller alloc] initwithnibname:nil bundle:nil

Jsonpath :-Should contains root object as well -

i have 1 requirment want result should contain root object well. example data below:- { "data": [ { "name": "barack obama", "category": "politician", "id": "6815841748" }, { "name": "barack obama's dead fly", "category": "public figure", "id": "92943557739" }] } and condition name=="barack obama" result should below :- { "data": [ { "name": "barack obama", "category": "politician", "id": "6815841748" }] } can please suggest experssion ?

python - unable to list collections in azure document db with mongodb protocol support -

Image
i using python3 (pymongo) connect azure document db mongo protocol support. # reference connection string self.connection_string = "mongodb://<user>:<pw>@<location>:<port>/<database>?ssl=true" # creates connection (this working) self.mongo_client = mongoclient( self.connection_string ) # show databases , there collections print(self.mongo_client.database_names()) db_name in self.mongo_client.database_names(): print(db_name,">",self.mongo_client[db_name].collection_names()) running above snippet of code lists databases collections not listed. running on local mongo db works expected. i trying run query on known collection within database however, can't seem able that. have mongochef connected , working expected (able run querys). any ideas doing wrong? @greener, issue seems caused pymongo , not documentdb mongodb protocol . i tried connect documentdb mongodb protocol using third party tool robomongo

reactjs - If <notFound/> component get executed add class to <footer/>component . React-Redux -

if < notfound /> rout executed (i.e : if not found page rendered want add class footer component. below index.jsx render function render() { return ( <div> <navbar /> <div classname="pagedata"> {this.props.children} // <notfound/> component rendered here </div> <footer/> <loginpopup /> </div> ) } below routes.jsx import react 'react' import { route, indexroute } 'react-router' import app 'layout/app' import home 'pages/home' import mywagers 'containers/mywagerscontainer' import wagers 'containers/wagerscontainer' import notfound 'pages/notfound' const routes = ( <route path='/' component={app}> <indexroute component={home} /> <route path="/wagers(/:trackcode)(/:racenum)" component={wagers} >

How to make an audio palyer widget in android -

i want make audio player widget in have added there buttons play , next , previous.widget should show title progress of song on seek bar , image if available same. i unable find how can play songs ,can go previous or next song , how show progress on seek bar through audio widget. following appwidgetprovider class have created this. public class audiomusicwidgetprovider extends appwidgetprovider { public static string action_widget_receiver = "playactionreceiverwidget"; textview songtitle; arraylist<song>arraylist; @override public void onupdate(context context, appwidgetmanager appwidgetmanager, int[] appwidgetids) { // todo auto-generated method stub remoteviews remoteviews = new remoteviews(context.getpackagename(), r.layout.musicplayerwidget); toast.maketext(context, "onupdate", toast.length_short).show(); getsongslist(context); intent action = new intent(context, au

visual c++ - How to compile Qt 3.3.6 for use in VC2012? -

i need compile qt 3.3.6 on win 7 pc use in combination msvc2012 c++ compiler (msvs 2012 professional). the simple reason have qt 3.3.6 license , lot of qt 3.3.6 source code. so, qt upgrade not option. "google" not help... edited:16/11/10 1:40 pm i tried compile starting shell via vs2012 (tools/visualstudiocommandprompt) , changing cwd qt directory containing appropriate makefile: c:\qt\3.3.6>bin\configure.exe -redo -spec win32-msvc2012 license file not found in c:/users/mdew enterprise modules not available. qmakespec...................win32-msvc maketool....................nmake [...list of installed programs...] configuration: nocrosscompiler dialogs iconview kernel styles tools widgets workspace minimal-config small-config medium-config large-config full-config release thread no-gif zlib jpeg mng png bigcodecs no-tablet debug symbols...............no thread support....

jquery - Animations in Javascript and CSS -

i'm not sure if right place ask this, want know how complex animations done in web apps. i'm complete noob when comes animations. other simple animations can apply transitions in css (fade in, fade out adding , removing class), have 0 experience in more advanced animations/transitions. i have no clue start or learn how this. let me elaborate more. i'm talking transitions this: https://uimovement.com/ui/2699/appless/ what want know is, are these done in pure css? if javascript used, keep code? keep separate files animations? are there frameworks sort of thing? what technologies should @ learn more? i'm sorry if question not within guidelines. i'm lost in area. points started appreciated.

mysql - Writing a PDO search query from a PHP array -

i'm building application using php 7 , pdo connection mysql database. one part of application contains search form allows user search training course 3 different fields: course category, course name, , date. the types of elements on form are: course category - dropdown, numerical (int) id's. course name - text input date - date picker (using html 5 type="date" parameter calendar in browser). these fields can used in conjunction, or on own. means user search, example, (1), or (2 & 3), or (1 & 2 & 3). i've written php post data , it's in array - example: $search_data = [ 'category' => 3, 'name' => 'hazard training', 'date' => '' ] i want use within pdo query don't know best way write because (1) , (3) = query condition, whereas (2) like . solution going looping through search terms , trying construct query, e.g. $sql = ' '; foreach ($search_data $key =&

java - How to move marker along polyline using google map -

Image
i trying move marker according polyline , animation. similar below image: mapbox giving kind of demo. want achieve same using google maps. right marker not rotating along path. here have tried: private void onready(list<latlng> polyz) { (int = 0; < polyz.size() - 1; i++) { latlng src = polyz.get(i); latlng dest = polyz.get(i + 1); polyline line = map.addpolyline(new polylineoptions() .add(new latlng(src.latitude, src.longitude), new latlng(dest.latitude, dest.longitude)) .width(2).color(color.red).geodesic(true)); } latlngbounds.builder builder = new latlngbounds.builder(); builder.include(polyz.get(0)); builder.include(polyz.get(polyz.size()-1)); map.movecamera(cameraupdatefactory.newlatlngbounds(builder.build(), 48)); map.animatecamera(cameraupdatefactory.zoomto(7), 1000, null); bitmapdescriptor icon = bitmapdescriptorfactory.fromresource(r.drawable.ca

ubuntu - Apache redirect sub domain to main domain conditionally -

i have 1 domain , sub domain cloud.example.com , example.com. i need redirect cloud.example.com example.com following condition. cloud.example.com www.example.com/customers/login cloud.example.com/<any url> www.example.com/<any url> i have added bellow code in apache config file of cloud.example.com servername cloud.example.com redirect 301 / https://www.example.com/customer/login now cloud.example.com redirecting https://www.example.com/customer/login other pages not working .that redirecting www.example.com/customer/login how solve issue? the best way use rewrite rules. rewriterule ^/$ https://www.example.com/customer/login [r] rewriterule ^/(.+) https://www.example.com/$1 [r] dont forget add module , enable rewriteengine

rest - Golang: Broadcast messages to websocket when a particular POST JSON is received -

i have app connected goserver using websocket . used code create websocket connection - https://github.com/gorilla/websocket/tree/master/examples/chat http.handlefunc("/ws", func(w http.responsewriter, r *http.request) { servews(hub, w, r) }) when receive post call need broadcast message - "order received: " productnum devices. productnum received in post request. http.handlefunc("/post",broadcastmessage()) i want know need write in broadcastmessage() this. please help. in broadcastmessage, send []byte hub's broadcast channel: hub.broadcast <- message

Restangular get in angularjs -

i using function of restangular. , in return object have customers , other functions of restangular these functions of restangular not associated list of customer. why? there other way? use .plain() this. restangular.one('accounts', 1234) .then(function (account) { account.plain(); // object whitout restangular methods });

jquery - paste email to input and validation right away. -

function checkemail(){ // set variable var email_target = $("#signupmenu-emailinput"); var email_value = email_target.val(); var email_errorspan = $("#email-errorresult"); var emailpass_boolean; if(email_value === ""){ // email empty email_errorspan.html("please enter email."); email_errorspan.css("color", "red"); email_target.css("border-color", "red"); }else if(email_value > 0){ email_errorspan.html("pass."); email_errorspan.css("color", "red"); email_target.css("border-color", "red"); } } $(document).ready(function(){ // singup email input $("#signupmenu-emailinput").bind({ keyup : function(){ checkemail(); }, paste : function(){ checkemail(); } }); }); my intention validation went user copy past on input , validation right away , s

android - how to pass and fetch data when using ampersand in sql -

im trying pass url fetch data android json. the url is: fetch_cat_url = "xxx/get_product_details.php?task_name=get_cat&cat_name="+cat_name; where cat_name="books & more" when pass url.. goes xxxxx/get_product_details.php?task_name=get_cat&cat_name=books & more in sql file switch($_get["cat_name"]) { case "fashion": $sql = "select * `category` c_name in (\"men\",\"women\" ,\"baby & kids\") "; break; case "home & living": $sql = "select * `category` c_name in (\"kitchenware\", \"home furnishing\", \"home decoratives\", \"furniture\") "; break; case "books & more": $sql = "select * `category` c_name in (\"academic text\", \"literature & fiction\", \"non fiction\&

java - How to use UriComponentsBuilder in non-servlet environment? -

the docs state if i'm not within servlet calling thread, still want make use of uricomponentsbuilder (eg in batch import), use servleturicomponentsbuilder.fromcurrentcontextpath() . @see https://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#mvc-uri-building i tried follows docs: public string createurl() { uricomponentsbuilder base = servleturicomponentsbuilder.fromcurrentcontextpath().path("/en"); mvcuricomponentsbuilder builder = mvcuricomponentsbuilder.relativeto(base); builder.withmethodcall(on(bookingcontroller.class).getbooking(21)).buildandexpand(42); uri uri = uricomponents.encode().touri(); return uri.tostring(); } for testing non-servlet call: @postconstruct public void init() { builder.createurl(); } but getting exception: caused by: java.lang.illegalstateexception: not find current request via requestcontextholder @ org.springframework.util.assert.state(assert.java:392) ~[spring-core-4

Scripting Glottolog Database into MySQL database -

i need script glottolog db file mysql db. db in postgresql , large, have scripted databases mysql importing table records i'm raising concern because file large. tables 124. appreciate.

TYPO3 Extension don't get Records -

i had create extension, tutorial https://docs.typo3.org/typo3cms/extensions/fluid_styled_content/7.6/addingyourowncontentelements/index.html in fluid-template only: array(2 items) data => array(105 items) current => null "data" have fields of tt_content. have field "pages", can general storage datasets come from. cannot records push fluid-template. on dataprocessor can't use repository , controller isn't used. what wrong?

solr - web crawling using apache Nutch -

i new apache-nutch/solr . trying crawl websites using it. tried goggling out couldn't required information. example lets take website , need title ,headers, content . how supposed start or valid links appreciated . these 2 step step. https://www.youtube.com/watch?v=o54o6aepqsm https://www.youtube.com/watch?v=vwdf8xcwegs

uiscrollview - Remove top space on zoom image -

i have code load , zoom image: import foundation import uikit class imagepreview: uiviewcontroller, uiscrollviewdelegate { var imageurl = "" var scrollviewimage = uiscrollview() var imagepreview = uiimageview() override func viewdidload() { super.viewdidload() scrollviewimage.delegate = self scrollviewimage.maximumzoomscale = 5.0 scrollviewimage.minimumzoomscale = 1.0 scrollviewimage.frame = cgrect(x: 0, y: self.view.center.y / 2, width: self.view.frame.size.width, height: 300) imagepreview.frame = cgrect(x: 0, y: self.view.center.y / 2, width: self.view.frame.size.width, height: 300) self.view.addsubview(scrollviewimage) scrollviewimage.addsubview(imagepreview) imagepreview.image = uiimage(contentsoffile: imageurl) } func viewforzooming(in scrollview: uiscrollview) -> uiview? { return imagepreview } } after zoom have space before image (top on it). how can remove it? p

ios - Addsubview custom xib file error -

Image
i'm using swift 3, have error adding xib file subview let bundle = bundle(for: type(of: self)) let nib = uinib(nibname: "customview", bundle: bundle) let view = nib.instantiate(withowner: self, options: nil)[0] as! uiview view.frame = bounds view.autoresizingmask = [.flexiblewidth, .flexibleheight] self.addsubview(view); can me please? in custom view class implemented follow: import uikit @ibdesignable class testview: uiview { override init(frame: cgrect) { super.init(frame: frame) loadviewfromnib() } required init?(coder adecoder: nscoder) { fatalerror("init(coder:) has not been implemented") } func loadviewfromnib(){ let view = bundle.main.loadnibnamed("test", owner: self, options: nil)?.first as! uiview print(view.backgroundcolor ?? uicolor.blue) } } then in viewcontroller want add custom view write below: let view = testview() and don

python - Is it OK to name an instance the same as a module? -

i find 'natural' name both module containing class definition , instances of class in lowercase, , use camel-case class name. example, want this: in [2]: publisher import publisher in [3]: publisher = publisher() here have module named publisher , instance of publisher called same way. seems module , instance both 'work' expected: in [4]: publisher import randomdata in [5]: publisher.random.uuid() out[5]: 'c490508d-2071-536e-2f38-4b03b04351e1' where i've imported class module , called instance method. python 'understand context' whether mean module or instance? ok re-use names in way? you not shadowing anything, no name being reused here. name publisher not being used in namespace until created instance publisher = publisher() . if tried use name publisher right after from publisher import publisher line, you'd nameerror exception. that's because from <module> import <name> form sets <name> i

single page application - websharper access to rpc from another site (SPA) -

i've got client-server (with transpiled js , rpc calls server) application websharper, , runs fine. now need single javascript file site (a wordpress app) , script, i'd access public (non protected rpc) made in former client-server application. the ideal able use websharper spa template , "link" client-server project. i've got 2 problems: - first, rpc signature encoded hash seems local app (no simple way reproduct hash outside it) - second, apparently there no way link generated dll client-server app new spa template , use exported rpc method signatures spa. am missing something, how make work ? regards, referencing client-server application spa should work fine; need make sure points right url calling following somewhere in spa: websharper.remoting.endpoint <- "http://your-client-server-application's-url"

php - preg_replace(): Parameter mismatch, laravel -

if(isset($newsportid['hockey'])){ $entries['hockey']['sport_id'] = (isset($newsportid['hockey'])) ? $newsportid['hockey'] : ''; $entries['hockey']['team_name'] = (isset($multisports[0]['team_name'])) ? $multisports[0]['team_name'] : ''; $entries['hockey']['position'] = (isset($multisports[0]['position_id'])) ? $multisports[0]['position_id'] : ''; $entries['hockey']['shot'] = (isset($multisports[0]['shot'])) ? $multisports[0]['shot'] : ''; } if(isset($newsportid['soccer'])){ $entries['soccer']['sport_id'] = (isset($newsportid['soccer'])) ? $newsportid['soccer'] : ''; $entries['soccer']['position'] = (isset($multisports[1]['position_id'])) ? $multisports[1]['position_id'] : ''; $entries['soccer'

java - How to specify a Generic Type as function parameter -

i want create jpa transaction jse app returns result. @suppresswarnings("unchecked") public static <t> t transaction(emworker worker, class<t>clazz){ entitymanager em = createentitymanager(); em.gettransaction().begin(); // >>> functional interface object result = worker.work(em); em.gettransaction().commit(); em.close(); return (t)result; } it works fetching single object : funkopop gandalf=emfactory.transaction( emanager -> { return emanager.find(funkopop.class, 1); }, funkopop.class); but now, want list of funkopop . list<funkopop> list =emfactory.transaction( e -> { string query = "select f funkopop f "; list<funkopop> l = e.createquery(query, funkopop.class).getresultlist(); return l; }, list<funkopop>.class); //won't compile ; or list.class gives warnings the transaction needs 2 arguments : lambda , class. approximatively understand canno

objective c - setBounds in Swift -

i'm trying convert objective-c app swift i'm stuck setbounds . original code looks this: - (void)setbounds:(cgrect)bounds { [super setbounds:bounds]; // code } what equivalent in swift? i've tried looking in documents , google can't seem figure out. you need override bounds : override var bounds: cgrect{ didset{ //your code here } }

javascript - Arrow function in object definition -

in javascript harmony, can example following: var maths = { sum (...args) { let r = 0; (let num of args) { r += num; } return r; } }; maths.sqr = n => n * n; i wondered if there way use arrow function, sqr within object definition, sum . you write literal. var maths = { sqr: n => n * n, sum (...args) { let r = 0; (let num of args) { r += num; } return r; } }; console.log(maths.sqr(5)); console.log(maths.sum(2, 4, 5));

java - What is port name of Raspberry pi3? -

i want send string "*" arduino. have java project. , working on computer. (i defined port name "com3") but after load project raspberry pi3, , tried send "*", fails. please @ code. problem simple, what must write instead of com3 control rasberry pi 3 usb port serialport seri=new serialport("com3"); private void btnbaslatactionperformed(java.awt.event.actionevent evt) { seri.openport(); seri.setparams(9600, 8, 1,0); seri.writestring("*"); }

c++ - Use of static data inside iostream header -

this question has answer here: c++ - initialize standard stream objects 2 answers i playing around on godbolt.org , , noticed "extra code" added compiler 'empty main()' iostream header included. after looking standards figured needed constructs , initializes objects cin , cout , cerr , clog , wcin , wcout , wcerr , , wclog, if have not been constructed/initialized. n4606: § 27.5.3.1.6 27.5.3.1.6 class ios_base::init [ios::init] namespace std { class ios_base::init { public: init(); ~init(); private: static int init_cnt; // exposition }; } but static data standard says counts number of constructor , destructor calls class init , , initialized zero. 2 sake of exposition, maintained data presented here as: (2.1) — static int init_cnt, counts number of constructor , destructor calls

Change the existing array key value in PHP -

my requirement show list of dates in array , time available in particular date. i got set logic struggling in 1 place, please down issue. i have array below, need change 'booked_from_time' 'from_time' dynamically ever want. how can achieve this, please me achieve solution it. <!-- array response --> [2016-11-25] => array ( [0] => array ( [from_time] => 00:00:00 [to_time] => 23:59:59 ) ) [2016-11-26] => array ( [0] => array ( [booked_from_time] => 2016-11-26 00:00:00 [booked_to_time] => 2016-11-26 16:00:00 ) [1] => array ( [booked_from_time] => 2016-11-26 16:00:00 [booked_to_time] => 2016-11-26 19:20:00 ) [2] => array ( [from_time] => 00:00:00 [to_time] =>

javascript - How to assign to .component() an isolated scope object, and to access it in it's template -

Image
i have daunting task ahead of me, rather new angularjs. help, or advise appreciated. goal achieve have controller loop through array of objects, each objects "compile" or "interpolate" component, each of these child component having isolated scope [i]-th object. i got component display objects value model, not isolated scope. , interpolation display markup string, gets value in it should. so in bit of trouble figuring out, how accomplish this. here code component: angular.module('mpwatchmodule').component('mpoint', { bindtocontroller: false, templateurl: '/ng-mpwatch/templates/mpoint.html', controller: mpdatacontroller, bindings: { mpdata:'<', } }); here template: <div> <h2>test</h2> <h1>{{$ctrl.testdata}}</h1> <h2>{{test}}</h2> </div> the page markup trying display: <li> <m-point mpdata="{{mpd.mpdata

awk - Find duplicate records with only text case difference -

i have log file 8m entries/records urls. i'd find duplicate urls (same urls) difference being type / text case. example: origin-www.example.com/this/is/hard.html origin-www.example.com/this/is/hard.html origin-www.example.com/this/is/hard.html in case, there 3 duplicates case sensitivity. output should count -c , new file duplicates. use typical awk '!seen[$0]++' file trick combined tolower() or toupper() make lines in same case: $ awk '!seen[tolower($0)]++' file origin-www.example.com/this/is/hard.html for different output , counters whatsoever, provide valid desired output.

php - Echo ALT attribute of random image -

i have little script displays random image, is: <img src="<?php echo bloginfo('template_url');?>/img/members/00<?php $random = rand(1,7); echo $random; ?>.jpg"alt="[ random image ]"> this makes image src src="example.com/images/001.jpg" alt="[ random image ]"> (1,7) in script adds number of image 001.jpg 007.jpg . now change "[ random image ]" in "$my_alt" , have display (echo) alt attribute of image in <h2 class="myalt">...</h2> tag. i'm not of coder, don't know how this. believe first need give my_alt value. go by: if {image src="example.com/images/001.jpg" $my_alt = "my first alt"} else if {image src="example.com/images/002.jpg" $my_alt = "my second alt"} and want value of alt placed add code: <h2 class="myalt"><?php echo $my_alt(); ?></h2> am doing correct, right way go? sai

jquery - How to create a name with as desired while reading for loop -

i reading json , construction table , during process reading inner array " video_details " while reading inner array need take first 3 elements , if there more elements need put ... (3 dots ) so looks (3 dots after 1 2 three) test 001 xxx 1 2 3 ... sertval var aajxresponse = { "tag_video_details": [{ "video_id": "369", "tag_name": "three", "video_name": "test 001", "video_file": "xxx", "video_details": [ "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" ] }] } $(document).ready(function() { updatetable(aajxresponse); }); function updatetable(aajxresponse) { var html = '<tr class="existingvideos">\ <t

python - Printing labels in a loop -

i want loop , plot file information -1 1 0.732313 -1 2 1.33585 -1 4 1.05306 -1 8 1.56261 -1 16 1.90336 -1 32 1.71105 -1 64 1.8319 which loaded mat0 have far: mat0 = genfromtxt("mydata") fig1 = plt.figure() ax = fig1.add_subplot(111) mybel =-1 count =0 while (count < 60): i=count j= i+6 plt.plot(mat0[i:j,1], mat0[i:j,2],label="size %s"%mybel) count = count + 7 mybel = mybel +1 plt.show() the problem not labels printed @ all. not error either. missing? you need call legend object. calling plt.legend() . mat0 = genfromtxt("mydata") fig1 = plt.figure() ax = fig1.add_subplot(111) mybel =-1 count =0 while (count < 60): i=count j= i+6 plt.plot(mat0[i:j,1], mat0[i:j,2],label="size %s"%mybel) count = count + 7 mybel = mybel +1 plt.legend() plt.show()

sql - Store DB columns values to string in Groovy -

i trying store sql query result string. def dblist = con.rows("select a.pkresourceitemsid,b.fieldvalue,a.fkresourceid,a.fkcountryid,b.fklocationid,b.fkbusinessunitid,b.floor tblresourceitems inner join tblresourceitemdata b on a.pkresourceitemsid=b.fkresourceitemid a.pkresourceitemsid='$id'" ) log.info "db_list = ${dblist}" the result getting: db_list =[[pkresourceitemsid:2000, fieldvalue:hello, fkresourceid:1, fkcountryid:1, fklocationid:88, fkbusinessunitid:518, floor:1]] the result want : db_list =[2000, hello, 1, 1, 88, 518, 1] what have tried : def = dblist.pkresourceitemsid it gives me result [2000] , can 1 column @ time. don't know how columns. how can achieve this? sql.rows(gstring query) returns list<groovyrowresult> why when make println of returned object get: [[pkresourceitemsid:2000, fieldvalue:hello, fkresourceid:1, fkcountryid:1, fklocationid:88, fkbusinessunitid:518, floor:1]] if instead of wan

computer vision - Caffe: variable input-image size for vgg network -

i trying use caffe extract features of convolution layer rather fc layer vgg network.the theoretical input image size may arbitrary in situation. seams vgg network trained on images cropped size 224x224 pixel. define input data layer in deploy.prototext: layers{ name: "data" type: memory_data top: "data" top: "label" transform_param{ mirror: false crop_size:224 mean_value:129.1863 mean_value:104.7624 mean_value:93.5940 } memory_data_param{ batch_size:1 channels:3 width:224 height:224 } } i tried modify width = 500\height = 500\crop_size = 500 failed. caffe throws errors:“ cannot copy param 0 weights layer 'fc6'; shape mismatch. source param shape 1 1 4096 25088 (102760448); target param shape 4096 131072 (536870912). learn layer's parameters scratch rather copying saved net, rename layer.” how possible can run on images big input layer without cropping? you should resize im