Posts

Showing posts from July, 2010

html - Jekyll: Using liquid tags in .md files -

i working on project using jekyll. looking online, seems possible use liquid tags in markdown file. reason, liquid tags not working in markdown files. want use liquid "capture" tag store text in variable , output variable in layout.html file. have listed related code below. page.md: --- page: approach layout: layout --- {% capture focus_content %} focus devices awesome. {% endcapture %} layout.html: <!-- layout.html file --> <div class="panel"> <div class="content-container panel-wrapper"> {{focus_content}} </div><!--end content container--> </div><!--end panel--> i know jekyll supports liquid templates. know why when define variable in markdown file, not output on webpage when include in html file? no way this. inside layout, things pages, posts , collections content , site , page variables. a capture made in page, post or collection not bubbling layout.

python - matplotlib argrelmax doesn't find all maxes -

Image
i have project i'm sampling analog data , attempting analyze matplotlib. currently, analog data source potentiometer hooked microcontroller, that's not relevant issue. here's code arrayfront = runningmean(array(datafront), 15) arrayrear = runningmean(array(datarear), 15) x = linspace(0, len(arrayfront), len(arrayfront)) # generate x axis y = linspace(0, len(arrayrear), len(arrayrear)) # generate x axis min_vals_front = scipy.signal.argrelmin(arrayfront, order=2)[0] # min min_vals_rear = scipy.signal.argrelmin(arrayrear, order=2)[0] # min max_vals_front = scipy.signal.argrelmax(arrayfront, order=2)[0] # max max_vals_rear = scipy.signal.argrelmax(arrayrear, order=2)[0] # max maxvalfront = max(arrayfront[max_vals_front]) maxvalrear = max(arrayrear[max_vals_rear]) minvalfront = min(arrayfront[min_vals_front]) minvalrear = min(arrayrear[min_vals_rear]) plot(x, arrayfront, label="front pressures") plot(y, arrayrear, label="rear pressures") plot(x...

c# - LINQ query string[] group by multiple anonymous columns -

i have delimited file reading string array (file has no headers) , trying parse linq query. i want group multiple anonymous columns (using array indexes) , sum 1 of fields. for instance, have file in format: 1000200034,2015,abc,1 1000200034,2015,def,2 i want group first , second columns, disregard third, , sum fourth. so return: 1000200034,2015,3 when group single column, can result return sum: ienumerable<string[]> query = row in data row[0] == "1000200034" group row row[0] g select new string[] { g.key, g.sum(a=>int.parse(a.elementat(3))).tostring(), }; but if try add other column, no longer sum, both rows returned: ienumerable<string[]> query = row in data row[0] == "1000200034" group row new[]{row[0], row[1]} g ...

vb.net - Datagridview doesn't change colours when changing combobox values -

i have following problem datagrid. i have datagridview several columns coloured , combobox. first column of datagridview , "signal name" has same values combobox. my goal change color of row same signal name in combobox , leave others same initial colors. i have tried following code, doesn't "reset" initial colors when run it. instead, desired row's color correctly changed but, when change value combobox value, doesn't reset usual colours should , end 2 rows coloured. public sub combobox1_selka() handles combobox1.selectedvaluechanged dgv_sigdata.columns("target profit").defaultcellstyle.backcolor = color.fromargb(102, 255, 102) dgv_sigdata.columns("avg loss").defaultcellstyle.backcolor = color.fromargb(247, 197, 141) dgv_sigdata.columns("avg win").defaultcellstyle.backcolor = color.fromargb(102, 255, 102) dgv_sigdata.columns("stop loss").defaultcellstyle.backcolor = color.fromargb(...

r - output .eps graphics with 800 dpi -

a client needs graphics manuscript .eps format , 800 dpi. usually export tiff using tiff() res= argument , good. in fact i've never exported .eps before i've been googling around. i found this , has gotten me .eps file stage (though can't view file exported make sure looks right). far quick search via in r-studio has given me, can't change dpi. any help? current code looks like: seteps() postscript("whatever.eps", width = 7, height = 5) plot(rnorm(100), main="hey data") dev.off() i'm used units="in" , res=800 being included don't feel comfortable height , width args i've supplied , can't view file make sure looks right.

javascript - Ionic checkbox doesn't react on clicks -

i have simple view in ionic application: <ion-view view-title="search"> <ion-content> <ul class="list"> <li class="item item-checkbox"> <label class="checkbox"> <input type="checkbox"> </label> flux capacitor </li> </ul> </ion-content> </ion-view> problems is, nothing happens when push checkbox? edit: found problem, don't know why doesn't work. when add following menu.html checkbox stops working: <ion-tabs class="tabs-positive tabs-icon-only"> <ion-tab title="home" icon-on="ion-ios-filing" icon-off="ion-ios-filing-outline"> <ion-nav-view name="home"></ion-nav-view> </ion-tab> </ion-tabs> can explain why is? line: <ion-nav-view name="home"></ion-nav-view> that ruins it.. ...

slick.js - jQuery Slick Slider showing some empty slides -

i'm creating product slider using slick jquery plugin, in slider contents filled using js , later call slick function, slider slider seems working shows empty sliders has class .slick-cloned the site url the last slider working fine first 2 not, can me fix this below has dummy codes used slider <div class="sliderrs"> <div><h3>contents added js</h3></div> <div><h3>contents added js</h3></div> <div><h3>contents added js</h3></div> <div><h3>contents added js</h3></div> <div><h3>contents added js</h3></div> <div><h3>contents added js</h3></div> </div> . $(function(){ $('.sliderrs').slick({ slidestoshow: 3, slidestoscroll: 1, autoplay: true, autoplayspeed: 2000, }); }); slick behaving...

javascript - Toggle just works once -

i'm trying use toggle jquery , it's working once. if click on div again toggle doesn't work, , have refresh de page. , if try on jsfiddle works fine, can´t see mistake. $("#search_icon").click(function() { $("#search").fadetoggle("slow", "linear"); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <img src="images/magnifying-glass32.png" height="30px" class="social_icons" id="search_icon" /> <div id="pesquisa"> <input type="text" placeholder="pesquisar..." id="search" border="0" /> </div>

jsf - Primeface datatable.filter() and url parameter -

i have .xhtml model primeface datatable in it. call page url this: http://localhost:8080/myproject/mypage.jsf?id=51&startdate=04-05-2015&name=whatever the url parameters used retrieve displayed in datatable, allow me filter content. used url parameter because page displayed when select row in datable have make manual redirect page on baking bean. however everytime use 1 of primeface functionality sorting or pagination primeface seems ajax call backing bean without parameters, every object displayed instead of filtered list of objects. therefore how can force primefaces use these parameters? or how can passe them primeface scope (they @managedproperty on backing bean) the best , easiest way use omnifaces utility library , more <o:form> . from documentation: the <o:form> component extends standard <h:form> , provides way keep view or request parameters in request url after post-back ... you can use same way <h:form...

java - GridviewLayoutManager with headers -

i working on app i have implemented working recycler view receives jsonarray, passes data string array. i want add section headers layout manager. i have read 2 schools of thought on this: - change spansize of view match total columns of grid - create custom adapter loads different view if item section header. im not sure way go , starting confuse me i have list of data in array includes both headers , grid data (mydataset), have created array mapping dataset in (mydatamap). in mydatamap have list of field types (1 header , 0 griddata. hoping pass both arrays adaptor , decide if header or griditem , load appropriate view. i leaning more towards loading different view header items, allowing me customise layout of header easier. here adaptor code package com.example.alex.recyclerview2; import java.util.arraylist; import android.content.context; import android.support.v7.widget.recyclerview; import android.view.layoutinflater; import android.view.view; import android....

convert Javascript timestamp into UTC format -

this question has answer here: how utc timestamp in javascript? 14 answers for example if receive timestamp in javascript: 1433454951000 how create function convert timestamp utc like: 2015/6/4 gmt+7 var d1 = new date("unix time stamp here"); d1.toutcstring() originally asked here: how utc timestamp in javascript?

Error on startup of activiti-rest -

on startup of activiti-rest 5.16.4 following error, our older instance 15.4 working without problems: severe: error configuring application listener of class org.activiti.rest.servlet.webconfigurer java.lang.noclassdeffounderror: javax/servlet/dispatchertype @ java.lang.class.getdeclaredconstructors0(native method) @ java.lang.class.privategetdeclaredconstructors(class.java:2532) @ java.lang.class.getconstructor0(class.java:2842) @ java.lang.class.newinstance(class.java:345) @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:4154) @ org.apache.catalina.core.standardcontext.start(standardcontext.java:4709) @ org.apache.catalina.core.containerbase.addchildinternal(containerbase.java:799) @ org.apache.catalina.core.containerbase.addchild(containerbase.java:779) @ org.apache.catalina.core.standardhost.addchild(standardhost.java:583) @ org.apache.catalina.startup.hostconfig.deploywar(hostconfig.java:943) @ org.apac...

c# - Using updatepanel with gridview templatefield (ImageButton), Firing event but no changes in forntend -

i using updatepanel templatefield itemtemplate imagebutton control. when imagebutton pressed event behind button fired mend populate textfields not do. .aspx code: <asp:templatefield showheader="false"> <itemtemplate> <asp:updatepanel id="updatepanel4" runat="server"> <triggers> <asp:asyncpostbacktrigger controlid="_btnuseredit" eventname="click" /> </triggers> <contenttemplate> <asp:imagebutton id="_btnuseredit" runat="server" imageurl="...

multithreading - Passing an Argument in a periodic runnable task execution using handler in Android -

i have created periodic execution of runnable task using handler in android, want pass argument in periodic task execution, have tried 2 approaches pass argument, 1 - declaring class in method void foo(string str) { class oneshottask implements runnable { string str; oneshottask(string s) { str = s; } public void run() { somefunc(str); } } thread t = new thread(new oneshottask(str)); t.start(); } 2 - , putting in function string paramstr = "a parameter"; runnable myrunnable = createrunnable(paramstr); private runnable createrunnable(final string paramstr){ runnable arunnable = new runnable(){ public void run(){ somefunc(paramstr); } }; return arunnable; } reference these above 2 approach can found on runnable parameter? below code in have used 1 approach, either use 1 or 2 approach there 2 problems remains passing argument in periodic runnable task, 1 prob...

wordpress - PHP Thumb Issue -

folks, working on wp site client not loading featured images used thumbs.php script (based on timthumbs), changed allow external source flag false , images script picking resides in same server ..wp-content/uploads/.. i changed cache folder , thumbs.php permissions (guide here ) still no luck, considering using new theme since have read timthumbs disabled server admins due security issues. there way can change thumbs.php code use implementation dont have change theme (which takes lot of re-work) or have code fixed. i not sure if provider has disabled file, assuming. thanks

matlab - find array elements that match one of multiple conditions, sorted by condition matched -

i have m-by-n matrix (n > 3) 2 first columns have lot of repetition of values. have 2 vectors, call them uniquecol1 , uniquecol2 , contain possible values 2 columns. i want find sub-matrices, p-by-n (p =< m), 2 first columns match given values in uniquecol1 , uniquecol2 . there length(uniquecol1) * length(uniquecol2) such sub-matrices. i use ismember() find these sub-matrices, can't see way of doing know parts of output matched condition. alternatively can loop, shown below, extremely slow. there way of vectorizing below? imagine solution have output cell array of these sub-matrices, each sub-matrix not same size (so multi-dimensional array not work). mybigmatrix = round(wgn(1000,6,1) * 3); uniquecol1 = unique(mybigmatrix(:,1)); uniquecol2 = unique(mybigmatrix(:,2)); = 1:length(uniquecol1) j = 1:length(uniquecol2) mysubmatrix = mybigmatrix( ... mybigmatrix(:,1) == uniquecol1(i) & ... mybigmatrix(:,2) == uniquecol2(j) , :...

data modeling - Choosing a partition key for a Cassandra table -- how many is too many partitions? -

i have application 'natural' partition key cassandra table seems 'customer'. primary way want query data, data distribution, etc. but if there on 1 million customers, many different partitions? should choose partition key results in smaller number of partition keys? i've looked @ number of related questions on topic none seem address particular point. but if there on 1 million customers, many different partitions? no. murmur3partitioner can handle 2^64 (-2^63 +2^63) partitions. cassandra designed @ storing large amounts of data , retrieving partition key. there restrictions on number of columns within partition (2 billion), total number of partitions think you'll fine have. should choose partition key results in smaller number of partition keys? definitely not. cause partitions grow big, and/or develop "hot spots" in cluster. the main task behind picking partition key, find 1 (both) offers data distribution in cl...

javascript - Regular expression. Find three words in the field -

help make correct regular expression search 3 words field. far have done so, think it's crazy. var inp = document.getelementsbytagname('input')[0], button = document.getelementsbytagname('button')[0]; button.onclick = function() { console.log(inp.value.match(/^([а-яa-z0-9]+ ){2}[а-яa-z0-9]+/i)); }; <input type="text" /> <button>check</button> i guess it's easier split text , verify element count expect it. may want trim text before avoid leading , trailing empty strings in result array. console.log(inp.value.trim().split(/\s+/))

c++ - Is it possible to access the current 'to create' obj in constructor? -

i writing tree class , want implement constructor creating tree dimension , depth: public: tree(); // empty constructor tree(int dimension, int depth); // constructing empty tree // ... void newnode(node<t>* const&, t const&); // ... private: unsigned int mnumnodes; node<t> *mroot; template<typename t> tree<t>::tree(int dimension, int depth): // member vars { // other constructing stuff this->newnode(0, parent); } apparently not possible, wrote working function adding new nodes specific parent specific value nice use it. but: method needs access current object. maybe there kind of solution working me neither pointing obj possible, nor other kind of access. the problem isn't constructor. @ point execution enters body of constructor, object constructed tree<std::basic_string<char> > . means can use object instance of class in body of co...

java - JXLS - how to create hyperlink to Excel worksheets in workbook -

i trying create excel workbook with jxls . want text hyperlink navigating through worksheets in workbook. couldn't find helpful information online. please give idea or hyperlink can to solve problem. thanks jxls small , easy-to-use java library writing excel files using xls templates , reading data excel java objects using xml configuration. if trying create hyerlink, jxls doen't have low lever excel manupulation capability. can use apache poi free library. code create hyperlink cell task shown below. //creating cell row row = my_sheet.createrow(0); cell cell = row.createcell(0); //creating helper class xssfworkbook workbook = new xssfworkbook(); xssfcreationhelper helper= workbook.getcreationhelper(); //creating hyperlink link = helper.createhyperlink(hssfhyperlink.link_document); link.setaddress("'target_worksheet_name'!a1"); //optional hyperl...

deleted csv still being referenced python/datetime object -

i new python , having trouble outputs. using ipython write code well. want synchronize 2 clock times. first open csv time 1 source in 1 column , time source in other column. once find difference between values import csv has values time source lagging , add difference lagging clock standard other. problems: 1.when switch out first csv calculate time difference e.g (first csv time difference 5 min , new csv time difference 2 min) outputs have 5 min added instead of 2 min. have attached code can see. 2. don't know how convert datetime objects time objects rid of 1900-01-01. saw forums didn't understand code if there simple way appreciate it. i know missing alot of basics appreciate help! import csv datetime import time time_difference= open('test.csv') time_difference_csv=csv.reader(time_difference)#imports csv 2 #clock differences; e.g wall clock , scanner clock 1 value in each column firstline = true row in time_difference_csv: if firstline: #skip ...

ElasticSearch C# client (NEST): access nested aggregation with Spaces -

assuming 2 values "red square" , "green circle", when run aggregation using elastic search 4 values instead of 2, space separated? red, square, green, circle. there way 2 original values. the code below: var result = this.client.search<myclass>(s => s .size(int.maxvalue) .aggregations(a => .terms("field1", t => t.field(k => k.myfield)) ) ); var agbucket = (bucket)result.aggregations["field1"]; var myagg = result.aggs.terms("field1"); ilist<keyitem> list = myagg.items; foreach (keyitem in list) { string data = i.key; } in mapping, need set field1 string not_analyzed , this: { "your_type": { "properties": { "field1": { "type": "string", "index": "not_a...

javascript - connect event is not firing -

i new socket.io, node.js, , javascript in general. building real-time web application partner summer research project. my question: able have 'connect' event , 'connection' event on server side? have not been able fire connect event client side have been able fire other event server side. secondary question: 'connect'/'connection'/'disconnect' native events language , there others? third question: 'connect' , 'connection' event same thing? var path = require('path'); var express = require('express'); var app = express(); var http = require('http').server(app); var io = require('socket.io')(http); app.use(express.static(__dirname)); io.on('connection', function(socket) { console.log('user connected from: ' + socket.id); socket.on("connect", function(messageplayername) { console.log(messageplayername); }); socket.on("disconnect", funct...

Excel VBA SQL - multiple data sources -

Image
i have simple problem cannot find answer to. i have following sql:- select filea in (select b fileb) i attempting run in excel using vba. the problem have filea table on as/400 , fileb table in excel spreadsheet. is, 2 different datasources. can't find way combine 2 datasources in 1 sql statement. anybody got bright ideas. the below example shows how data 2 excel workbooks within single sql query (since haven't got as/400 data source), , put result recordset worksheet. code placed in query.xlsm : option explicit sub sqlwhereintest() dim strconnection string dim strquery string dim objconnection object dim objrecordset object strconnection = _ "provider=microsoft.ace.oledb.12.0;" & _ "user id=admin;" & _ "data source='" & thisworkbook.fullname & "';" & _ "mode=read;" & _ "extended properties=""exc...

java - Parsing SOAP request sent from SOAPUI - using Axis2 Servlet -

here's soap request submitting using soapui <?xml version="1.0" encoding="utf-8"?> <soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:my namespace="my package"> <soapenv:header> <username>q</username> <password>q</password> </soapenv:header> <soapenv:body> <op:op> <op:int>2134</op:int> </op:op> </soapenv:body> </soapenv:envelope> now have created maven project in eclipse , have generated wsdl file, aar file (for deploying using tomcat 7) , jar file java code (java2wsdl). when request submitted, code must authorize user credentials provided under header element. however, not able parse soap request. when tried parsing with, soapfactory fac = omabstractfactory.getsoap11factory(); soapenvelope envelope = fac.getdefaultenvelope(); soapheader header = envelope.getheader(); soapb...

javascript - Working with Dates in Sapui5 -

how can current date, current year, current month, , current week in sapui5? code started with: var otype = new sap.ui.model.type.date(); otype = new sap.ui.model.type.date({ source: {}, pattern: "mm/dd/yyyy" }); i have no idea go here. appreciated. edit: how following javascript function sapui5 table? function addzero(i) { if (i < 10) { = "0" + i; } return i; } function datefunction() { var today = new date(); var dd = addzero(today.getdate()); var mm = addzero(today.getmonth() + 1); var yyyy = today.getfullyear(); var hours = addzero(today.gethours()); var min = addzero(today.getminutes()); var sec = addzero(today.getseconds()); var ampm = hours >= 12 ? 'pm' : 'am'; hours = hours % 12; hours = hours ? hours : 12; // hour '0' should '12' today = mm + '/' + dd + '/' + yyyy + " " + hours + ":" + min + ":" +...

entity framework - WCF + EF return object with FK -

i facing following issue: have productorder class has productid foreign key product class. when invoke following method: public ienumerable<productorder> getorders() { return oddzialdb.productorders; } orders associated product can write this: oddzialdb.productorders.first().product.name; but when reaches client turns out there no association product null (only productid included). in dbcontext have set base.configuration.proxycreationenabled = false; base.configuration.lazyloadingenabled = false; on wcf service side auto-generated ef productorder class looks follows: public partial class productorder { public int id { get; set; } public nullable<int> productid { get; set; } public int quantity { get; set; } public virtual product product { get; set; } } what happens looses connections tables associated foreign keys? make relationship virtual in example: public class productorder { pub...

dataframe - R - extract row as character string with double quote -

i have data frame called dataf dataf<-data.frame(replicate(10,sample(0:1,10,rep=true))) and extract each row of data frame character string function : result=data.frame(matrix(na, ncol=1, nrow=10)) i=0 for(i in 0:9) { result[i+1,]=tostring(dataf[i+1,]) } but result not expected : 1, 0, 0, 0, 1, 0, 0, 1, 1, 0 0, 0, 0, 1, 1, 1, 1, 0, 1, 1 1, 1, 0, 0, 0, 0, 0, 0, 1, 0 i this: "1","0","0","0","1","0","0","1","1","0" "0","0","0","1","1","1","1","0","1","1" "1","1","0","0","0","0","0","0","1","0" i tried dquote , \"r\" , collapse , sep ... don't need. try: capture.output(write.table(lapply(dataf, as.character), row.names=f, col.names=f, sep=",...

ios - childViewControllerForStatusBarHidden For Hiding -

Image
i trying hide half of status bar. specifically, using refrostedviewcontroller side drawer, , when comes out, go on status such in picture (the app google's inbox). the current hierarchy of uiviewcontroller so: - refrostedviewcontroller |--menuviewcontroller |--navigationcontroler |--contentviewcontroller i have uiviewcontrollerbasedstatusbarappearance set yes . in drawer menu (menuviewcontroller) have method - (bool)prefersstatusbarhidden { return yes; } in navigation controller have: - (uiviewcontroller *)childviewcontrollerforstatusbarhidden { return self.frostedviewcontroller.menuviewcontroller; } this hides status bar in screens. when - (uiviewcontroller *)childviewcontrollerforstatusbarhidden { if (self.isdraweropen) { return self.frostedviewcontroller.menuviewcontroller; } else { return self.frostedviewcontroller.contentviewcontroller; } } it crashes. self.frostedviewcontroller.contentviewcontroller hold...

c# - Selecting list of object type after grouping in linq -

i have table such following: productid, categoryid 123, category1 123, category2 123, category1 my parameter productid , need return list of type category based on distinct categories given productid in above table. you leverage .distinct() function linq select distinct categories belonging specified productid. var plist = (from p in context.products p.productid == productid select p.category).distinct().tolist();

c# - 'System.AggregateException' occurred in mscorlib.dll” when using SignalR -

Image
consider following code: using microsoft.aspnet.signalr.client; using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace consoleapplication1 { class stock { public string symbol { get; set; } public decimal price { get; set; } } class program { static void main(string[] args) { var hubconnection = new hubconnection("http://www.contoso.com/"); ihubproxy stocktickerhubproxy = hubconnection.createhubproxy("stocktickerhub"); stocktickerhubproxy.on<stock>("updatestockprice", stock => console.writeline("stock update {0} new price {1}", stock.symbol, stock.price)); hubconnection.start().wait(); console.readline(); } } } when run, getting "an unhandled exception of type 'system.aggregateexception' occurred in mscorlib.dll". tri...

The "Build" tab missing from project properties in Visual Studio 2013 -

when open c# win-forms or wpf project in visual studio 2013, "build" tab doesn't show up. visible if open project in vs2010. haven't been able find information specific tab disappearing. i've have tried resetting user settings in vs2013, running setup repair, , uninstalling , reinstalling vs2013. any ideas on how back? the issue fixed version 4.1.15, can download here . changes in 4.1 branch 4.1.15 2015-06-09 bug 11560 vsix: missing build , debug pages in project properties.

AngularJS ngTouch $swipe move doesn't work -

i used ngtouch module implement things touch devices. 'start' works fine. console.log() in 'move' case has not been displayed, if drag object out of first drop-zone. inside first drop-zone 'move' works. html: <div class="drop-zone" ng-trop="true"> <my-directive ng-drag="true" ng-drag-data="myobject" on-drag="mymethod()"></my-directive> </div> <div class="drop-zone" ng-trop="true"></div> directive: angular.module('myapp') .directive('mydirective', ['$swipe', function($swipe) { return { restrict: 'ea', scope: { ondrag: '&' }, link: function(scope, ele, attrs, ctrl) { $swipe.bind(ele, { 'start': function(coords) { scope.ondrag(); }, 'move': function(coords) { console.log("is moving...

javascript - Adding rel= attributes to Bootpag Pagination for SEO -

im using bootpag pagination ajax call , i'm looking way add rel='next' rel='prev' links, got far adding them based on 'active' class 'prev' attribute on previous links , 'next' on next links use pagination attributes don't change. the code additional attributes if ( $('ul.pagination li').hasclass('active') ) { $('li.active').prevall().attr("rel","prev"); } if ( $('ul.pagination li').hasclass('active') ) { $('li.active').nextall().attr("rel","next"); } the code pagination $('#pagination_container').bootpag({ total: ${myordersdata.totalnumberofpages}, leaps: true, firstlastuse: true, first: '| &lt;', last: '&gt; |', wrapclass: 'pagination', activeclass: 'active', disabledclass: 'disabled', nextclass: 'next', prevclass: 'prev...

Python class and global vs local variables -

this question has answer here: python class scoping rules 2 answers i have problem understanding happening outcome of following pieces of code: my_str = "outside func" def func(): my_str = "inside func" class c(): print(my_str) print((lambda:my_str)()) my_str = "inside c" print(my_str) the output is: outside func inside func inside c another piece of code is: my_str = "not in class" class c: my_str = "in class" print([my_str in (1,2)]) print(list(my_str in (1,2))) the output is: [‘in class’, 'in class’] ['not in class’, 'not in class’] the question is: what happening here in each print() statement? can explain why print() statement string different namespaces? edit 1: i think different this question because humbly think answer...

Google Cloud , Compute Engine I can't create Password -

Image
i'm new here please not hate. tried create vm in compute engine no password shows up. like print: there have been changes windows images 2 days ago. first of all, need create windows instance. later, can windows username , password clicking on new "create or reset windows password" button appears in instance details. following picture shows how looks like: you can choose username , compute engine generate random password username. you can using cloud sdk using command: gcloud beta compute reset-windows-password windows-instance --zone zone --project project_id if forget password you'll need reset password again. you can find more information these changes in following links: link1 link2 link3 once have logged windows instance, can modify password , use custom password following steps can find at documentation .

Python - matplotlib - PyQT: plot to QPixmap -

i want visualise matplotlibs colormaps (similar http://matplotlib.org/examples/color/colormaps_reference.html ) , use qpixmaps in pyqt widgets. idea create plots in matplotlib without showing (or saving file) , convert qpixmap. solution offered here ( python - matplotlib - pyqt: copy image clipboard ) doesn't seem work, maybe because don't want show matplotlib plot. i have tried following , works: def testcolourmap(cmap): sp = subplotparams(left=0., bottom=0., right=1., top=1.) fig = figure((2.5,.2), subplotpars = sp) canvas = figurecanvas(fig) ax = fig.add_subplot(111) gradient = np.linspace(0, 1, 256) gradient = np.vstack((gradient, gradient)) ax.imshow(gradient, aspect=10, cmap=cmap) ax.set_axis_off() canvas.draw() size = canvas.size() width, height = size.width(), size.height() im = qimage(canvas.buffer_rgba(), width, height, qimage.format_argb32) return qpixmap(im)

php - Set user avatar from front end in wordpress -

i working on user registration page. when user upload image attached image in user meta attachment id , when user add comment uploaded photo not appearing in comment list beside comment. after search got information in avatar...but cant idea how upload avatar front side? <?php if ( function_exists( 'get_avatar' ) ) { echo get_avatar( $user->user_email, 50); } else { //alternate gravatar code < 2.5 $grav_url = "http://www.gravatar.com/avatar.php?gravatar_id= " . md5($user->user_email) . "&default=" . urlencode($default) . "&size=" . $size; echo "<img src='$grav_url' height='50px' width='50px' />"; } ?> please check code. should work.

python - Converting raw input string to numbers (for each letter) then summing the numbers -

this question has answer here: convert alphabet letters number in python 10 answers i want user enter word e.g. apple , convert each character in string corresponding letter (a = 1, b = 2, c = 3 etc.) so far i've defined letters a=1 b=2 c=3 d=4 e=5 f=6 g=7 etc... and have split string print out each letter using word = str(raw_input("enter word: ").lower()) in range (len(word)): print word[i] this prints characters individually, can't figure out how print these corresponding numbers, sum together. in case, better use dictionary defines characters , there value. string library provides easier way this. using string.ascii_lowercase within dict comprehension can populate dictionary mapping such. >>> import string >>> wordmap = {x:y x,y in zip(string.ascii_lowercase,range(1,27))} >>> wordmap {...

C - can't use my sizeof implementation as an array size -

i implemented sizeof as recommended . work ok when want print size of variable ,but can't use array size. this code: #include <stdio.h> #include <stdlib.h> #define my_sizeof(var) (size_t)((char *)(&var+1)-(char*)(&var)) int s = 7; void main() { int arr[sizeof(s)]; //works ok int arr2[my_sizeof(s)];//error printf("%d\n", my_sizeof(s));//works ok int temp = 0; } error 1 error c2057: expected constant expression error 2 error c2466: cannot allocate array of constant size 0 error 3 error c2133: 'arr2' : unknown size your implementation my_sizeof not equivalent to sizeof operator in c, compile time operator whereas yours can calculate size @ run time. so, int arr[sizeof(s)]; declares array size sizeof(s) whereas int arr2[my_sizeof(s)]; does the same the array size not calculated @ compile time runtime. work, you'll need support of c99's vlas , compiler doesn't support , ...

java - LWJGL + Swing crashing -

i trying add lwjgl display jframe. added lwjgl canvas. after move complete window or alt-tab out, window freezes. private jpanel contentpane; public guijgen() { setresizable(false); setbounds(100, 100, 1200, 800); contentpane = new jpanel(null); setcontentpane(contentpane); // model-viewer jpanel panel_model = new jpanel(); panel_model.setbounds(0, 0, 771, 761); contentpane.add(panel_model); panel_model.setlayout(null); guimodelcanvas canvas = new guimodelcanvas(); canvas.setbounds(10, 11, 751, 591); canvas.setbackground(color.blue); canvas.requestfocusinwindow(); canvas.setfocusable(true); canvas.setignorerepaint(true); panel_model.add(canvas); this.setvisible(true); try { display.setdisplaymode(new displaymode(751,591)); display.setparent(canvas); display.create(); } catch (lwjglexception ex) { ex.printstacktrace(); } } i left important code , removed rest. why c...

tsql - Converting Datasets and Shared Datasets to t-sql stored procedure -

is there way automatically generate stored procedures out of t-sql in datasets found in ssrs project? there's not automatic way this. might able cobble though. ssrs reports in xml format. datasets in < datasets > element. unfortunately, don't know how helpful since parameters need resolved. someone created powershell retrieve dataset definitions report if want try automate something. think still need manual work convert them - if use parameters or have calculated fields. https://ask.sqlservercentral.com/questions/94491/retrieve-dataset-definitions-from-ssrs-report.html

vb.net - Enumerate all controls in a form (redundant) -

i'm trying enumerate controls in form satisfy condition code beelow public enum methodseachenum startswith = 1 endswith = 2 contains = 3 end enum public function getallcontrols(control control, key string, methodseach methodseachenum, controltype type, optional usetag boolean = true) ienumerable(of control) dim controls = control.controls.cast(of control)() return (controls.selectmany(function(ctrl) getallcontrols(ctrl, metodo)).concat(controls).where(function(c) select case methodseach case metodoseachenum.endswith if (usetag) return c.tag.tostring.toupper.endswith(key.toupper) , c.gettype() controltype else return c.name.toupper.endswith(key.toupper) , c.gettype() controltype end if case metodoseachenum.startswith if (usetag) return c.tag.tostring.toupper.st...

html - fixed position <div> with width 100% leaves some space on left -

i writing simple website myself. i'm in process of creating fixed navigation bar @ bottom of page navigation (duh) , social media links. have created div right width set 100% there space left on left side. html: <html> <head> <!-- stuff browser , search engine --> <title>page</title> <!-- links follow --> <link href='http://fonts.googleapis.com/css?family=pt+sans:400,700,400italic' rel='stylesheet' type='text/css'> <link rel="stylesheet" type="text/css" href="myblogstyle.css"> <!-- css styling --> <style> </style> </head> <body> <div id = 'maindiv' class = 'centered'> <span id = 'maintitle'>page</span><br/> <hr/><br/> <div id="posts"> <!-- format: <span class = 'post_title'>[title]</...

android - Popup Menu at bottom of a view -

how show popup menu @ bottom of anchor view. code i'm using display popup menu. popupmenu popup = new popupmenu(activityreference, view, gravity.no_gravity); popup.getmenuinflater() .inflate(r.menu.popup_menu_event_edit, popup.getmenu()); popup.show(); i have tried changinging gravity.no_gravity gravity.bottom. not working. it worked me popupmenu attachfilepopup = new popupmenu(this, view ,gravity.bottom); attachfilepopup.inflate(r.menu.attachment_choices); view => bottom button want show menu attachment_choices.xml <item android:id="@+id/attach_location" android:title="@string/send_location"/> <item android:id="@+id/attach_record_voice" android:title="@string/attach_record_voice"/> <item android:id="@+id/attach_take_picture" android:title="@string/attach_take_picture"/> <item android:id="@+id/attach...