Skip to content

Instantly share code, notes, and snippets.

View mcr's full-sized avatar

Michael Richardson mcr

View GitHub Profile
@bartman
bartman / kill-big-chrome-renderers.py
Created September 13, 2020 14:07
kill-big-chrome-renderers.py
#!/usr/bin/env python3
# https://superuser.com/questions/413349/limiting-use-of-ram-in-chrome
import sys, os, psutil
limit = 200 #default 200MB
if len(sys.argv) == 2:
try:
limit = int(sys.argv[1])
except:
@mcr
mcr / gist:e6f78eb106e44d88cc0852f7543c7539
Created February 6, 2017 17:30
Documentation for Chart of Account CSV upload for LedgerSMB
based upon code at: https://github.com/ledgersmb/LedgerSMB/blob/master/lib/LedgerSMB/Scripts/import_csv.pm#L308
There are 9 columns, 0-9. In spreadsheet terms "A" through "I"
A/0 - account number, like "1001"
B/1 - description, free form text
C/2 - charttype: 'A' for account, 'H' for heading
D/3 - category: A = asset, L = liability, Q = Equity, I = Income, E = expense
E/4 - contra: f for regular account, t for contra accounts, such as Liability and Expense
F/5 - tax: t if a tax account, f otherwise
@bartman
bartman / README.md
Last active December 27, 2021 16:24
tmux
@andrey-skat
andrey-skat / deploy.rb
Last active December 1, 2024 08:06
Local assets precompilation on Rails 4 using Capistrano 3
# also you need to uncomment next line in Capfile
# require 'capistrano/rails/assets'
namespace :deploy do
namespace :assets do
Rake::Task['deploy:assets:precompile'].clear_actions
desc 'Precompile assets locally and upload to servers'
task :precompile do
@juanje
juanje / Description.md
Last active November 30, 2023 19:29
Limit Chrome from eating all the memory and CPU

I was tired of Chrome eating all my laptop resources so I decided to put some limit to it with cgroup.

As I was using Ubuntu 12.04 with support for cgroup, I installed the package cgroup-bin and add the following group to the file /etc/cgconfig.conf:

group browsers {
    cpu {
#       Set the relative share of CPU resources equal to 25%
        cpu.shares = "256";
 }
@bhaberer
bhaberer / submodule_strategy.rb
Last active December 8, 2024 08:47 — forked from stevenscg/submodule_strategy.rb
Capistrano 3.1.x Strategy to deploy git projects with submodules.
# Usage:
# 1. Drop this file into lib/capistrano/submodule_strategy.rb
# 2. Add the following to your Capfile:
# require 'capistrano/git'
# require './lib/capistrano/submodule_strategy'
# 3. Add the following to your config/deploy.rb
# set :git_strategy, SubmoduleStrategy
module SubmoduleStrategy
# do all the things a normal capistrano git session would do
@stevenscg
stevenscg / submodule_strategy.rb
Last active July 12, 2019 23:50
Capistrano deploy strategy that supports git submodules (requires Capistrano v3.1.0 or later)
# this include won't work for some reason:
# include Capistrano::Git::DefaultStrategy
module SubmoduleStrategy
# check for a .git directory
def test
test! " [ -d #{repo_path}/.git ] "
end
@drdaeman
drdaeman / 0001-no-reply-wo-explicit-servicename.patch
Created February 17, 2012 03:47
rp-pppoe service-name related patches
--- rp-pppoe-3.8/src/pppoe-server.c 2010-07-15 16:42:39.031057949 +0400
+++ rp-pppoe-3.8/src/pppoe-server.c 2010-07-15 16:48:14.078605821 +0400
@@ -97,6 +97,7 @@
#define MAX_SERVICE_NAMES 64
static int NumServiceNames = 0;
static char const *ServiceNames[MAX_SERVICE_NAMES];
+static int ReactionOnNoServiceName = 1;
PppoeSessionFunctionTable DefaultSessionFunctionTable = {
PppoeStopSession,
@rgl
rgl / chunk.c
Created January 31, 2010 14:15
HTTP chunked transfer in a libevent server
/*
This shows how to use HTTP chunked transfer in libevent. It starts an HTTP server on port 8080; when the client connects, it outputs an message every second. After all messages are outputted, the server closes the HTTP connection.
It has an unsolved crashing problem though... to see it crash, run the next commands in a shell.
See my ML post "after the http client abruptly closes socket libevent (2.0.3-alpha) http server crashes" at http://archives.seul.org/libevent/users/Jan-2010/msg00054.html
Compile with:
gcc -Wall -g -std=c99 -D_GNU_SOURCE -Iinclude -Llib -levent -o chunk chunk.c