Skip to content

Instantly share code, notes, and snippets.

@SkyWriter
SkyWriter / pbkdf2.rb
Created August 17, 2016 07:05
PBKDF2 Script to Create Safe Passwords (ugly and dirty code, just a PoC)
#!/usr/bin/env ruby
require 'openssl'
require 'pry'
def convert_base(num, base)
result = []
while num > 0
quot, rem = num / base, num % base
result.push(rem)
@SkyWriter
SkyWriter / id_rsa.pub
Last active August 16, 2016 06:40
SSH public key
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEApQ6UjmjtcNvYJ6hlSZF4ECMfgMIxUrW2AtkujL71W44vj/g3+Wd2kSmW2fa3Pgmk2fcy35pjIo/KtYIg1UpyH2gf+aGD0kHOfnfvvnEYYbYzGfkZ2rEbC8LmQEj9UEkdFtKyPUfcS8X88voKTDtFmpIzZ7kgWlQjKkmuEnL+v4TAXrcwLVqYs8Lrl7mp/BgvTZzEeDffI9T0mobzwQMt/BnPliduUOv62u2I5w0CurRDWjKrT2cqrv8JrcexiSME0wbYKe0tbPfRQNpN9X9wkemtWCX5xoIFrCNi0FiXbvaeKNdMmdGPiptMTC/Uroym1cmn4XepFyGc+1HcELtbFw== [email protected]

Keybase proof

I hereby claim:

  • I am SkyWriter on github.
  • I am skywriter (https://keybase.io/skywriter) on keybase.
  • I have a public key whose fingerprint is 52C7 EA34 4533 3F52 A899 0444 CE75 845D F2FC FDE2

To claim this, I am signing this object:

@SkyWriter
SkyWriter / execute.sh
Created July 2, 2016 06:51
Sandbox Mac OS X Application
sandbox-exec -f /tmp/sandbox /bin/sh
@SkyWriter
SkyWriter / active_json.rb
Last active January 19, 2016 04:21
Active JSON implementation based on JSON path specs, Virtus and JSONPath gem
#!/usr/bin/env ruby
# gem 'jsonpath', '~> 0.5'
# gem 'virtus', '~> 1.0'
require 'jsonpath'
require 'virtus'
module ActiveJSON
class Base
@SkyWriter
SkyWriter / simple_crypt.rb
Last active September 9, 2015 16:11
Simple OpenSSL based encryption
require 'openssl'
require 'base64'
require 'pry'
def encrypt(data, pass)
salt = OpenSSL::Random.random_bytes(16)
iter = 20000
len = 256
encryption_key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(pass, salt, iter, len)
(function () {
var root = $(document.getElementsByTagName('body'));
var watchers = [];
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
angular.forEach(element.data().$scope.$$watchers, function (watcher) {
watchers.push(watcher);
});
}
#!/bin/bash
fsWithSnapshots=$(zfs list -Hr -t snapshot tank/share |grep '@' |cut -d '@' -f 1 |uniq)
for fs in $fsWithSnapshots ; do
# Changed to now sort newest to oldest. This will mean that newer snapshots without deltas will get removed.
emptySnapshot=$(zfs list -Hr -d1 -t snapshot -o name,used -S creation $fs |sed '$d' |awk ' $2 == "0B" { print $1 }' )
for snapshot in $emptySnapshot ; do
# Added safety check. Verify the size of the snapshot prior to destroying it
#!/bin/bash
for d in `zfs list -t snapshot | grep ^tank/share@ | awk '{ print $1 }' | head -n -720`; do
zfs destroy ${d}
done
zfs snapshot tank/share@`date "+%Y-%m-%d-%T"`
@SkyWriter
SkyWriter / gist:6104447
Created July 29, 2013 13:53
TextMate sampling
Sampling process 91681 for 3 seconds with 1 millisecond of run time between samples
Sampling completed, processing symbols...
Analysis of sampling TextMate (pid 91681) every 1 millisecond
Process: TextMate [91681]
Path: /Applications/TextMate.app/Contents/MacOS/TextMate
Load Address: 0x1080a0000
Identifier: com.macromates.TextMate.preview
Version: 2.0-alpha.9443 (9443)
Code Type: X86-64 (Native)
Parent Process: launchd [244]