Skip to content

Instantly share code, notes, and snippets.

View zerobearing2's full-sized avatar

Dave Bradford zerobearing2

View GitHub Profile
@zerobearing2
zerobearing2 / services-start.sh
Last active March 3, 2021 17:40 — forked from ovace/services-start.sh
multi SSID with VLAN script, for ASUS AC86U with merlin
#!/bin/sh
# multi SSID with VLAN script, for ASUS AC86U with merlin
#
# setup before hand:
# set "router" to "AP Mode"
# this will put all ports and wireless in br0
# create 3 guest network
# enable Administration => System => Enable JFFS custom scripts and configs
# put this script in /jffs/scripts/, name should be "services-start"
require "net/http"
def start_server
# Remove the X to enable the parameters for tuning.
# These are the default values as of Ruby 2.2.0.
@child = spawn(<<-EOC.split.join(" "))
XRUBY_GC_HEAP_FREE_SLOTS=4096
XRUBY_GC_HEAP_INIT_SLOTS=10000
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0
@zerobearing2
zerobearing2 / deflate_request.rb
Last active August 29, 2015 14:05 — forked from relistan/compress_requests.rb
Rack middleware to deflate/unzip requests
module Rack
#
# Deflate/ungzip request body
#
class DeflateRequest
def initialize(app)
@app = app
end
task :console do
require 'irb'
require 'irb/completion'
require 'my_gem' # You know what to do.
ARGV.clear
IRB.start
end
select.form-control + .chosen-container.chosen-container-single .chosen-single {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
color: #555;
vertical-align: middle;
background-color: #fff;
@zerobearing2
zerobearing2 / bootstrap.sass
Created October 31, 2013 17:10
Bootstrap 3 w/Simple Form configuration
@import "bootstrap"
.form-control.boolean
width: auto
height: auto
@zerobearing2
zerobearing2 / pg_json_store.rb
Last active December 27, 2015 00:59
ActiveRecord Store for Postgres' JSON data type
module ActiveRecord
module PgJsonStore
extend ActiveSupport::Concern
module ClassMethods
#
# Store (JSON) using Postgres
# JSON data type.
#
@zerobearing2
zerobearing2 / 401_json.rb
Created April 20, 2012 19:40
Rails 3.2.x HTTP Basic 401 as JSON
# Overload rails 3.2.x default HTTP Baisc 401 response
# to JSON instead of plain text/html.
#
# Examples
#
# require 'json_401'
# class ApiController < ActionController::Metal
# ...
# end
#
@zerobearing2
zerobearing2 / embedded_callbacks.rb
Created September 5, 2010 19:01
bubble down callbacks to embedded associations with mongoid
# encoding: utf-8
module Mongoid #:nodoc:
module Associations #:nodoc:
module EmbeddedCallbacks
# bubble callbacks to embedded assocaitions
def run_callbacks(*args)
# now bubble callbacks down
self.associations.each_pair do |name, meta|
if meta.association == Mongoid::Associations::EmbedsMany
@zerobearing2
zerobearing2 / nginx
Created August 27, 2009 03:12
centos /etc/init.d script for nginx
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /opt/nginx/conf/nginx.conf
# pidfile: /var/run/nginx.pid