Skip to content

Instantly share code, notes, and snippets.

View 13k's full-sized avatar

K 13k

View GitHub Profile
@13k
13k / fragment_cache.rb
Created April 3, 2014 16:13
fragment cache fetch/expire
ActionController::Base.new.read_fragment('key')
ActionController::Base.new.expire_fragment('key')
@13k
13k / mappings.rb
Last active August 29, 2015 14:02
class Target
class_attribute :index_mappings
class << self
def mappings(*args, &block)
self.index_mappings ||= { options: {}, mappings: {} }
mappings = nil
options = nil
require "benchmark/ips"
state1 = :initial
state2 = "initial"
Benchmark.ips do |x|
x.report("<Symbol> => (<String>, <Symbol>)") do
case state1
when "initial", :initial
a = 1
@13k
13k / 127.0.0.1.txt
Created November 28, 2014 20:00
curl bug
$ curl 127.0.0.1:9200
{
"status" : 200,
"name" : "Stonewall",
"version" : {
"number" : "1.3.4",
"build_hash" : "a70f3ccb52200f8f2c87e9c370c6597448eb3e45",
"build_timestamp" : "2014-09-30T09:07:17Z",
"build_snapshot" : false,
"lucene_version" : "4.9"
@13k
13k / automount_nfs_osx.md
Created December 17, 2014 01:04
Automount NFS exports in OSX

Linux server

Install NFS.

Add to /etc/exports:

<export_path>   <network>/24(rw,nohide,insecure,no_subtree_check,sync,all_squash,anonuid=1000,anongid=1000)
@13k
13k / gvm_auto.sh
Last active August 29, 2015 14:17
# Based on chruby's auto feature
# https://github.com/postmodern/chruby/blob/bfd78880fbbbf13635e1f97f83225c6a03ca6e89/share/chruby/auto.sh
function gvm_auto() {
local dir="$PWD/" version
until [[ -z "$dir" ]]; do
dir="${dir%/*}"
if { read -r version <"$dir/.go-version"; } 2>/dev/null || [[ -n "$version" ]]; then
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Sends a bunch of links to delicious.
#
# This script depends on pydelicious library, which can be found here:
# http://code.google.com/p/pydelicious/
#
# Command-line usage:
#
# delicious_send.py <username> <password> <file with links> [file2, file3, ... ]
@13k
13k / 0001-Horizontal-size-and-alignment.patch
Created February 9, 2009 07:11
Patches Guake (9a41f1f8b7ce073302e864cd71901c0628d818be) to have horizontal size and alignment
From 9a41f1f8b7ce073302e864cd71901c0628d818be Mon Sep 17 00:00:00 2001
From: Kiyoshi de Brito Murata <13k@kside.net>
Date: Mon, 9 Feb 2009 05:03:32 -0200
Subject: [PATCH] Horizontal size and alignment
---
data/guake.schemas | 32 +++++-
data/prefs.glade | 274 ++++++++++++++++++++++++++++++++--------------
src/guake.py | 92 +++++++++++-----
src/guake_globals.py.in | 3 +
class Array
def slices(*args)
args.map do |arg|
case arg
when Range, Fixnum
self[arg]
else
raise ArgumentError, "Arguments for slices() must be either Fixnum or Range"
end
end
#!/bin/sh
# Pushes current branch to remote branch possibly with different names
# With no arguments, pushes to origin +<branch>:<branch> where <branch>
# is the same branch name as current.
# With one argument, pushes to origin +<branch>:<argument>
head=`git symbolic-ref HEAD`
branch=`basename $head`
git push origin +$branch:${1:-$branch}