Skip to content

Instantly share code, notes, and snippets.

View qw3r's full-sized avatar

István Demeter qw3r

  • Emarsys
  • Switzerland
  • 02:42 (UTC +02:00)
View GitHub Profile
@qw3r
qw3r / cards.erl
Last active May 24, 2018 00:42
War Erlang ch008, Processes Etude
-module(cards).
-export([make_deck/0, shuffle/1]).
make_deck() ->
[{Rank, Suit} || Rank <- ["A", 2, 3, 4, 5, 6, 7, 8, 9, 10, "J", "Q", "K"],
Suit <- ["Clubs", "Diamonds", "Hearts", "Spades"]].
shuffle(List) -> shuffle(List, []).
shuffle([], Acc) -> Acc;
-module(teeth).
-export([alert/1]).
-spec(alert(list(list(non_neg_integer()))) -> list(non_neg_integer())).
alert(PocketDepths) ->
check_pockets(PocketDepths).
check_pockets([Head | Tail]) ->
@qw3r
qw3r / pyenv-on-codeship.sh
Last active August 7, 2017 16:58
Install PyEnv, the required Python version and package requirements on Codeship
export PYENV_ROOT="${HOME}/cache/.pyenv"
if [ -d ${PYENV_ROOT} ]; then (cd ${PYENV_ROOT}; git pull --rebase); else git clone https://github.com/yyuu/pyenv.git ${PYENV_ROOT}; fi
export PATH="${PYENV_ROOT}/bin:${PATH}"
eval "$(pyenv init -)"
pyenv install -s; echo 'lofasz'
pip install --upgrade pip setuptools
[ -f requirements.txt ] && pip install -r requirements.txt
[ -f requirements.development.txt ] && pip install -r requirements.development.txt
@qw3r
qw3r / vim-on-heroku.sh
Last active August 23, 2016 20:56 — forked from sfate/vim-on-heroku.sh
vim on heroku
curl https://s3.amazonaws.com/heroku-jvm-buildpack-vi/vim-7.3.tar.gz --output vim.tar.gz && mkdir vim && tar xzf vim.tar.gz -C vim && export PATH=$PATH:/app/vim/bin
@qw3r
qw3r / ultimate-ut-cheat-sheet.md
Created May 10, 2016 23:24 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


Docker quick start for Node.js developers

Install Dependencies

Install Docker Toolbox

For Mac and Windows users, just install Docker Toolbox. It provides what you need to get started, including:

@qw3r
qw3r / s3.sh
Last active August 29, 2015 14:20 — forked from chrismdp/s3.sh
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter do
# Find Account_ID by seach for a domain - NOT Refactored yet
host_id = $memcache_instance.get('hosts/' + request.host)
unless host_id
host_db_row = BimbooHost.where( :host => request.host ).one
if host_db_row
$memcache_instance.set('hosts/' + request.host, host_db_row.bimboo_account_id, 60*60)

#####Copied from askubuntu's Enabling mic mute button and light on Lenovo Thinkpad

There are two possible "hardware" indicators (to show that mute is on or off):

The Power button light (green) will blink to show when mute is on The Mic mute button light (orange) will be on or off to show mute status (just like in Windows)

Solution 2 requires a patched thinkpad_acpi kernel module, and is only recommended for advanced users who know what they are doing. This is because the patch is not included by the thinkpad_acpi developers by default, (See this discussion for more details).

###Common Steps

module Tire
module Disable
module ClassMethods
def mock_es_response_doc
@mock_es_response_doc ||=
'{"took": 1,"timed_out": false,"_shards": {"total": 5,"successful": 5,"failed": 0},"hits": {"total": 0,"max_score": null,"hits": []}}'
end
def enable! &blk
old_enabled = @tire_enabled || false