Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env sh
# I've adapted this from the following, which was in turn adapted from the link
# below it:
# * https://raw.github.com/gist/2108403/hack.sh
# * https://github.com/mathiasbynens/dotfiles/blob/master/.osx
echo "Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)"
# defaults write NSGlobalDomain AppleKeyboardUIMode -int 3

Store file uploads in the database

This gem allows to store carrierwave uploads in the database, eg. on platforms with ephemeral filesystems like Heroku.

Installation

# In: Gemfile
gem 'carrierwave-blob', git: "https://gist.github.com/f1dc8c75d67b92b23a55.git"
@karmi
karmi / index.html
Last active December 18, 2015 15:19 — forked from clintongormley/index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" />
<title>Elasticsearch stats analyzer</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="rules.js"></script>
<script type="text/javascript" src="stats.js"></script>
<script type="text/javascript" src="parser.js"></script>
<script type="text/javascript">
@karmi
karmi / prices.sh
Last active December 15, 2015 16:09 — forked from imotov/prices.sh
curl -XDELETE "localhost:9200/test"
curl -XPUT "localhost:9200/test" -d '{
"mappings": {
"doc": {
"properties": {
"price": {
"type": "long"
},
"colour": {
"type": "string",
@karmi
karmi / Gemfile
Last active August 4, 2021 13:53 — forked from rkh/Gemfile
Sinatra + EventSource JavaScript Streaming
source "http://rubygems.org/"
gem "sinatra", "~> 1.3.0"
gem "thin"
module Tire
module Scroll
DEFAULT_SCROLL_DURATION = '1m'
class Scroll
attr_reader :search, :total, :remaining, :counter
def initialize(indices=nil, options={}, &block)
@search = Tire::Search::Search.new(indices, options, &block)
@options = options
# ========================================
# Testing multiple analyzers per field
# ========================================
# Setup
curl -s -X DELETE 'http://localhost:9200/news_test/'
# Create index with settings and mapping
curl -s -X PUT 'http://localhost:9200/news_test' -d '
{
curl -XPUT ${host}/_template/template_mail -d '
{
"template" : "*",
"settings" : {
"number_of_shards" : 3,
"number_of_replicas" : 1
},
"mappings" : {
"mail" : {
"_index" : { "enabled" : true },
@karmi
karmi / aliases_and_mapping.sh
Created January 26, 2011 09:05 — forked from vhyza/elasticsearch_mapping.sh
Mappings for different languages in ElasticSearch indices
# Setup
curl -X DELETE 'http://localhost:9200/news_cs/'
curl -X DELETE 'http://localhost:9200/news_en/'
# Create Czech and English indices (databases)
curl -X PUT 'http://localhost:9200/news_cs/'
curl -X PUT 'http://localhost:9200/news_en/'
# Create mapping for Czech documents
curl -X PUT 'http://localhost:9200/news_cs/_mapping' -d '
@karmi
karmi / couchapp.html
Created November 27, 2010 16:47 — forked from jchris/couchapp.html
<!DOCTYPE html>
<html>
<!-- This should be the simplest possible jQuery based CouchApp. Install by uploading to a design document in Futon or putting in _attachments/index.html and running `couchapp push` -->
<head><title>Tiny CouchApp</title></head>
<body>
<h1>Tiny CouchApp</h1>
<ul id="databases"></ul>
</body>
<script src="/_utils/script/jquery.js"></script>
<script src="/_utils/script/jquery.couch.js"></script>