Skip to content

Instantly share code, notes, and snippets.

View sideshowcoder's full-sized avatar
💭
🐱

Philipp Fehre sideshowcoder

💭
🐱
View GitHub Profile
@sideshowcoder
sideshowcoder / item_view_controller.rb
Created June 9, 2014 11:19
Couchbase as a table view data source
class ItemsViewController < UIViewController
attr_accessor :database, :user_id, :data_source
def viewDidLoad
super
navigationItem.title = "Items"
@items_table = UITableView.alloc.initWithFrame(view.bounds)
@items_table.delegate = self
@data_source = CBLUITableSource.alloc.init
#import "Blocks.h"
#import <CouchbaseLite/CouchbaseLite.h>
@implementation Blocks
+(void)setupListsMapBlockForView:(CBLView*)view
{
if (!view.mapBlock) {
[view setMapBlock: MAPBLOCK({
if ([doc[@"type"] isEqualToString:@"list"])
@sideshowcoder
sideshowcoder / .jshintrc
Created June 30, 2014 16:10
Couchbase views jshintrc
{
"-W025": false
}
var cb = require("couchbase")
var async = require("async")
var cluster = new cb.Cluster("couchbase://localhost/")
var bucket = cluster.openBucket("default")
bucket.queryhosts = ["localhost:8093"]
var log = function () {
var args = Array.prototype.slice.call(arguments, 0)
console.log.apply(null, args.filter(function (e) { return e != null }))
@sideshowcoder
sideshowcoder / index.js
Created July 11, 2014 13:51
Couchbase View Query example key prefix matching
var couchbase = require("couchbase")
var async = require("async")
var bucket = new couchbase.Connection({})
function die(msg) {
if(msg) console.log(msg)
bucket.shutdown()
process.exit()
}
@sideshowcoder
sideshowcoder / 1000_docs.erl
Created September 2, 2014 16:09
Creating a 1000 documents in Couchbase via Erlang oneliner
[cberl:set(default, list_to_binary(X), 0, {[{<<"type">>,<<"bar">>}]}) || X <- [lists:flatten(io_lib:format("bar-~p", [X])) || X <- lists:seq(4, 10000)]].
#!/bin/bash
# Output is a script which installs all currently installed packages from
# homebrew, including those from tabs. Packages no longer available are ignored
# Usage:
# ./backup-homebrew.sh > my-homebrew-backup.sh
#
# warnings about packages not available anymore will be generated
#
/**
* Functions to handle transition from Tumblr to Wordpress
* author: philipp fehre <philipp@fehre.co.uk
*
* The goal ist to make imported tumbler posts work along the normal permalinks
* generated by tumblr
*
* This works for posts imported via http://tumblr2wordpress.benapps.net
* exported file containing the tumblr post ids in the post_name field.
*/
require "dotenv/tasks"
require "uri"
namespace :development do
desc "run server"
task :server => :dotenv do
sh "php -S localhost:9292 "
end
desc "open a local database shell"
if (null !== getenv("DATABASE_URL")) {
$db = parse_url(getenv("DATABASE_URL"));
define("DB_NAME", trim($db["path"],"/"));
define("DB_USER", $db["user"]);
define("DB_PASSWORD", $db["pass"]);
define("DB_HOST", $db["host"]);
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
} else {
die("Your heroku DATABASE_URL does not appear to be correctly specified.");