Skip to content

Instantly share code, notes, and snippets.

View qw3r's full-sized avatar

István Demeter qw3r

  • Emarsys
  • 14:04 - 2h ahead
View GitHub Profile
@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
simpleFormat = (text) ->
re1 = /\r\n?/g
re2 = /\n\n+/g
re3 = /([^\n]\n)(?=[^\n])/g
fstr = text
fstr = fstr.replace(re1, "\n") # \r\n and \r -> \n
fstr = fstr.replace(re2, "</p>\n\n<p>") # 2+ newline -> paragraph
fstr = fstr.replace(re3, "$1<br/>") # 1 newline -> br
"<p>#{fstr}</p>"
@qw3r
qw3r / drop_connections.rake
Created November 13, 2012 15:10 — forked from trekdemo/drop_connections.rake
Drop postgres connections to a database in a Rails application
namespace :db do
desc 'Drop all database connections'
task :drop_connections => :environment do
database = Rails::Application.config.database_configuration[RAILS_ENV]["database"]
field = if ActiveRecord::Base.connection.send( :postgresql_version ) < 90200
'pg_stat_activity.procpic' # PostgreSQL <= 9.1.x
else
'pg_stat_activity.pid' # PostgreSQL >= 9.2.x
end
@qw3r
qw3r / j_unit.rb
Created November 10, 2012 10:50 — forked from natritmeyer/Usage.txt
JUnit formatter for RSpec
=begin
Copyright (c) 2012, Nathaniel Ritmeyer
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.