Skip to content

Instantly share code, notes, and snippets.

View mindscratch's full-sized avatar

Craig Wickesser mindscratch

View GitHub Profile
@mindscratch
mindscratch / bits.md
Last active August 29, 2015 14:11
optimizing nsq
@mindscratch
mindscratch / chat.md
Last active August 29, 2015 14:12
kubernetes-rollingupdate-chat

mindscratch: now that some people are here, here's an earlier question: hen performing a rolling update (https://github.com/GoogleCloudPlatform/kubernet...) ...how does kubernetes know which image to update if a pod has multiple containers with different images 2:23 PM

jbeda: mindscratch: Right now, it is run client side and is kind of a little too simple. 2:24 PM It captures the list of pods and just kills them one by one. It assumes there is a replication controller that will 'heal' them with the new version 2:24 PM

jbeda: Ideally, the 'upgrader' would make sure that the new pods come up okay, do some health checking, etc.

@mindscratch
mindscratch / foo_test.go
Last active August 29, 2015 14:16
golang integration test
package main
import "testing"
import "time"
import "fmt"
func TestBar(t *testing.T) {
fmt.Println("FOO sleeping")
time.Sleep(time.Second)
fmt.Println("FOO done")
@mindscratch
mindscratch / $.Controller.md
Created May 31, 2011 09:47 — forked from jupiterjs/$.Controller.md
$.Controller for Alex MacCaw's Book

TODOS:

  • show .models() method and hookup

$.Controller - jQuery plugin factory

JavaScriptMVC's controllers are many things. They are a jQuery plugin factory. They can be used as a traditional view, making pagination widgets and grid controls. Or, they can be used as a traditional controller, initializing and controllers and hooking them up to models. Mostly, controller's are a really great way of organizing your application's code.

Controllers provide a number of handy features such as:

@mindscratch
mindscratch / app-config.yml
Created July 6, 2011 09:51
rake task to build a WAR using warbler. The idea being that a YAML file has multiple 'production' configurations but you need to select one when building a WAR for a certain production environment. You can do that by running: rake build_war[some_environme
%YAML 1.1
---
! "defaults":
! "cache": &7000
! "username": ""
! "password": ""
! "servers": ["localhost:11211"]
! "development":
! "cache": *7000
! "prod-server-a"
@mindscratch
mindscratch / gemfile-snippet
Created August 9, 2011 09:43
Reference other ruby or rails engine project from Gemfile
# include version of rails
gem "rails", "3.0.9"
require "rails"
if Rails.env == 'development'
gem "my-other-project", "../my-other-project"
else
gem "my-other-project", "~> 0.0.1"
end
@mindscratch
mindscratch / mongoid_id_monkey_patch.rb
Created August 15, 2011 09:24
Mongoid: return 'id' instead of '_id' when serializing documents as JSON
module Mongoid
module Document
def as_json(options={})
attrs = super options
attrs["id"] = attrs.delete "_id" if attrs.has_key? "_id"
attrs
end
end
end
@mindscratch
mindscratch / routes.rb
Created August 15, 2011 09:44
Rails (3.0.x): easily namespace routes for entire app
MyApp::Application.routes.draw do
my_draw = Proc.new do
get "widgets" => "widgets#index"
# add other routes here
end
@mindscratch
mindscratch / gist:1145962
Created August 15, 2011 09:37
Rails: simple resource routes generation (rails 3.0)
module ActionDispatch
module Routing
class Mapper
# resources can be one or more resource types (should be plural)
#
# ex: simple_resources :widgets
#
# This will generate the following routes:
#
# GET widgets => widgets#index
@mindscratch
mindscratch / warble.rb
Created August 15, 2011 09:47
Rails: warbler config for a JRuby on Rails app
# this file would live in myapp/confif directory
# this only shows the lines that I had uncommented/configured in the warble.rb file
# that was generated with warble v1.3.1
Warbler::Config.new do |config|
config.dirs = %w(app config lib log vendor tmp)
config.webxml.jruby.compat.version = "1.9"