Skip to content

Instantly share code, notes, and snippets.

Jeremy Bingham ctdk

Block or report user

Report or block ctdk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ctdk
ctdk / node_test.rb
Created Jul 2, 2014
Create a bunch of nodes & clients with chef-api and fauxhai
View node_test.rb
#!/usr/bin/env ruby
require 'chef-api'
require 'fauxhai'
include ChefAPI::Resource
ChefAPI.configure do |config|
config.endpoint = 'http://nineveh.local:4545'
config.client = 'admin'
View gist:5f2eda65bf7079cf8c08
{
"apt": {
"1.1.2": {
"dependencies": {
},
"location_path": "http://nineveh.local:4545/cookbooks/apt/1.1.2",
"location_type": "chef_server"
}
},
"build-essential": {
@ctdk
ctdk / velikij.go
Last active Aug 29, 2015
A sample plugin for gosudar.
View velikij.go
package main
// A demonstration of a gosudar plugin. For now, place the compiled binary in /tmp/plugins.
import (
"net"
"net/rpc/jsonrpc"
"os"
)
View gist:9a1109f198ac924e308d
nineveh:goiardi-test jeremy$ knife raw /organizations
{
"default": "http://nineveh.local:4545/organizations/default"
}
nineveh:goiardi-test jeremy$ knife raw /organizations/default
{
"name": "default",
"full_name": "default org",
"guid": "1d40f87ac0b9438f8c20f67c684c32c1"
View moneta-memcached.rb
begin
require "memcached"
rescue LoadError
puts "You need the memcached (the libmemcached client, not the other one) gem to use the Memcached moneta store"
exit
end
# uses the memcached gem properly, and traps the weirdass exception a get on an undefined key throws. May be worth changing
# further to allow the extra flags memcached lets you use, like marshal => true|false or the various memcached flags
View gist:109499
begin
require "memcached"
rescue LoadError
require "memcache"
rescue LoadError
puts "You need the memcache or the memcached gem to use the Memcache moneta store"
exit
end
module Moneta
View gist:112031
class MessageController < ApplicationController
def index
@messagee = User.by_name(params[:nick])
end
def newpmthr
if request.post?
pmthr = PMThread.new
unless (pmthr)
raise "Something's wrong"
View gist:118462
class StoryController < ApplicationController
#require 'utility'
def index
@story = Story.get(params[:id])
#@comments = repository(:default).adapter.query('SELECT comments.id, story_id, user_id, parent_id, time, sid, cid, pid, subject, recrate, trollrate, raters, commentip, comment, nickname from comments left join users on comments.user_id = users.id where story_id = ?', @story.id)
#@comments = Comment.find_by_sql(['SELECT comments.id, subject, nickname from comments left join users on comments.user_id = users.id where story_id = ?', @story.id])
# experiment...
clist = repository(:default).adapter.query('SELECT comments.id, story_id, user_id, parent_id, time, sid, cid, pid, subject, recrate, trollrate, raters, commentip, comment, nickname from comments left join users on comments.user_id = users.id where story_id = ?', @story.id)
chash = Hash.new
View gist:118846
def self.treeify_comments(clist, pid = 0)
chash = Hash.new # comments grouped by parent_id
comhash = Hash.new # comments in a hash, w/ comment id as key
comments = Array.new # for the ordered comments
depth_tree = Hash.new # comment depth
clist.collect { |x| comhash[x.id] = x }
# ?
clist.collect do |c|
chash[c.parent_id] ||= Array.new
View gist:124738
# what breaks
<% blogs = @story.user.blogs %>
# with:
Cannot find the child_model Blogadmin for User
# the relationship in User
# doesn't work
You can’t perform that action at this time.