This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --------------------------------------------------------------------------- | |
# | |
# Description: This file holds all my BASH configurations and aliases | |
# | |
# Sections: | |
# 1. Environment Configuration | |
# 2. Make Terminal Better (remapping defaults and adding functionality) | |
# 3. File and Folder Management | |
# 4. Searching | |
# 5. Process Management |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A middleware to check if id exists in collection | |
* app.get('/resources/:id/', exist('id', collection), function(req, res){...}} | |
* @param {String} id the parameter name of item id in req object | |
* @param {Model} collection the collection model | |
* @return {Function} the middleware | |
*/ | |
function exist(id, collection) { | |
return function (req, res, next) { | |
collection.findById(req.params[id]).exec(function (err, item) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* Bootstrap v3.3.5 (http://getbootstrap.com) | |
* Copyright 2011-2015 Twitter, Inc. | |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) | |
*/ | |
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */ | |
html { | |
font-family: sans-serif; | |
-ms-text-size-adjust: 100%; | |
-webkit-text-size-adjust: 100%; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
travelerGlobal.usernames.initialize(); | |
$('#username').typeahead({ | |
minLength: 1, | |
highlight: true, | |
hint: true | |
}, { | |
name: 'usernames', | |
display: 'displayName', | |
limit: 20, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mixin progress(id) | |
.bar-wrap | |
.progress.no-extra-space(id=id) | |
.progress-marker(style='right:25%') | |
.progress-marker(style='right:50%') | |
.progress-marker(style='right:75%') | |
mixin time-axis | |
.time-axis | |
.time-spot-end now | |
.time-spot.text-center 6 hours ago |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @fileOverview a middleware for express deployment behind a reverse proxy | |
* @param {string} proxy - the known reverse proxy host | |
* @param {string} proxied_service - the url assigned by proxy | |
* @return {function} the middleware | |
* / | |
function proxied (proxy, proxied_service) { | |
return function (req, res, next) { | |
req.proxied = false; | |
req.proxied_prefix = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function average(array) { | |
return array.reduce(function(p, c, i, a) { | |
return (p * i + c) / (i + 1); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start = Date.now(); | |
size = pv_list.length; | |
pv_list.forEach(function(pv) { | |
ca.exec('caget', pv, function(err, result) { | |
complete = complete + 1; | |
if (err) { | |
results[pv] = { | |
name: pv, | |
value: 'unavailable' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get(d, pv_name, size, start, pid): | |
ch = ca.create_channel(pv_name, connect=False, auto_cb=False) | |
if ca.connect_channel(ch, timeout=1.0): | |
d[pv_name] = ca.get(ch, wait=True) | |
else: | |
d[pv_name] = 'not connected' | |
if len(d) == size: | |
print int(round((time.time() - start) * 1000)) | |
os.kill(pid, signal.SIGTERM) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
from multiprocessing import Process, Manager | |
def get(d, pv_name, size, start, pid): | |
pv = PV(pv_name) | |
if pv.wait_for_connection(timeout=1.0): | |
d[pv_name] = pv.get(use_monitor=False) | |
else: | |
d[pv_name] = 'not connected' | |
if len(d) == size: |
NewerOlder