Skip to content

Instantly share code, notes, and snippets.

View jcalvert's full-sized avatar

Jonathan Calvert jcalvert

View GitHub Profile
Variable_name Value
auto_increment_increment 1
auto_increment_offset 1
autocommit ON
automatic_sp_privileges ON
back_log 50
basedir /usr/local/mysql
big_tables OFF
binlog_cache_size 32768
binlog_direct_non_transactional_updates OFF
module MethodPair
def method_accessor(var, &block)
define_method("set_#{var}",block)
define_method(var) do
var_name = var.to_s.gsub(/\?/,'')
insvar = instance_variable_get("@#{var_name}")
unless insvar
insvar = self.send("set_#{var}")
instance_variable_set("@#{var_name}", insvar)
curl -v "https://maps.googleapis.com/maps/api/place/search/json?sensor=true&key=censored&location=38.897,-77.036&radius=&language=en-US&name=Starbucks&rankby=prominence&types="
*snip*
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=UTF-8
< Date: Tue, 09 Oct 2012 22:17:25 GMT
< Server: mafe
< Cache-Control: private
< X-XSS-Protection: 1; mode=block
Glad:
To be off subversion!!!!!!!!
To feel finally over a significant hump.
That we've got some traction to improving our process.
Sad:
That we have yet to realize that e-Release is silly.
Corollary: that we're not quite ready for something like CI/CD
That I didn't get to work on new stuff rather than fixing bugs.
function ssh_connection() {
if [[ -n $SSH_CONNECTION ]]; then
echo "%{$fg_bold[red]%}(ssh) "
fi
}
PROMPT=$'\n$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}:%{$fg_bold[blue]%}%2/%{$reset_color%}:$ '
ZSH_THEME_PROMPT_RETURNCODE_PREFIX="%{$fg_bold[red]%}"
ZSH_THEME_GIT_PROMPT_PREFIX=" $fg[white]‹ %{$fg_bold[yellow]%}"
@jcalvert
jcalvert / rake output
Created June 5, 2012 15:42
Nested with_options
GET /:locale/services/foo/:name {:action=>"config", :controller=>"services/foo"}
GET /:locale/services/bar/:name {:action=>"config", :controller=>"services/bar"}
@jcalvert
jcalvert / sort-out.rb
Created March 19, 2012 15:23
candidate's sample code. ouch. sql injection
require 'rubygems'
require 'sequel'
require 'sqlite3'
def readFile(filePath)
#Creating file handler
STDOUT.sync = true
fileObj = File.open(filePath)
begin
#Making use of in-memory database for faster and better performace
db = Sequel.sqlite
module Multiball
module Multicaster
def multi_method(proxied_thing, *args)
args.each do |method|
define_method method do |*method_args|
Multiball.servers.values.each{|value| value.send(proxied_thing).send method, method_args}
end
end
end
@jcalvert
jcalvert / unicron.rb
Created March 5, 2012 22:05
AR Sinatra filters
before do
request[:connection] = ActiveRecord::Base.connection_pool.checkout
end
after do
ActiveRecord::Base.connection_pool.checkin(request[:connection]) if request[:connection]
end
@jcalvert
jcalvert / app.rb
Created March 2, 2012 20:18
Sinatra IP filter?
before do
unless ['10','192','127'].include? request.ip.to_s.gsub /(.*?)\..*/,'\\1'
halt(404, "Not found") #I should probably throw 403, but in this case it's sensitive and I'd rather make like a hole.
end
end