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 / API.md
Last active August 29, 2015 13:57 — forked from ryaz/API.md

API

$.li18n.currentLocale = 'xxx';
Set the current locale.

Default is "en".

# Bad, because declarative code without business logic should NOT be absolutely DRY.
%w[Bob Alice].each do |first_name|
%w[Black White].each do |second_name|
Person.create(first_name: first_name, second_name: second_name)
end
end
# Good, because it's clear, what results the code produces. Declarative, baby!
# Not perfect, because the naming of the params is
@kostia
kostia / gist:9079278
Last active August 29, 2015 13:56
Re: 5 surprisingly painful things about client-side JS

Bad search ranking and Twitter/Facebook previews

  • Google & Co. should be feeded with https://prerender.io/
  • Facebook and Twitter should be feeded with extra content. Always. And it's easy to implement.

Flaky stats and monitoring

Dunno...

Slow, complex build tools

@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|
@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 / 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
module Customer
class BaseController < ApplicationController
# ...
before_filter :enable_live_notifications, only: [:waiter_home, :cook_home]
# ...
private
@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}
@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>
~ 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