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
  • 18:50 (UTC -04:00)
  • X @cgriego
View GitHub Profile
@cgriego
cgriego / grind.rb
Created April 21, 2015 17:07
2008 era image optimizer script
#!/usr/bin/env ruby
# Copyright (c) 2008 Chris Griego
#
# Grinder is freely distributable under the terms of an MIT-style license.
# For details, see http://www.opensource.org/licenses/mit-license.php
require 'rubygems'
require 'mime/types'
@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'