Skip to content

Instantly share code, notes, and snippets.

View macournoyer's full-sized avatar

Marc-André Cournoyer macournoyer

View GitHub Profile
def strrev(s)
class TmpObject < ActiveRecord::Base
acts_as_an_object_with_a_reversed_string_column :tmp
end
TmpObject.new(s).reversed_tmp
end
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <string.h>
#define JIT_ALLOC_FUNC(size) \
(u8 *)mmap(NULL, size, PROT_READ|PROT_WRITE|PROT_EXEC, \
(MAP_PRIVATE|MAP_ANON), -1, 0)
typedef unsigned char u8;
def self.memoize_with_memcache(name)
define_method "#{name}_with_memo" do
key = [self.class.name, id.to_s] * '/'
Cache.get(key) || Cache.put(key, name_without_memo)
end
alias_method_chain :name, :memo
end
Process: Vim [2098]
Path: /Applications/MacVim.app/Contents/MacOS/Vim
Identifier: Vim
Version: ??? (???)
Code Type: X86 (Native)
Parent Process: MacVim [2096]
Date/Time: 2009-01-21 16:19:43.164 -0500
OS Version: Mac OS X 10.5.6 (9G55)
Report Version: 6
$ 2009-01-21 16:14:23.083 Vim[1983:10b] ERROR: Failed to load dictionaries.
Most likely this is because you have symlinked directly to
the Vim binary, which Cocoa does not allow. Please use an
alias or the mvim shell script instead. If you have not used
a symlink, then your MacVim.app bundle is incomplete.
E254: Cannot allocate color Red
E254: Cannot allocate color White
E254: Cannot allocate color Blue
#!/usr/bin/env ruby
# List tweets w/ links.
# require: sudo gem install jnunemaker-twitter --source http://gems.github.com
# usage: twitlinks [num]
require "rubygems"
require "twitter"
# EDIT THIS
EMAIL = 'ur@emailz.com'
PASSWORD = 'greenerpoop'
Error while running applet.
processing/core/PApplet.java:1242:in `createGraphics': java.lang.RuntimeException: You need to use "Import Library" to add processing.opengl.PGraphicsOpenGL to your sketch. (NativeException)
from processing/core/PApplet.java:1015:in `size'
from processing/core/PApplet.java:959:in `size'
from sun/reflect/NativeMethodAccessorImpl.java:-2:in `invoke0'
from sun/reflect/NativeMethodAccessorImpl.java:39:in `invoke'
from sun/reflect/DelegatingMethodAccessorImpl.java:25:in `invoke'
from java/lang/reflect/Method.java:585:in `invoke'
from org/jruby/javasupport/JavaMethod.java:250:in `invokeWithExceptionHandling'
from org/jruby/javasupport/JavaMethod.java:219:in `invoke'
From d8d28ef73fdd539e0d6a358b7e3f00ac5317842c Mon Sep 17 00:00:00 2001
From: macournoyer <macournoyer@gmail.com>
Date: Wed, 19 Nov 2008 15:43:45 -0500
Subject: [PATCH] Fix presentable_for so longest presentable name is matched first.
This makes sure subscripton_discount_ is matched before subscripton_.
---
.../lib/active_presenter/base.rb | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
class User
has_many :cats
end
class UserTest < Test::Unit::TestCase
# Useless
should_have_many :cats
# Useful
def test_should_add_a_cat
# Memcache-like Invisible app
STORE = {}
with ":key" do
put { STORE[params[:key]] = params[:value] }
get { render STORE[params[:key]] }
end