Skip to content

Instantly share code, notes, and snippets.

top - 22:24:02 up 127 days, 5:32, 1 user, load average: 0.87, 0.35, 0.11
Tasks: 95 total, 1 running, 94 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.4%us, 0.2%sy, 0.0%ni, 99.1%id, 0.1%wa, 0.0%hi, 0.0%si, 0.1%st
Mem: 4054804k total, 2263500k used, 1791304k free, 204860k buffers
Swap: 0k total, 0k used, 0k free, 1560948k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
24520 root 20 0 1166m 211m 9820 D 2.0 5.3 73:33.39 node
1 root 20 0 19232 1500 1228 S 0.0 0.0 1:14.64 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
@davidlbatey
davidlbatey / gist:6380807
Last active December 21, 2015 23:18
Uservoice coffeescript with turbolinks support
# Suggest this goes in it's own file
$.pageLoad = (ready) ->
$(document).ready(ready)
$(document).on('page:load', ready)
# Called on document ready and turbo links page:load
$.pageLoad ->
unless window.UserVoice
loadUserVoice()
else
<script type="text/javascript">
var clicky_site_ids = clicky_site_ids || [];
clicky_site_ids.push(100615330);
(function() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//static.getclicky.com/js';
( document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] ).appendChild( s );
})();
@davidlbatey
davidlbatey / finance-calcs
Last active December 16, 2015 22:20
Finance calculations
Adjusting close.
Dividend multiplier for adjusting close: (Close(T-1) - d)/Close(T-1) where d is the dividend.
Splits adjusting close: Close(T) * 1/N Where N is the split ratio.
Sharpe ratio
Daily return: (new_price - old_price)/old_price
Excess daily return: (daily_return - base_return) e.g. base_return for risk free rate at 4% would be 0.04/252 where 252 is number of trading days.
Sharpe ratio: √252 * average(excess_daily_return) / standard_deviation(excess_daily_return)
module List
def self.included(base)
base.extend ClassMethods
base.list = []
end
module ClassMethods
attr_accessor :list
has_many :super_heros
has_one :batman, :through => :super_heros
belongs_to :catwoman
:Tabularize / :[a-z|A-Z|_]*
has_many :super_heros
has_one :batman , :through => :super_heros
belongs_to :catwoman
@davidlbatey
davidlbatey / jquery-chrome-console
Created January 31, 2013 02:05
Add jquery to console if the site is not using it. So useful.
var jq = document.createElement('script');
jq.src = "http://code.jquery.com/jquery-latest.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
jQuery.noConflict();
@davidlbatey
davidlbatey / gist:2274650
Created April 1, 2012 11:05
Install public key on remote authorized keys
cat ~/.ssh/id_rsa.pub | ssh user@remote.machine.com 'cat >> .ssh/authorized_keys'
@davidlbatey
davidlbatey / Gemlist
Last active September 27, 2015 12:48
Gem list
# Base application
https://github.com/RailsApps/rails3-devise-rspec-cucumber
appscrolls
# Validations
validates_email_format_of
client_side_validations
# CSS
twitter-bootstrap-rails
.bashrc
export HISTCONTROL=ignoredups:erasedups # no duplicate entries
export HISTSIZE=100000 # big big history
export HISTFILESIZE=100000 # big big history
shopt -s histappend # append to history, don't overwrite it
# Save and reload the history after each command finishes
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"