Skip to content

Instantly share code, notes, and snippets.

@hinrik
hinrik / gist:305741
Created February 16, 2010 17:57
Supplying a custom FTS3 tokenizer to SQLite from Perl
use strict;
use warnings;
use Inline C => Config => LIBS => '-lsqlite3';
use Inline C => <<'END';
#include <sqlite3.h>
/* Not included in sqlite.h */
#define SQLITE_PRIVATE static
#define SQLITE_ENABLE_FTS3 1
#define UNUSED_PARAMETER(x) (void)(x)
@bdotdub
bdotdub / redis.markdown
Created November 24, 2010 22:18
Running redis using upstart on Ubuntu

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

require 'em-proxy'
require 'http/parser'
require 'uuid'
# > ruby em-proxy-http.rb
# > curl --proxy localhost:9889 www.google.com
host = "0.0.0.0"
port = 9889
puts "listening on #{host}:#{port}..."
@arbales
arbales / handlebars-formatTextForHTML.coffee
Created January 22, 2012 00:08
Replace URLs with links and unicode emoji with images.
LINK_DETECTION_REGEX = /(([a-z]+:\/\/)?(([a-z0-9\-]+\.)+([a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|local|internal))(:[0-9]{1,5})?(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&amp;]*)?)?(#[a-zA-Z0-9!$&'()*+.=-_~:@/?]*)?)(\s+|$)/gi
EMOJI_DIRECTORY = "/path/to/assets/emoji/20x20"
# Handlebars is presumed, but you could swap out
ESCAPE_EXPRESSION_FUNCTION = Handlebars.Utils.escapeExpression
MARKSAFE_FUNCTION = (str) -> new Handlebars.SafeString(str)
# Emoji unicode chars become images.
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
@doxavore
doxavore / gist:3758520
Created September 20, 2012 21:40
RubyMotion 1.23 and iOS 6 (latest XCode)
% rake spec --trace
================================================================================
A new version of RubyMotion is available. Run `sudo motion update' to upgrade.
================================================================================
** Invoke spec (first_time)
** Execute spec
** Invoke simulator (first_time)
** Invoke build:simulator (first_time)
** Execute build:simulator
@seanlilmateus
seanlilmateus / nsvalue_transformer_dsl.rb
Created November 11, 2012 22:20
NSValueTransformer dsl for Rubymotion and MacRuby
class Transformer
def self.withName(name, class:klass, &block)
if block_given?
transformer = Transformer.new(&block)
transformer.build(name, transformedValueClass:klass)
end
end
def initialize(&dsl_code)
@transform = @reverse = nil
@seanlilmateus
seanlilmateus / gist:4134454
Last active January 12, 2018 16:11
Rubymotion GCD Future; with lazy evaluation
#!/usr/bin/env macruby -wKU
framework 'Foundation'
module Dispatch
module Futuristic
def proxy
Class.new(BasicObject) do
def initialize(obj)
@obj = obj
end
@kytrinyx
kytrinyx / README.md
Created January 8, 2013 23:26
Take a snapshot of yourself on every commit.

Git Commit Snapshots

Snap a picture of yourself on every commit.

Probably Mac OS X only, I haven't looked into others.

$ brew install imagesnap
$ git config --global init.templatedir '~/.git_template'
$ chmod +x post-commit
@MrRooni
MrRooni / gist:4988922
Created February 19, 2013 19:16
UITableView and NSFetchedResultsController: Updates Done Right
@interface SomeViewController ()
// Declare some collection properties to hold the various updates we might get from the NSFetchedResultsControllerDelegate
@property (nonatomic, strong) NSMutableIndexSet *deletedSectionIndexes;
@property (nonatomic, strong) NSMutableIndexSet *insertedSectionIndexes;
@property (nonatomic, strong) NSMutableArray *deletedRowIndexPaths;
@property (nonatomic, strong) NSMutableArray *insertedRowIndexPaths;
@property (nonatomic, strong) NSMutableArray *updatedRowIndexPaths;
@end