Skip to content

Instantly share code, notes, and snippets.

@mat
mat / INSTALL
Created August 12, 2011 19:43
Turn an Ubuntu 10.04 server into a StatsD/Graphite server
TODO:
- edit /opt/statsd/local.js
- correct the graphite host to localhost
- if desired, put 'debug: true' in there
- make the box accessible via the hostname 'graphite'
- update conf/storage-schemas.conf, see example for these retention rules:
6 hours of 10 second data
1 week of 1 minute data
5 years of 10 minute data
@oliverdaff
oliverdaff / binarysearch.sh
Created July 23, 2013 23:40
Bash Script Binary Search
binary_search(){
TARGET=$1
TO_SEARCH=(${@:2})
LENGTH=${#TO_SEARCH[@]}
START=0
END=$((LENGTH - 1))
while [[ $START -le $END ]]; do
MIDDLE=$((START + ((END - START)/2)))
ITEM_AT_MIDDLE=${TO_SEARCH[MIDDLE]}
@kgriffs
kgriffs / enable-winrm.ps1
Last active October 17, 2017 17:49
Enable WinRM (w2k8r2 or better)
# Configure a Windows host for remote management with Ansible
# -----------------------------------------------------------
#
# This script checks the current WinRM/PSRemoting configuration and makes the
# necessary changes to allow Ansible to connect, authenticate and execute
# PowerShell commands.
#
# Written by Trond Hindenes <trond@hindenes.com>
# Updated by Chris Church <cchurch@ansible.com>
# Updated by Kurt Griffiths <kurt.griffiths@rackspace.com>
@mhart
mhart / git-fixup.sh
Created December 11, 2012 04:16
Script to fixup/squash commits given on a cmd line - can be used as a Custom Action in SourceTree
#!/bin/bash
lastCommit=""
editorCmd="sed -i ''"
for commit in $@; do
lastCommit=${commit:0:7}
editorCmd="$editorCmd -e 's/pick ${lastCommit}/fixup ${lastCommit}/'"
done
GIT_SEQUENCE_EDITOR=$editorCmd git rebase -i ${lastCommit}~2
@syntagmatic
syntagmatic / README.md
Last active July 18, 2019 10:59 — forked from mbostock/.block
Github Users Worldwide
@nixpulvis
nixpulvis / gem-reset
Last active October 5, 2020 15:21
Remove all non default gems. For ruby 2.0.0
#!/usr/bin/env ruby
# Remove all gems EXCEPT defaults :)
`gem list -d`.split(/\n\n^(?=\w)/).each do |data|
match = data.match(/(?<name>([^\s]+)) \((?<versions>.*)\)/)
name = match[:name]
versions = match[:versions].split(', ')
if match = data.match(/^.*\(([\d\.]*),? ?default\): .*$/)
next if match[1].empty? # it's the only version if this match is empty
@thomaslevesque
thomaslevesque / memset.cs
Last active July 6, 2021 01:48
Benchmark of memset implementations in C# using a loop or the initblk CLR instruction (run in LinqPad)
void Main()
{
var array = new byte[10000000];
var initBlk = new InitblkMemoryHelper();
var loop = new LoopMemoryHelper();
// First run for JIT warmup and type initialization
initBlk.Memset(array, 0, array.Length, 42);
loop.Memset(array, 0, array.Length, 42);
r53 = AWS::Route53.new(
:access_key_id => 'aws-key-id',
:secret_access_key => 'aws-secret-key')
response = r53.client.list_resource_record_sets(
:hosted_zone_id => "zone-id",
:start_record_name => 'xxx.example.com',
:start_record_type => 'CNAME'
)
puts response[:resource_record_sets].map{|r| r[:name]}
@antonijn
antonijn / unicode.c
Last active September 30, 2022 01:13
UTF-8 to UTF-32 converter in C
#include "unicode.h"
#include <stdint.h>
#include <stddef.h>
int is_valid_char(uint32_t ch)
{
return ch < 0xd800 || ch > 0xdfff;
}
int is_combo_char(uint32_t ch)
@ktheory
ktheory / dd.log
Last active November 10, 2023 23:41
EC2 EBS-SSD vs instance-store performance on an EBS-optimized m3.2xlarge
# /tmp/test = EBS-SSD
# /mnt/test = instance-store
root@ip-10-0-2-6:~# dd bs=1M count=256 if=/dev/zero of=/tmp/test
256+0 records in
256+0 records out
268435456 bytes (268 MB) copied, 3.26957 s, 82.1 MB/s
root@ip-10-0-2-6:~# dd bs=1M count=256 if=/dev/zero of=/tmp/test
256+0 records in
256+0 records out