Skip to content

Instantly share code, notes, and snippets.

View nanosplit's full-sized avatar

Jacob Montgomery nanosplit

  • Texas
View GitHub Profile
sudo apt-get update
sudo apt-get install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev
cd
git clone https://github.com/excid3/asdf.git ~/.asdf
echo '. "$HOME/.asdf/asdf.sh"' >> ~/.bashrc
echo '. "$HOME/.asdf/completions/asdf.bash"' >> ~/.bashrc
echo 'legacy_version_file = yes' >> ~/.asdfrc
echo 'export EDITOR="code --wait"' >> ~/.bashrc
## Options section
setopt correct # Auto correct mistakes
setopt extendedglob # Extended globbing. Allows using regular expressions with *
setopt nocaseglob # Case insensitive globbing
setopt rcexpandparam # Array expension with parameters
setopt nocheckjobs # Don't warn about running processes when exiting
setopt numericglobsort # Sort filenames numerically when it makes sense
setopt nobeep # No beep
setopt appendhistory # Immediately append history instead of overwriting
setopt histignorealldups # If a new command is a duplicate, remove the older one
#routes
constraints(AffiliateSubdomain) do
match '/', to: 'affiliates/properties#index', via: :all
end
#libs/affiliate_subdomain.rb
class AffiliateSubdomain
def self.matches? request
matching_site?(request)
def arrayify(string)
if string.class == Array
string.to_a.map{ |v1|
if v1.class == Array
v1.map{ |v2|
if v2.class == Symbol
v2
elsif v2.class == Array
v2.map{|k|
if k.class == Hash
@nanosplit
nanosplit / simple-linear-regression.rb
Created December 12, 2016 08:15 — forked from rweald/simple-linear-regression.rb
Simple Linear Regression in Ruby
class SimpleLinearRegression
def initialize(xs, ys)
@xs, @ys = xs, ys
if @xs.length != @ys.length
raise "Unbalanced data. xs need to be same length as ys"
end
end
def y_intercept
mean(@ys) - (slope * mean(@xs))
@nanosplit
nanosplit / gist:db42e507c5d1d984b664868db10a3669
Created December 12, 2016 03:51 — forked from jrochkind/gist:2636355
reddit 'hot' algorithm, in ruby, with typo fixed
require 'date'
# Actually doesn't matter WHAT you choose as the epoch, it
# won't change the algorithm. Just don't change it after you
# have cached computed scores. Choose something before your first
# post to avoid annoying negative numbers. Choose something close
# to your first post to keep the numbers smaller. This is, I think,
# reddit's own epoch.
$our_epoch = Time.local(2005, 12, 8, 7, 46, 43).to_time
// a noobs no good very bad javascript...
$(function() {
$('#membershipsTable').DataTable({
'order': [[1, 'asc']],
'columnDefs': [{
'targets': [3],
'orderable': false
}],
});
void loop() {
int tSignal_status = digitalRead(tSignal);
if (tSignal_status == 1) {
status = 1;
prev_status = 1;
}
if (tSignal_status == 0) {
require 'sinatra'
require 'sinatra/activerecord'
require './config/environments'
require './models/flick'
require 'pi_piper'
include PiPiper
set :bind, '192.168.1.75'
set :port, '5678'
# Function to print strftime results
def print_strftime_formats(a,cur_date)
a.each do |format|
b = "%#{format}"
output = cur_date.strftime(b)
puts "t.strftime('#{b}'), => #{output}"
end
end
a = ('a'..'z').to_a