Skip to content

Instantly share code, notes, and snippets.

View cgriego's full-sized avatar

Chris Griego cgriego

  • Priceline Partner Solutions
  • Portland, Oregon Metro Area
  • 10:18 (UTC -07:00)
  • X @cgriego
View GitHub Profile
@cgriego
cgriego / snippet.txt
Created December 26, 2008 22:30
Testing to see if different script[type] values result in executed JavaScript.
<script type="text/javascript">/* <![CDATA[ */
var types = [
'text',
'application'//,
];
var subtypes = [
'javascript',
'jscript',
'ecmascript',
def detect(path)
git = File.directory?(File.join(path, '.git'))
svn = File.directory?(File.join(path, '.svn'))
hg = File.directory?(File.join(path, '.hg'))
bzr = File.directory?(File.join(path, '.bzr'))
case [git, svn, hg, bzr]
when [true, false, false, false] then SourceControl::Git.new(:path => path)
when [false, true, false, false] then SourceControl::Subversion.new(:path => path)
when [false, false, true, false] then SourceControl::Mercurial.new(:path => path)
From 14c3cd15dd0f50dc02fcfa1a01ad93c723bba36d Mon Sep 17 00:00:00 2001
From: Chris Griego <cgriego@gmail.com>
Date: Tue, 4 May 2010 17:05:42 -0500
Subject: [PATCH] Fix halting callbacks
---
lib/mongoid/persistence.rb | 3 ++-
lib/mongoid/persistence/insert.rb | 3 +--
2 files changed, 3 insertions(+), 3 deletions(-)
class Chef
class Recipe
def has_gem?(name, version=nil)
if !$GEM_LIST
gems = {}
`gem list --local`.each_line do |line|
gems[$1.to_sym] = $2.split(/, /) if line =~ /^(.*) \(([^\)]*)\)$/
end
$GEM_LIST = gems
end
# /etc/mysql/my.cnf: The global mysql configuration file.
# $Header: /var/cvsroot/gentoo-x86/dev-db/mysql/files/my.cnf-4.1,v 1.3 2006/05/05 19:51:40 chtekk Exp $
# The following options will be passed to all MySQL clients
[client]
port = 3306
[mysql]
character-sets-dir=/usr/share/mysql/charsets
default-character-set=utf8
[Mon, 16 Aug 2010 16:50:08 -0700] ERROR: execute[start sysklogd] (/etc/chef/recipes/cookbooks/sysklogd/recipes/default.rb line 1) had an error:
/etc/init.d/sysklogd start returned 1, expected 0
---- Begin output of /etc/init.d/sysklogd start ----
STDOUT: * ERROR: sysklogd is already starting.
STDERR:
---- End output of /etc/init.d/sysklogd start ----
// I want to unset comments.moderated for embedded document in the whole collection
{
"_id" : ObjectId("4cb7f2d5fe38855e43897d13"),
"title" : "Blog Examples Considered Harmful",
"comments" : [
{
"by" : "Bob",
"moderated" : true,
"text" : "first!"
},
@cgriego
cgriego / gist:949389
Created April 30, 2011 04:08
ActiveResource optimizations
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index 1607637..b607ebd 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -1239,9 +1239,10 @@ module ActiveResource
@attributes[key.to_s] =
case value
when Array
- resource = find_or_create_resource_for_collection(key)
+ resource = nil
source "http://rubygems.org"
gem 'i18n', '~> 0.6.0beta1'
@cgriego
cgriego / einval.rb
Created August 16, 2011 21:08
MacBook Pro Early 2011, Lion, REE 2011.03, Mongo, forking #=> Errno::EINVAL
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'mongo'
@conn = Mongo::Connection.new
@db = @conn['supply_chain_development']
puts @db['properties'].find.to_a.size