Skip to content

Instantly share code, notes, and snippets.

View clok's full-sized avatar
👾
I can do this all day.

Derek Smith clok

👾
I can do this all day.
View GitHub Profile
@slackorama
slackorama / js-beautify.el
Created November 23, 2010 19:51
beautify some js code in emacs
;;; js-beautify.el -- beautify some js code
(defgroup js-beautify nil
"Use jsbeautify to beautify some js"
:group 'editing)
(defcustom js-beautify-args "--jslint-happy --brace-style=end-expand --keep-array-indentation"
"Arguments to pass to jsbeautify script"
:type '(string)
:group 'js-beautify)
@ryandotsmith
ryandotsmith / a-backbone-js-demo-app-sinatra-backend.md
Created January 22, 2012 01:42
Backbone demo app with sinatra backend

A Backbone.js demo app (Sinatra Backend)

Oct 16 2010

Updates

  • 04/10/2011 - Updated application.js and application.rb thanks to @rebo's comments

In this article, I will walk through some simple steps to get a [demo app][2] up and running with [Backbone.js][3] and [Sinatra][4] on [Heroku][5].

@clok
clok / color-picker.js
Created April 29, 2012 14:38
Hex Color Fade Picker Plugin for ImpactJS
ig.module(
'plugins.color-picker'
)
.requires(
)
.defines(function(){
/*
Initialize object with a default 10 color array fading from
White to Red and with a Tri-Color array from Green to Yellow
class BackTicks
def run
`pwd`
end
end
describe BackTicks do
subject { BackTicks.new }
it "should execute run" do
@clok
clok / useful.sql
Last active May 9, 2017 13:13
useful sql queries
# process list info
select id, user, db, host, command, state, time from INFORMATION_SCHEMA.PROCESSLIST;
# ALL Tables in ALL DBs
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
@stephan-nordnes-eriksen
stephan-nordnes-eriksen / key-value-performance-test.md
Last active February 21, 2024 03:22
Performance testing different Key-Value stores in Ruby

For a project I am on I need to use a key-value store to converts file-paths to fixnum IDs. The dataset will typically be in the range of 100 000 to 1 000 000. These tests use 305 000 file paths to fixnum IDs.

The Different Key-Value stores tested are:

Daybreak: "Daybreak is a simple and very fast key value store for ruby" GDBM: GNU dbm. "a simple database engine for storing key-value pairs on disk." DBM: "The DBM class provides a wrapper to a Unix-style dbm or Database Manager library" PStore: "PStore implements a file based persistence mechanism based on a Hash. "

Out of these, all except Daybreak are in the Ruby standard library.

@clok
clok / useful.sh
Last active April 11, 2017 12:49
useful shell oneliners
#!/bin/bash
# List most recently modified files (will take time)
find $1 -type f -print0 | xargs -0 stat --format '%Y :%y %n' | sort -nr | cut -d: -f2- | head -20
# get file permissions for a file
perl -e 'printf "%o\n", (stat shift)[2]&07777' SOME-FILE
# Convert INT to IPv4
perl -MSocket=inet_ntoa -le "print inet_ntoa(pack(\"N\", shift))"
@clok
clok / datadog.service
Created April 6, 2016 14:38
DataDog Fleet service with teardown
[Unit]
Description=Datadog
Requires=docker.socket
After=docker.socket
[Service]
ExecStartPre=-/usr/bin/docker stop dd-agent
ExecStartPre=-/usr/bin/docker rm dd-agent
ExecStartPre=/bin/sh -c "docker history datadog/docker-dd-agent:latest >/dev/null || docker pull datadog/docker-dd-agent:latest"
ExecStart=/usr/bin/docker run --privileged --name dd-agent -h %H -v /var/run/docker.sock:/var/run/docker.sock -v /proc/mounts:/host/proc/mounts:ro -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro -e API_KEY=DATADOG_API_KEY datadog/docker-dd-agent
@clok
clok / s3-analysis.rb
Created May 4, 2016 15:07
S3 Bucket usage for the past 24 hours
require 'optparse'
require 'ostruct'
require 'json'
require 'date'
def opts
@opts ||= OpenStruct.new(
verbose: false,
region: 'us-east-1',
aws_profile: 'default',
@CMCDragonkai
CMCDragonkai / regular_expression_engine_comparison.md
Last active May 9, 2025 10:44
Regular Expression Engine Comparison Chart

Regular Expression Engine Comparison Chart

Many different applications claim to support regular expressions. But what does that even mean?

Well there are lots of different regular expression engines, and they all have different feature sets and different time-space efficiencies.

The information here is just copied from: http://regular-expressions.mobi/refflavors.html