Skip to content

Instantly share code, notes, and snippets.

View courtsimas's full-sized avatar
🏠
Building

Court Simas courtsimas

🏠
Building
View GitHub Profile
ip_array = %w{
3.0.0.0/8
4.0.0.0/8
5.35.192.0/21
5.150.156.0/22
5.152.184.0/21
6.0.0.0/7
8.0.0.0/9
8.192.0.0/12
8.224.0.0/11
def grouped_options_from_enum(model, enum, label)
grouped_options = [].tap do |opts|
model.send(enum.to_s.pluralize).keys.each do |enum_value|
opts << [enum_value.humanize, model.send(enum_value).collect {|obj| [obj.send(label), obj.id]}]
end
end
grouped_options
end
@courtsimas
courtsimas / Mobile-Particle-Add.shader
Created January 24, 2018 21:50 — forked from keijiro/Mobile-Particle-Add.shader
Mobile/Particles/Additive shader (Unity built-in shader)
// Simplified Additive Particle shader. Differences from regular Additive Particle one:
// - no Tint color
// - no Smooth particle support
// - no AlphaTest
// - no ColorMask
Shader "Mobile/Particles/Additive" {
Properties {
_MainTex ("Particle Texture", 2D) = "white" {}
}
from scapy.all import *
import requests
import time
MAGIC_FORM_URL = 'http://put-your-url-here'
def record_poop():
data = {
"Timestamp": time.strftime("%Y-%m-%d %H:%M"),
"Measurement": 'Poopy Diaper'
}
_=$$/$$;__=_-_;@_=_+_;$_=@_+_;$__=@_+$_;$-_=$__*$_
@__=''<<$-_*($__+$_)+@_
$___=''<<$-_*$__-$__<<$-_*($__+@_)<<@__<<@__
@___=''<<$-_*$__-$_*$_<<$-_*($__+$_)-$_<<@__<<@__
(___=->{$.+=_;$><<($.%$-_==__ ?$___+@___:$.%$_==__ ?$___:$.%
$__==__ ?@___:$.)<<(''<<$__*@_);$.<($__*@_)**@_?___[]:_})[]
@courtsimas
courtsimas / 0_reuse_code.js
Created January 20, 2014 17:37
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@courtsimas
courtsimas / unicorn.rb
Created June 28, 2012 15:53
our unicorn setup
worker_processes 2
timeout 30
preload_app true
before_fork do |server, worker|
# Replace with MongoDB or whatever
if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect!
Rails.logger.info('Disconnected from ActiveRecord')
end
@courtsimas
courtsimas / gist:3007196
Created June 27, 2012 22:13
grabbing a digested file when a source is passed in, when the asset_path refuses to return the digested version
def get_digest_file(source)
return asset_path(source.to_s.downcase) unless Rails.application.config.assets.digests.present?
return ActionController::Base.asset_host + "/assets/" + Rails.application.config.assets.digests[source.to_s.downcase]
end
@courtsimas
courtsimas / unicorn.rb
Created May 10, 2012 22:52
our unicorn heroku setup
worker_processes 2
timeout 30
preload_app true
before_fork do |server, worker|
# Replace with MongoDB or whatever
if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect!
Rails.logger.info('Disconnected from ActiveRecord')
end
@courtsimas
courtsimas / gist:2639836
Created May 8, 2012 22:12
transferring database from one heroku app to another

First, capture (backup) the database from the primary app

$ heroku pgbackups:capture --app appname_im_transferring_from

Then, import it into the second app

$ heroku pgbackups:restore DATABASE `heroku pgbackups:url --app appname_im_transferring_from` --app appname_im_transferring_to