Skip to content

Instantly share code, notes, and snippets.

View morgoth's full-sized avatar

Wojciech Wnętrzak morgoth

View GitHub Profile
@peterhost
peterhost / node_debian_init.sh
Created November 25, 2010 11:41
Daemon init script for node.js based app/server (DEBIAN/UBUNTU)
#!/bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
@szimek
szimek / basecamp-daily-report.user.js
Created December 7, 2011 14:22
Adds a button on time entries page to create a daily report for a user.
// ==UserScript==
// @match https://objectreload.basecamphq.com/projects/*
// ==/UserScript==
var container = document.getElementById('report_link_block'),
link = document.createElement('a'),
content = document.createTextNode('Create a daily report'),
date = new Date(),
user,
path;
@morgoth
morgoth / gist:1468756
Last active September 28, 2015 16:58
Pulseaudio sound server configuration
# Configuring sound server
# Tested on Ubuntu 11.10
sudo apt-get install pulseaudio-module-zeroconf
# Change /etc/default/pulseaudio file on server to contain:
PULSEAUDIO_SYSTEM_START=1
DISALLOW_MODULE_LOADING=1
@pcworld
pcworld / _README.md
Last active December 8, 2023 20:22
Linux Spotify Ad Mute
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@viniciusteles
viniciusteles / bench.rb
Created November 4, 2012 16:19
Picasa API access benchmarks
require 'rubygems'
require 'benchmark'
require 'httparty'
@picasa_user = '117499753694301708125'
class XmlFetcher
include HTTParty
format :xml
end
@malarkey
malarkey / Three Wise Monkeys.md
Created December 2, 2012 14:26
Three Wise Monkeys (NDA)

Date: [date]

Between us [company name] and you [customer name].

Summary:

In short; neither of us will share any confidential information about each-other, by any means, with anyone else.

What’s confidential information?

@neerajsingh0101
neerajsingh0101 / guideline.md
Last active April 24, 2017 23:46
How to file Active Record bug report

How to file Active Record bug report

In order to make it easier to verify Active Record bugs you are encouraged to file bug report using one of the templates mentioned below .

If you are using published versions of gems then all you need to create is a single gist file like this .

If you are using master version of rails then use this template . Note that in this case both Gemfile and test file are needed .

@krasnoukhov
krasnoukhov / 2013-01-07-profiling-memory-leaky-sidekiq-applications-with-ruby-2.1.md
Last active October 4, 2023 21:53
Profiling memory leaky Sidekiq applications with Ruby 2.1

My largest Sidekiq application had a memory leak and I was able to find and fix it in just few hours spent on analyzing Ruby's heap. In this post I'll show my profiling setup.

As you might know Ruby 2.1 introduced a few great changes to ObjectSpace, so now it's much easier to find a line of code that is allocating too many objects. Here is great post explaining how it's working.

I was too lazy to set up some seeding and run it locally, so I checked that test suite passes when profiling is enabled and pushed debugging to production. Production environment also suited me better since my jobs data can't be fully random generated.

So, in order to profile your worker, add this to your Sidekiq configuration:

if ENV["PROFILE"]
@ncr
ncr / limiter.rb
Last active February 5, 2024 18:21
Simple Limiter based on individual keys instead of Redis hashes which are impossible to expire individually
require 'redis'
require 'redis-namespace'
class Limiter
def initialize(name:, threshold:, interval:, time_span: 600, bucket_span: 5)
@name, @threshold, @interval, @time_span, @bucket_span = name, threshold, interval, time_span, bucket_span
raise ArgumentError if @interval > @time_span || @interval < @bucket_span
@redis ||= Redis::Namespace.new(:limiter, redis: $redis || Redis.new)