Posts

Showing posts from January, 2013

How to compile python 3.4.3 script to exe? -

how compile python 3.4.3 script module tkinter , ttk self-executable exe (standalone)? (py2exe, pyinstaller, freeze doesn't work.) suggestions? thank you what is download portable python create file in other language can compiled exe make executable call portable python python file. structure: application_folder # folder in +--my_python_folder # folder python files in | +--my_program.py # python file want start +--portable python 3 # python version use +--program.exe # compiled program the c++ source code: // based on https://msdn.microsoft.com/en-us/library/ms682425%28vs.85%29.aspx #include <windows.h> #include <stdio.h> #include <tchar.h> int _tmain( int argc, tchar *argv[] ) { startupinfo si; process_information pi; // choose between pythonw.exe , python.exe tchar command[] = "\"portable python 3\\app\\pythonw.exe\" \"my_program.py\""; // directory start python progr

Eclipse Outbound connection blocked : The same url works from web browser -

i using httpurlconnection class connect external web service eclipse, getting error message "connection refused" public class testconnection { static { //for localhost testing javax.net.ssl.httpsurlconnection.setdefaulthostnameverifier( new javax.net.ssl.hostnameverifier(){ public boolean verify(string hostname, javax.net.ssl.sslsession sslsession) { if (hostname.equals("localhost")) { return true; } return false; } }); } public static void main(string[] args) { httpurlconnection urlconnection; try { //https method required parameters // xmlhttprequest s1 = new xmlhttprequest (); urlconnection = (httpurlconnection) ((new url("https://google.com").openconnection())); urlcon

How to rotate Tomcat Log file when it reached certain limit -

in windows can go go program files\apache software foundation\tomcat6.0\bin , run tomcat6w.exe administrator under java tab, in java options section add following: -djava.util.logging.filehandler.limit=25000000 set default stdout.log file 25mbs before rotates new log file. if configured log file not rotating size reached limit. i believe $tomcat/logs/catalina.out cannot logrotated $tomcat/logs/mywebapp.log files possible in tomcat's default juli(javautilloginterface) implementation. add mywebapp/web-inf/classes/logging.properties file webapps. handlers = java.util.logging.filehandler ## limit=kb of file, count=number of files kept java.util.logging.filehandler.level = fine #org.apache.juli.filehandler.directory = ${catalina.base}/logs #org.apache.juli.filehandler.prefix = mywebapp. java.util.logging.filehandler.pattern = ${catalina.base}/logs/mywebapp.%g.log java.util.logging.filehandler.limit = 2000000 java.util.logging.filehandler.count = 5 java.util.l

ServiceStack (Self-hosted) - running a curl from Windows console -

i trying run curl command windows console. (eg curl.exe http://localhost:8087/servicestackrequest ) however, information returned provides me "error 401.2 unauthorized". ... " [ logon method: not yet determined. logon user: not yet determined". in iis, have enabled - apppool: given access specific user has got access - service (site): enabled pass-through authentication said user. however, authentication details not being passed when running command. ideas? ok got working. in iis, (i) disabled windows authentication (ii) enabled anonymous authentication

javascript - JQuery get input value -

html <td data-title="quantity"> <div class="clearfix quantity r_corners d_inline_middle f_size_medium color_dark m_bottom_10"> <button class="btn-minus bg_tr d_block f_left" data-item-price="8000.0" data-direction="down">-</button> <input min="0" class="f_left" type="text" value="2" name="order[line_items_attributes][0][quantity]" id="order_line_items_attributes_0_quantity"> <button class="btn-plus bg_tr d_block f_left" data-item-price="8000.0" data-direction="up">+</button> </div> <div> <a href="#" class="color_dark remove-order"><i class="fa fa-times f_size_medium m_right_5"></i>remove</a><br> </div> </td> javascript $(

javascript - <s:select> drop down issue when using default option as empty -

i using map populate struts2 tag <s:select > , observed when there multiple submission of form blank line gets appened @ end of list. instance, if map has 2 key value pairs show 3 records , append blank record in bottom(not @ top--for default case). item 1 item 2 <-blank-> <s:select id="bankaccountid" name="accountbean.recorddetails.bankacct.bankacctid" label="" headerkey="" headervalue="" list="accountbean.bankaccountmap" listkey="key" listvalue="value" /> <select name="accountbean.recorddetails.bankacct.bankacctid"> <option value=""></option> <option value="51089">bank xxxx123</option> </select> <select name="accountbean.recorddetails.bankacct.bankacctid" id="bankaccountid"> <option value="-1" selected="select

Cakephp 3 : How to give condition in get method? -

i trying give condition in cakephp 3 method, data fetch foreign id not primary key. here have tried below code: $eventpasswordall = $this->eventpasswordall->get($id, [ 'conditions' => ['event_id'=>$id], 'contain' => ['events'] ]); but showing me data according id(primary key) , not event_id . how add condition in methods event_id=my id ? don't use get , use find . according cakephp 3.0 table api , get method: returns single record after finding primary key , if no record found method throws exception. you need use find : $eventpasswordall = $this->eventpasswordall->find('all', [ // or 'first' 'conditions' => ['event_id' => $id], 'contain' => ['events'] ]); // or $eventpasswordall = $this->eventpasswordall->find() ->where(['event_id' => $id]) ->contain(['events']) ;

html - bootstrap not getting dismissable warning -

i'm new bootstrap. tutorials i've seen <div class="alert alert-warning" style="margin-left: 480px;margin-top: 20px;width: 500px;"> warning message here </div> this should give me dismissable warning message. but i'm getting warning message, not dismissable. is there wrong code? you need use - <div role="alert" class="alert alert-warning alert-dismissible fade in" style="margin-left: 480px;margin-top: 20px;width: 500px;"> <button aria-label="close" data-dismiss="alert" class="close" type="button"><span aria-hidden="true">×</span></button> <strong>holy guacamole!</strong> warning message here </div> see more details

python - Move Y axis to another position in matplotlib -

Image
i have following plot: i want move y axis x = 0 ticks , everything, how can it? here go import matplotlib.pyplot plt import numpy np fig = plt.figure() x = np.linspace(-np.pi, np.pi, 100) y = 2*np.sin(x) ax = fig.add_subplot(111) ax.set_title('centered spines') ax.plot(x, y) ax.spines['left'].set_position('center') ax.spines['right'].set_color('none') ax.spines['bottom'].set_position('bottom') ax.spines['top'].set_color('none') ax.spines['left'].set_smart_bounds(true) ax.spines['bottom'].set_smart_bounds(true) ax.xaxis.set_ticks_position('bottom') ax.yaxis.set_ticks_position('left') more examples: http://matplotlib.org/examples/pylab_examples/spine_placement_demo.html

matlab model -- access base workspace variables -

Image
i running test.m file create variables in base work space. content of test.m file :-- a=10; % define variable particular value b=20; % define variable particular value c=0; % define variable particular value in matlab model trying access variables & b. returning me value zero both & b. i using function call generator trigger model every 10 msec. solver type : fixed step solver : discreate(no continous states) why not able access workspace variables in simulink model. please see attached print shot. you using inport , named variable name not affect variable it, port. try using constant block , set variable name ("a" example)

.net - C++ Determine remaining space of hard drive -

i programming c++ in visual studio 2010 , wondering if there easy way remaining space of hard drive in mb. making program records images , want able see remaining space. noticed visual basic has following: dim cdrive system.io.driveinfo cdrive = my.computer.filesystem.getdriveinfo("c:\") msgbox(cdrive.totalsize) is there in c++? thanks edit 1: responses guys, have finished work i'll have @ suggestions tomorrow getfreediskspaceex want call. sample code here .

javascript - ws4py - send/received_message not working -

i'm encountering issues on making websocket server/client. this websocket clas: wslist = [] class loginlivewebsockethandler(websocket): # /live/ws/zones loggedon = false def opened(self): log("opened!") wslist.append(self) def received_message(self, m): log("received message!") log(m) log(m.data) m = str(m.data) if not m.startswith("login: ") & (not self.loggedon): return if m.startswith("login: ") & self.loggedon: return if m.startswith("login: ") & (not self.loggedon): split = m.replace("login: ", "").split(":") try: id = split[0] key = split[1] except keyerror: self.send("login: 0", false) return try: usr = users.getuser(id, key)

javascript - Unable to render templateUrl from custom Directive -

this custom directive centraapp.directive('counter', function () { return { restrict: 'a', scope: { value: '=value' }, templateurl: '~/scripts/app/shared/directives/counter/partials/counter.html', link: function (scope, element, attributes) { // make sure value attribute not missing. if (angular.isundefined(scope.value)) { throw "missing value attribute on counter directive."; } var min = angular.isundefined(attributes.min) ? null : parseint(attributes.min); var max = angular.isundefined(attributes.max) ? null : parseint(attributes.max); var step = angular.isundefined(attributes.step) ? 1 : parseint(attributes.step); element.addclass('counter-container'); // if 'editable' attribute set, make field editable. scope.readonly = angular.isundefined(attributes.e

railstutorial.org - Login with remembering tests not failing -

normally i'd happy tests passing, not in case. i'm going through tutorial again, making own app. have few differences tutorial code, (hopefully) cosmetic. logging in , session stuff should same. after slogging through section 8.4.2 login remembering, tests supposed fail (listing 8.37), because there's no way log out. mine pass. does know test supposed fail? don't know how track down problem without failure. i missed section on logging out. after adding code, expected failure in "login valid information followed logout" delete logout_path assert_not is_logged_in? assert_redirected_to root_url f ollow_redirect! assert_select "a[href=?]", login_path <----- fails

c# - Entity Framework Doesn't create a new proxy Why? -

i've got trouble ef (6.0.0) here code var answer = new ticketanswer(); answer.answer = "hello"; answer.ticketid = 20; answer.confirmdate = datetime.now; db.ticketanswer.add(answer); db.savechanges(); answerid = answer.id; db.ticketanswer.where(x=> x.id == answerid).firstordefault(); after , when im trying db.ticketanswer same id of answer (which new created) ef returning ticketanswer class (not proxy) , cant access ticket class on (ticket property null ticketid not null , there ticket on db id = 20 , there not problem relations) , when change query : var = db.ticketanswer.where(x => x.id == 225).firstordefault(); ef returning system.data.entity.dynamicproxies_asdgafd... , can access ticket class. all want , reach ticket class on ticketanswer class , should ? your navigation property has not yet loaded newly added entity in context. load must: var ticketanswer = db.ticketanswer.include(ta => ta.ticket).where(x=> x.id == answerid).f

php - show pinned item at the very top of posts -

i have created checkbox of metabox pinning news items, can't keep last pinned item @ top of list, here code: $today = date("ymd"); $args = array( 'post_type' => 'news', 'posts_per_page' => -1, 'meta_key' => 'pinned_news_item', 'meta_value' => '1', 'order' => 'desc', 'orderby' => $today, ); finally found solution. here code worked me: $args_meta = array( 'post_type' => 'news', 'posts_per_page' => -1, 'meta_key' => 'pinned_news_item', 'orderby' => 'modified', 'order' => 'desc', 'ignore_sticky_posts' => '1' );

MATLAB: short function taking 20+ minutes to run -

i'm using xeon quad-core processor 64gb of ram. program running function has 89 data points. it's been on 20 minutes , matlab still "busy" computing program. code below reveal reason why it's taking long compute? function last15minsofday=last15minsofday(time,price) % last15minsofday takes average of prices between 3:45 , 4:00. timestr=cellstr(datestr(time)); timedbl=datevec(timestr); times=and(timedbl(:,4)==14,timedbl(:,5)>=45)+and(timedbl(:,4)==15,timedbl(:,5)==0); priceidx=find(times); z=find(fwdshift(1,priceidx)~=priceidx+1); z=[1; z]; mu=zeros(length(z),1); = 1:length(z); while < length(z) mu(i)=mean(price(priceidx(z(i):z(i+1)))); end end last15minsofday=mu; i no expert in matlab part looks funny: for = 1:length(z); while < length(z) mu(i)=mean(price(priceidx(z(i):z(i+1)))); end end specifically not see i being incremented in inner loop inner loop run indefinitely.

angular2 template - Angular HTML binding -

i writing angular application, , have html response want display. how do that? if use binding syntax {{myval}} encodes html characters (of course). i need somehow bind inner html of div variable value. the correct syntax following: <div [innerhtml]="thehtmlstring"></div> working in 5.0.2 documentation reference

java - Counting entries in mysql which are not equal to something -

i making code count entries in database in column's default value specified me. in front end, user can change value of column random alphanumeric number. have count how many entries has user changed. tried following code(s) in jdbc while linking mysql it: select * complaints rid=11120059 permanent_token !='0'; select * complaints rid=11120059 not permanent_token ='0'; but none working. giving default value of varchar permanent_token '0'. there 2 mistakes in requests. first, use twice keyword where second, when want not equals in sql have use <> for exemple, first request: select * complaints rid=11120059 , permanent_token <>'0'; and have count result: select count(*) complaints rid=11120059 , permanent_token <>'0';

Delete step from Workflow in JIRA server edition v6.3.4 -

Image
i'm trying delete step workflow in jira. i have read on interwebz delete workflow step, must make copy of workflow , delete step copy. don't see way in copy have created. i have tried twice; new workflow not assigned project , not have workflow scheme. shows "inactive". have tried deleting transitions step, did not help. everything i've found topic assumes workflow "draft" copy not appear draft, don't know problem is. i've been digging around in ui hour no luck. suggestions appreciated. try delete transition in diagram view. delete transition want , complete diagram flow.may deleting transition may course diagram flow.

database - How to validate success of cassandra version upgrade and cross datacenter backup -

here production cassandra cluster 1 datacenter of 3 hosts. version 1.0.7. want upgrade 1.0.7 2.1.8 , add cassandra data center 3 hosts of version 2.1.8. i have experimented on test cluster , can upgrade cluster without errors. still worry there data loss or modified. want design quick method validate following 2 points. are there data losses or damages when cluster upgraded 1.0.7 2.1.8? i add data center in cluster , alter keyspace strategy networktopologystrategy 2 replicas each data center. how validate 2 data centers holding same replicas? there 10g rows in current clusters. tedious match rows. there better way validate points above? or can trust cassandra itself. i'm not sure it's practical (or necessary) in cases check every row of data. i'd before , after checks of things this: spot check selected subset of rows. if of them correct, of them are. compare data sizes before , after upgrade make sure in same ballpark. monitor upgrade process

php - How to Find Zip codes by Zip and Distance -

please, me. need find zip codes zip , distance miles. know few ways, how to. can create table location, zip_code, lat, lng , use mysql find can takes many time because, 1 - find lat, lng location.zip_code = xxxx 2 - find mysql - select `id`, `zip_code`, ( 6373 * acos( cos( radians( :lat ) ) * cos( radians( `lat` ) ) * cos( radians( `long` ) - radians( :long ) ) + sin(radians(:lat)) * sin(radians(`lat`)) ) ) `distance` `location` having `distance` < :distance order `distance` limit 25 return $zip_codes 3 - find sql select * **** zip in ($zip_codes) maybe know how optimize case?

javascript - Google Maps API - Hover on markers and show image -

i trying google maps instance show bunch of markers, , when hover on specific marker change larger image. revert original marker image when mouse leaves new image area. seem have working i'd in jsfiddle: https://jsfiddle.net/vn9po27c/2/ var locations_programs = [ ['christie lake camp', 44.803033, -76.418031, 1, 'http://www.christielakekids.com/_images/map_pins/events/canoe-for-kids.png', ''], ['caldwell community centre', 45.373083, -75.735550, 1, 'http://www.christielakekids.com/_images/map_pins/events/caldwell-community-centre.png', ''], ['dempsey community centre', 45.401887, -75.627530, 1, 'http://www.christielakekids.com/_images/map_pins/events/dempsey-community-centre.png', ''], ['brewer arena', 45.389560, -75.691445, 1, 'http://www.christielakekids.com/_images/map_pins/events/brewer-arena.png', ''] ]; var markersarray = []; var markers =

javascript - Absolute Center (Vertical & Horizontal) "Responsive" it does not work -

Image
i'm use bootstrap 3.3.5 , demo 30-lazy-load-images, problem container can not have fixed height(px), must "100% or auto" compatible responsive design. check demo .swiper-container { width: 100%; height: 500px; // work if star height eg 500px, need container responsive 100% or auto. } if set height: 100% or auto, .swiper-container height not initialize "0". how can solve this? image must centered lazy load you use height:50vh; have swiper-container display half of screen height. or whatever want set height at. responsive. .swiper-container { width: 100%; height: 50vh; } here fiddle . for more info using vh please read this .

javascript - CRC calculation over 26 bytes -

i'm implementing simple protocol , need calculate crc following structure: type (1 byte, unsigned) address (1 byte, unsigned) dataid (4 bytes, unsigned, little-endian) data (4 bytes, unsigned, little-endian) data (4 bytes, unsigned, little-endian) data (4 bytes, unsigned, little-endian) data (4 bytes, unsigned, little-endian) data (4 bytes, unsigned, little-endian) ----------------- = (26 bytes) you can imagine simple javascript object: var message = { type: 0x11, address: 0x01, dataid: 0xffffffff, data: [ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff ] } from object need calculate crc. unfortunately, in manual crc calculation includes message type, slave address data-id's , data values. crc calculation performed on 26 bytes. i'm not sure should do. crc calculated using crc16-ccit function. downloaded crc package npm has function implemented. it great if post me code, because have no i

java - GWT and SQL - No Suitable Driver -

i'm having strange problem gwt , sql. i'm trying gwt program communicate sql server. took several examples web , terminate following error: severe: no suitable driver found jdbc:mysql://localhost:3306/table java.sql.sqlexception: no suitable driver found jdbc:mysql://localhost:3306/table after racking brain hours , hours, came following code does work. running following happily output mysql version console: public static void printversion() { connection con = null; statement st = null; resultset rs = null; string url = "jdbc:mysql://localhost:3306/table"; string user = "username"; string password = "password"; try { con = drivermanager.getconnection(url, user, password); st = con.createstatement(); rs = st.executequery("select version()"); if (rs.next()) { system.out.println(rs.getstring(1)); } } catch (sqlexception ex) { logge

sql - How to select and group by month in linq? -

select name, m1 = sum(case when month(pay_date) = 1 1 else 0 end), m2 = sum(case when month(pay_date) = 2 1 else 0 end), m3 = sum(case when month(pay_date) = 3 1 else 0 end), m4 = sum(case when month(pay_date) = 4 1 else 0 end), m5 = sum(case when month(pay_date) = 5 1 else 0 end), m6 = sum(case when month(pay_date) = 6 1 else 0 end), m7 = sum(case when month(pay_date) = 7 1 else 0 end) tbl_post year(date) = 2015 group name name m1 m2 m3 m4 m5 m6 m7 0 0 0 0 0 174 327 b 44071 50101 5501 569 65831 6998 69305 c 0 0 0 0 5 147 195 d 3438 6003 8640 8930 11598 13731 13368 e 0 1 3 2 3 3 3 f 2455 29084 993 6310 7561 19040 25722 try query var sums = d in contex.tbl_post d.date.value.year=2015 group d new {d.name} g select new { name = g.key, m1 = g.sum(s => s.pay_date.value.month==1??1:0),

javascript - Highcharts Pie chart longer text -

Image
as example image displays, i'm having problems highcharts data labels in situation text longer. created jsfiddle example. solution limit length of string i.e. max 20 strings , put "..." end of text, longer text like: "another long text wit...". want find out different solution, question is: how solve long text issue occurs on hc pie chart? jsfiddle [{ name: "microsoft internet explorer looooooooooonggggggggggggg", y: 56.33 } you can add width: '100px' plotoptions > pie > style : style: { color: (highcharts.theme && highcharts.theme.contrasttextcolor) || 'black', width: '100px' } working fiddle: https://jsfiddle.net/rfnawems/2/

python - How to interpret this traceback? -

i'm setting new development machine , installed ide pycharm. installed python c:\program (x86)\python27 . when start gae server traceback. mean? pydev debugger: process 7576 connecting traceback (most recent call last): file "c:\program files (x86)\jetbrains\pycharm 4.5.3\helpers\pydev\pydevd.py", line 2358, in <module> globals = debugger.run(setup['file'], none, none, is_module) file "c:\program files (x86)\jetbrains\pycharm 4.5.3\helpers\pydev\pydevd.py", line 1778, in run pydev_imports.execfile(file, globals, locals) # execute script file "c:\program files (x86)\google\google_appengine\_python_runtime.py", line 83, in <module> _run_file(__file__, globals()) file "c:\program files (x86)\google\google_appengine\_python_runtime.py", line 79, in _run_file execfile(_paths.script_file(script_name), globals_) file "c:\program files (x86)\google\google_appengine\google\appengine\tools\deva

c# - Calculating hard drive throughput -

my app creates 2gb file , needs select fastest drive on system enough space. trying calculate throughput creating file, setting length, writing data sequentially follows: fileinfo file = null; var drives = driveinfo.getdrives(); var stats = new list<driveinfostatistics>(); foreach (var drive in drives) { { file = new fileinfo(path.combine(drive.rootdirectory.fullname, guid.newguid().tostring("d") + ".tmp")); } while (file.exists); try { using (var stream = file.open(filemode.createnew, fileaccess.write, fileshare.none)) { var seconds = 10; var framerate = 120f; var byteswritten = 0l; var bytesperpixel = 1; var watch = new stopwatch(); var videosize = new size(1328, 1048); var buffer = new byte [(int) (videosize.width * videosize.height * bytesperpixel)]; stream.setlength((long) (videosize.width * videosize.hei

Mono certificate issue: Unsupported hash algorithm: 1.2.840.10045.4.3.3 -

i'm running mono v3.2.8 in ubuntu 14.04 , working fine until after upgrading os. got error when running nodejs application (use edge.js communicate mono): error getting response stream (write: authentication or decryption has failed.): sendfailure i thought same old bug solved running command: $ mozroots --import --ask-remove but it's not, still got error. check until saw error: $ certmgr -list -c -v trust ... x.509 v3 certificate serial number: 2a99639b9e014c5450700062aaaf471f issuer name: c=gb, s=greater manchester, l=salford, o=comodo ca limited, cn=comodo ecc certification authority subject name: c=gb, s=greater manchester, l=salford, o=comodo ca limited, cn=comodo ecc certification authority valid from: 3/6/2008 12:00:00 valid until: 1/18/2038 11:59:59 pm unique hash: key algorithm: 1.2.840.10045.2.1 algorithm parameters: 06052b81040022 public key: /* public key */ signature algorithm: 1.2.840.10045.4.3.3 algorit

R: ggplot2 x axis prints as continuos, but needed as discreate -

Image
my data: structure(list(year = structure(1:10, .label = c("1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", "1989" ), class = "factor"), lupas = c(1185, 822, 1340, 853, 3018, 1625, 966, 1505, 1085, 1754)), .names = c("year", "lupas"), row.names = c(na, -10l), class = c("tbl_df", "tbl", "data.frame"), drop = true) i've group data group_by dplyr. str(df1) classes ‘tbl_df’, ‘tbl’ , 'data.frame': 10 obs. of 2 variables: $ year : factor w/ 10 levels "1980","1981",..: 1 2 3 4 5 6 7 8 9 10 $ lupas: num 1185 822 1340 853 3018 ... - attr(*, "drop")= logi true i'm trying plot graph of years, , "lupas" each year. time series graph. this code, gives error: ggplot(df1, aes(x = year, y = lupas)) + geom_line() geom_path: each group cons

c# - Large object (ntext and image) cannot be used in ORDER BY clauses -

i wanted change code-first project sql server compact 4.0. but have problem following linq expression db.test.orderby(t => t.name).tolist() it throws following error large object (ntext , image) cannot used in order clauses is there way tell code-first create nvarchar type name field instead of ntext type when creating database? yes. decorate name property of entity class attribute: [column(typename = "nvarchar(max)")] that should trick.

ruby on rails - fluentd, config agent-td send request to webservice -

i 'm new fluentd. wonder support send request in fluentd-agentd. example: when fluent have new log (from apache/nginx/rails). want call request http body log text specify url ( http://my_service.com/api/get_log ) is possible? yes, it's possible. did simple test using following output plugin: https://github.com/ento/fluent-plugin-out-http you can install '$ gem install fluent-plugin-out-http' , proceed configuration schema proposed on github repository. happy logging!

html - Github Page Rendering Incorrectly -

i've looked around forums unfortunately couldn't find answers looking - have html page renders locally in chrome when uploaded onto github renders incorrectly (the lower subscription form , social icons in pop out menu) i've ran through cross-browser compatibility tools , seems render correctly on ca 70% of browsers. im not sure cause is, love on one. <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <link rel="shortcut icon" href="assets/ico/favicon.ico"> <title>weave.</title> <!-- bootstrap core css --> <link href=&qu

c# - Does Attribute Routing with Conventional mapped routes make sense -

we have many web api solution 2 projects. 1 project sets web api config stuff , other project contains controllers. each web api config setup this: config.maphttpattributeroutes(); config.routes.maphttproute( name: "defaultapi", routetemplate: "api/{controller}/{id}", defaults: new { id = routeparameter.optional } ); as use route/prefix-attributes on every controller/action asked myself config.routes.maphttproute method call still take effect? actually annotate route attribute on controller @ least overwrite convention behavior of web api. method call obsolete. is correct? or there still consider, because want remove method call in every project. the convention-based route still applied. attribute-based routes take precedence (because configured first) if action method has both matching attribute routes and conventional routes, both routes map action in question. if want use exclusively attribute-based

Render Twig macro from PHP? -

i'm migrating project old custom xml-based templating engine twig . in order ease transition thought might nice able render twig macros inside old engine new widgets can built using twig , ran in both places needed. the way can think of doing generate twig source code looks this: {% import 'macros.twig' m %} {{ m.widget(...) }} and crazy like eval('?>'.$twig->compilesource($twig->getloader()->getsource($name), $name)); which seems slow, dangerous, , brittle. there better way tap twig api? yes, render template, should use: echo $twig->loadtemplate($name)->render($context); the loadtemplate compile twig source if not exist in cache. the render method render template safely. a macro method of compiled class (see compiled template link of fiddle: http://twigfiddle.com/orfp3d ) can call macro outside quite easily, that's not recommended (as macro not take part of templateinterface )

shell - Find the average values in 2nd column for each distinct values in 1st column using Linux -

this question related earlier post find maximum values in 2nd column each distinct values in 1st column using linux i have 2 columns follows ifile.dat 1 10 3 34 1 4 3 32 5 3 2 2 4 20 3 13 4 50 1 40 2 20 what find average values in 2nd column each 1,2,3,4,5 in 1st column. ofile.dat 1 18 i.e. (10+4+40)/3 2 11 i.e. (2+20)/2 3 26.33 i.e. (34+32+13)/3 4 35 5 3 i can't able it, though know average command. using awk can do: awk '{a[$1]+=$2; c[$1]++} end{for (i in a) printf "%d%s%.2f\n", i, ofs, a[i]/c[i]}' file 1 18.00 2 11.00 3 26.33 4 35.00 5 3.00

m2eclipse - Eclipse mars m2e & groovy eclipse compiler?: no source folders -

Image
i tried import maven multimodule project worked eclipse luna eclipse mars. multi-module maven project has no source folder in eclipse mars, dependencies not present: i can't add src/main/java folder source folder: other maven multi module projects work. difference project uses groovy-eclipse-compiler: <plugin> <artifactid>maven-compiler-plugin</artifactid> <version>3.3</version> <dependencies> <dependency> <groupid>org.codehaus.groovy</groupid> <artifactid>groovy-eclipse-compiler</artifactid> <version>2.9.2-01</version> <scope>compile</scope> </dependency> <dependency> <groupid>org.codehaus.groovy</groupid> <artifactid>groovy-eclipse-batch</artifactid> <version>2.4.3-01</version> <s

sql - How to check if all days of the month are in the database -

this table wys_attendence : id studid adate amonth ayear acls_id attendence 1 28 02 07 2015 10 1 2 31 02 07 2015 10 0 4 32 02 07 2015 10 1 5 28 13 07 2015 10 0 6 31 13 07 2015 10 1 7 32 13 07 2015 10 1 9 28 14 07 2015 10 1 10 31 14 07 2015 10 1 11 32 14 07 2015 10 1 13 28 15 07 2015 10 1 14 31 15 07 2015 10 0 15 32 15 07 2015 10 1 17 28 16 07 2015 10 0 18 31 16 07 2015 10 1 19 32 16 07 2015 10 1 21 28 17 07 2015 10 1 22 31 17 07 2015 10 1 23 32 17 07 2015 10 0 24 28 20 08

MySql database excludes A.M, P.M, from datetime, timestamp, time, PHP, SQL -

i have 3 data types in database. datetime, timestamp, , time. time using date function , tried insert database under 3 columns, 3 columns rejected a.m, p.m part of date function. don't understand why. need a.m, p.m part of date function inserted, can sort data in database more efficiently time. there column can store a.m, p.m part of date, or there workaround this? thanks. $time = date('h:i:s a'); //insert $time 3 columns database the workaround use hours value 24 hour clock. represent '3:45:56 pm ' , insert database column string value '15:45:56' . otherwise, can use str_to_date function convert string valid time value. insert mytable (mycol) values (str_to_date('3:45:56 pm','%h:%i:%s %p')) to retrieve time value database column, formatted 12 hour clock am/pm. select date_format(mytimecol,'%h:%i:%s %p') mytimestr ... references: str_to_date https://dev.mysql.com/doc/refman/5.5/en/date-and-time-func

javascript - Using Gulp Zip to zip all the files in a folder -

i using gulp-zip zip source files. have main folder called fifa has other sub folders might have more sub folders , files. in additon fifa folder has files package.json, gulp.js , other files. want use gulp-zip zip entire project , create folder called distribution , save zip inside it. code used. gulp.task('zip', function () { return gulp.src('./*,') .pipe(zip('test.zip')) .pipe(gulp.dest('./distribution')); }); the issue although zip created inside distribution folder zip contains files inside fifa folder, files inside subfolders of fifa not there. instance if fifa has subfolder called ronaldo , ronaldo contains goal.js goal.js not in zip. have done wrong? please advice. try 2 * gulp.task('zip', function () { return gulp.src('./**') .pipe(zip('test.zip')) .pipe(gulp.dest('./distribution')); }); what's difference between * , ** ? one star means fil