Skip to content

Instantly share code, notes, and snippets.

View kostia's full-sized avatar

Kostia Newt kostia

  • JustRelate
  • Berlin, Germany
View GitHub Profile
@kostia
kostia / README.md
Created February 23, 2012 14:56
Plugin for HashWithStructAccess for loading YAML from string and from files

HashWithStructAccessYamlLoader

# In you Gemfile
gem("hash_with_struct_access_yaml_loader", :git => "git://gist.github.com/1893175.git")

# In your code
HashWithStructAccess.load_yaml_file("load_me.yml")
@kostia
kostia / gist:4075236
Created November 14, 2012 22:15
German synonyms for Elasticsearch
This file has been truncated, but you can view the full file.
80470 => 80470
ABC => ABC
ABM => ABM
ACL => ACL
ACPI => ACPI
ADAC => ADAC
ADSL => ADSL
AEG => AEG
AG => AG
AGP => AGP
@kostia
kostia / prefere-instance-level-implementations-over-class-level-implementation.md
Last active December 17, 2015 11:39
The is a pseudo-blogpost about why I think an instance level implementations is to prefere over a class level implementation.

Why an instance level implementations is to prefere over a class level implementation.

First of all, let's make clear what is ment by an instance level implementation and a class level implementation.

Here is an example of an instance level implementation:

# driver1.rb
~ vi --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jun 20 2012 13:16:02)
Compiled by root@apple.com
Normal version without GUI. Features included (+) or not (-):
-arabic +autocmd -balloon_eval -browse +builtin_terms +byte_offset +cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
-conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs
-dnd -ebcdic -emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path
+find_in_path +float +folding -footer +fork() -gettext -hangul_input +iconv
+insert_expand +jumplist -keymap -langmap +libcall +linebreak +lispindent
@kostia
kostia / elasticsearch.rb.diff
Created June 27, 2013 08:07
Diff for Elasticsearch Homebrew formula, increasing available memory for Elasticsearch and default pool size for JVM's permanent generation. Basically it solves the problem with `java.lang.OutOfMemoryError: PermGen space` when running Elasticsearch.
diff --git a/Library/Formula/elasticsearch.rb b/Library/Formula/elasticsearch.rb
index bed30bf..054c9ce 100644
--- a/Library/Formula/elasticsearch.rb
+++ b/Library/Formula/elasticsearch.rb
@@ -105,7 +105,11 @@ class Elasticsearch < Formula
<key>EnvironmentVariables</key>
<dict>
<key>ES_JAVA_OPTS</key>
- <string>-Xss200000</string>
+ <string>-Xss200000 -XX:PermSize=500m -XX:MaxPermSize=500m</string>
@kostia
kostia / users.coffee
Last active December 19, 2015 02:09
A coffee-pause with a beauty...
User = require '../models/user'
exports.index = (req, res, next) ->
[page, perPage] = [parseInt(req.query.page, 10) or 0, 5]
require('async').parallel [
(next) -> User.count next,
(next) -> User.find({}).sort(username: 1).skip(page * perPage).limit(perPage).exec next
], (err, [count, users]) ->
return next err if err?
res.render 'users/index', {users, page, perPage, count}
module Customer
class BaseController < ApplicationController
# ...
before_filter :enable_live_notifications, only: [:waiter_home, :cook_home]
# ...
private
@kostia
kostia / polluter.rb
Last active December 30, 2015 02:59
require 'fileutils'
include FileUtils
def sh(cmd)
puts %x{#{cmd}}
end
puts "What's your app's name? "
app_name = STDIN.gets.chomp
@kostia
kostia / kick-it-visual
Last active January 3, 2016 20:59
Visual dialog for "Kick it!"
#!/usr/bin/env ruby
#
# Visual dialog for "Kick it!" (https://github.com/infopark/kick-it)
#
# Requires http://mstratman.github.io/cocoadialog
# Useful for example in combination with http://fitztrev.github.io/shuttle
#
cocoa_dialog_command = '~/Applications/CocoaDialog.app/Contents/MacOS/CocoaDialog' \
@kostia
kostia / check-gem.rb
Created February 3, 2014 15:47
Fast and easy check and test new gems from the CLI.
#!/usr/bin/env ruby
require 'tmpdir'
unless gem_name = ARGV.first
puts 'Usage: check-gem GEM_NAME'
exit 1
end
Dir.mktmpdir("check-gem-#{gem_name}") do |tmpdir|