This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ArrayUtils | |
def self.flatten(array) | |
array.inject([]) { |accu, elem| | |
if elem.kind_of?(Array) | |
accu.concat(flatten(elem)) | |
else | |
accu << elem | |
end | |
} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# sed 's/https:\/\/www.twitter.com\///' -i ~/Downloads/twitter_accounts.csv | |
require "csv" | |
require "English" | |
require "logger" | |
require "pathname" | |
require "set" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "English" | |
require "logger" | |
require "pathname" | |
# kill me with kill -INT PID | |
script_path = Pathname(__FILE__) | |
pid_file = script_path.sub_ext(".pid") | |
pid_file.write(String(Process.pid)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import cycle, chain, islice, repeat | |
fizzes = cycle(chain(islice(repeat(''), 2), ('fizz' for _ in range(1)))) | |
buzzes = cycle(chain(islice(repeat(''), 4), ('buzz' for _ in range(1)))) | |
fizzes_buzzes = zip(range(1, 101), fizzes, buzzes) | |
fizz_buzz = (str(i) if not(fizz) and not(buzz) else f'{fizz}{buzz}' for i, fizz, buzz in fizzes_buzzes) | |
for line in fizz_buzz: | |
print(line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::iter::{once, repeat}; | |
fn main() { | |
let fizzes = repeat("").take(2).chain(once("fizz")).cycle(); | |
let buzzes = repeat("").take(4).chain(once("buzz")).cycle(); | |
let fizzes_buzzes = fizzes.zip(buzzes); | |
let fizz_buzz = (1..=100).zip(fizzes_buzzes).map(|tuple| match tuple { | |
(i, ("", "")) => i.to_string(), | |
(_, (fizz, buzz)) => format!("{}{}", fizz, buzz), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Requires: imagemagick | |
Usage: convert.py [DIR] (defaults to ~/Pictures) | |
""" | |
from concurrent import futures | |
import fnmatch | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# USAGE: ssh REMOTE_HOST "~/bin/whitelist-ip-4-squid ROSALES $(public-ip)" | |
SQUID_CONFIG=/etc/squid/squid.conf | |
LABEL="$1" | |
NEW_IP="$2" | |
# echo "LABEL: $LABEL, NEW IP: $NEW_IP" | |
# find out the previous IP associated with LABEL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
********************* | |
Streaming Replication | |
********************* | |
++++++ | |
Master | |
++++++ | |
postgresql.conf | |
--------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# RBENV_VERSION=jruby-9.1.16.0 JRUBY_OPTS="--server -J-Xms2048m -J-Xmx2048m" N=12 ./dict-gen -o ~/Downloads/dicts | |
require "optparse" | |
require "fileutils" | |
require "unique_permutation" | |
SYMBOLS = ("A".."Z").to_a.freeze | |
N = Integer(ENV.fetch("N", 12)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This class provides a collection of class methods to manipulate Arrays | |
class ArrayUtils | |
class << self | |
# Recursively flattens its arbitrarily nested array arguement | |
# Warning: passing in very big arrays WILL BLOW UP THE STACK! | |
def flatten(arr) | |
_flatten(arr, []) | |
end | |
private |
NewerOlder