Skip to content

Instantly share code, notes, and snippets.

View holyketzer's full-sized avatar

Alex Emelyanov holyketzer

View GitHub Profile
@holyketzer
holyketzer / ability.rb
Created December 9, 2013 10:47
CanCan ability class
class Ability
include CanCan::Ability
def initialize(user)
# Define abilities for the passed in user here.
user ||= User.new # guest user (not logged in)
if user.admin?
can :manage, :all
end
# See the wiki for details:
@holyketzer
holyketzer / user_key_bindings.py
Last active December 31, 2015 06:39
Ruby Sublime config itemsItems from user_settings should be added in "Preferences" > "Settings - User"Items from user_key_bindings should be added in "Preferences" > "Key bindings - User"
{ "keys": ["ctrl+t"], "command": "expand_tabs", "args": { "set_translate_tabs": true } }
@holyketzer
holyketzer / run-tests.sh
Created January 15, 2014 12:41
Node.js Mocha runner
#/bin/bash
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "Mac OS X detected"
export NODE_ENV=test && node_modules/.bin/mocha --reporter spec --recursive test
else
echo
SET NODE_ENV=test && node_modules/.bin/mocha --reporter spec --recursive test
fi
@holyketzer
holyketzer / tmux.md
Last active August 29, 2015 13:56 — forked from andreyvit/tmux.md

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

/**
* Created by alex on 15.02.14.
*/
fun main(args: Array<String>) {
var s = readLine()!!
var first = s!!.indexOf('1')
var last = s!!.lastIndexOf('1')
/**
* Module dependencies.
*/
var config = require('../app/config/config')
, url = 'http://localhost:' + config.get('port')
, dbUri = config.get('mongoose:uri')
, request = require('supertest')
, agent = request(url);
var mongoose = require('mongoose')
class Player:
def __init__(self, type):
self.type = type
def do_work(self, *params):
if self.type == 'file':
# Do something like this
lines = open(*params).readlines()
for line in lines:
self.do_something(line)
CLDR.pluralForm not found. Em.I18n will not support count-based inflection.
Trace: Entering db:getAuthenticated function
failed on loading cluster name
ERROR
#App
App.isHadoop21Stack
◦ : ✓
◦ HDP: ✓ HDP
{
"Versions": {
"stack_name": "HDP",
"stack_version": "2.1.1"
},
"hosts": ["dev1.hortonworks.com", "dev2.hortonworks.com", "dev3.hortonworks.com"],
"services": ["FALCON", "FLUME", "GANGLIA", "HBASE", "HCATALOG", "HDFS", "HIVE", "MAPREDUCE2", "NAGIOS", "OOZIE", "PIG", "SQOOP", "STORM", "TEZ", "WEBCHAT", "YARN", "ZOOKEEPER"],
"recommendations": {
"blueprint": {
"configurations": {
# Create gem set and ruby version files
rvm --create --ruby-version use 2.1@gemset-name