Skip to content

Instantly share code, notes, and snippets.

View jheidt's full-sized avatar
💭
:shipit: 👍

Jake jheidt

💭
:shipit: 👍
View GitHub Profile
@havenwood
havenwood / producer-consumer.rb
Created May 14, 2013 01:14
Producer-consumer problem in Ruby with SizedQueue
require 'thread'
class ProducerConsumer
def initialize producers = 5, consumers = 5, queue_size = 5
@producers, @consumers = producers, consumers
@queue = SizedQueue.new queue_size
@mutex = Mutex.new
@threads = []
end
@sj26
sj26 / assets.rake
Last active May 13, 2023 04:42
Don't discard cache during asset precompile. Full explanation and caveats: http://sj26.com/2013/02/09/the-asset-pipeline-isnt-actually-slow
# Stick this in lib/tasks/assets.rake or similar
#
# A bug was introduced in rails in 7f1a666d causing the whole application cache
# to be cleared everytime a precompile is run, but it is not neccesary and just
# slows down precompiling.
#
# Secondary consequences are the clearing of the whole cache, which if using
# the default file cache could cause an application level performance hit.
#
# This is already fixed in sprockets-rails for rails 4, but we patch here for
@nmcv
nmcv / bash_xor.txt
Created February 1, 2013 11:02
Quick XOR of hexadecimal strings for BASH
# BASH function to get the result
# of a ^ b when a, b are in the
# following hexadecimal string
# form: AF396463D8705 ...
# Obtained from here:
# http://www.codeproject.com/Tips/470308/XOR-Hex-Strings-in-Linux-Shell-Script
# Author is Sanjay1982 (see http://www.codeproject.com/Members/Sanjay1982)
# Usage:
@radupotop
radupotop / gist:4013294
Created November 4, 2012 19:48
PolKit rules to allow mounting, rebooting and network management without a password
// /etc/polkit-1/rules.d/10-rules.rules
// PolKit rules to allow mounting, rebooting and network management without a password.
// User needs to be in storage, power and network groups.
polkit.addRule(function(action, subject) {
if (action.id.match("org.freedesktop.udisks2.") && subject.isInGroup("storage")) {
return polkit.Result.YES;
}
});
@lhw
lhw / pom.xml
Created August 30, 2012 12:26
maven file with sqlite4java
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.ring0.lhw</groupId>
<artifactId>system</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.almworks.sqlite4java</groupId>
<artifactId>sqlite4java</artifactId>
@ogrodnek
ogrodnek / gist:2933779
Created June 15, 2012 00:13
AWS Billing hive schema
create external table aws_billing(
InvoiceId string,
PayerAccountId string,
LinkedAccountId string,
RecordType string,
RecordID int,
BillingPeriodStartDate string,
BillingPeriodEndDate string,
InvoiceDate string,
PayerAccountName string,
@trustin
trustin / fontfix.patch
Last active November 30, 2015 15:47
OpenJDK 7 font rendering patch for Linux (cd openjdk/jdk; patch -p1 < fontfix.patch)
diff -r 19cc3b567644 make/sun/font/Makefile
--- a/make/sun/font/Makefile Wed Jan 22 12:34:24 2014 -0800
+++ b/make/sun/font/Makefile Fri Jan 24 21:41:23 2014 +0900
@@ -138,7 +138,7 @@
ifeq ($(USING_SYSTEM_FT_LIB), false)
FREETYPE_LIB = $(LIB_LOCATION)/$(LIB_PREFIX)freetype.$(LIBRARY_SUFFIX).6
endif
- OTHER_LDLIBS += -L$(FREETYPE_LIB_PATH) -lfreetype
+ OTHER_LDLIBS += -L$(FREETYPE_LIB_PATH) -lfreetype -lfontconfig
endif
@deviantintegral
deviantintegral / compress-tables.sh
Created April 12, 2012 17:27
Compress MySQL Tables
#!/usr/bin/env bash
# Compress MySQL tables on disk.
# Author: Andrew Berry, andrew.berry@lullabot.com
#
# Compress all tables in a MySQL InnoDB database using compression from the
# Barracuda table format. Tables have to already be in the Barracuda file
# format to actually compress tables, otherwise the table setting is ignored.
#
# innodb_file_per_table = 1 MUST be set in my.cnf for compression to work.
@xuhdev
xuhdev / ctags_with_dep.sh
Last active November 7, 2023 15:51
Generate ctags file for C or C++ files and its depedencies (included header files). This could avoid you to always generate a huge tags file.
#!/bin/sh
# https://www.topbug.net/blog/2012/03/17/generate-ctags-files-for-c-slash-c-plus-plus-source-files-and-all-of-their-included-header-files/
# ./ctags_with_dep.sh file1.c file2.c ... to generate a tags file for these files.
gcc -M "$@" | sed -e 's/[\\ ]/\n/g' | \
sed -e '/^$/d' -e '/\.o:[ \t]*$/d' | \
ctags -L - --c++-kinds=+p --fields=+iaS --extra=+q
@jstorimer
jstorimer / hilong.rb
Last active July 30, 2020 06:52
hilong -- A simply utility to show character counts for each line of input and highlight lines longer than 80 characters.
#!/usr/bin/env ruby
# A simply utility to show character counts for each line of input and
# highlight lines longer than 80 characters.
#
# Written as an example for http://jstorimer.com/2011/12/12/writing-ruby-scripts-that-respect-pipelines.html
#
# Examples:
#
# $ hilong Gemfile