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
defmodule GZIP do | |
def gunzip(enum) do | |
Stream.transform( | |
enum, | |
fn -> | |
z = :zlib.open | |
:zlib.inflateInit z, 16 + 15 | |
z | |
end, | |
fn compressed, z -> |
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 | |
require 'optparse' | |
require 'open3' | |
options = {} | |
parser = OptionParser.new do |opt| | |
opt.separator 'This is a wrapper over wmctrl.' | |
opt.on('-C COMMAND_NAME') do |v| |
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 | |
WIFI_INTERFACE = 'wlp2s0' | |
WIFI_NETWORK = 'fsociety5' | |
PING_ENDPOINT = '8.8.8.8' | |
OK = "#{WIFI_NETWORK.inspect} has internet! :)" | |
ERR = "#{WIFI_NETWORK.inspect} doesn't have internet :(" | |
CON_ERR = "Can't connect to #{WIFI_NETWORK.inspect}" | |
def nmcli(*args) |
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 | |
require 'pathname' | |
require 'fileutils' | |
DIR = Pathname.new('/tmp') | |
PROJECT = 'activeadmin-load-paths-bug' | |
def system!(*args) | |
system(*args) || exit(1) | |
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 | |
require 'fileutils' | |
require 'optparse' | |
require 'socket' | |
def first_available_port(host = 'localhost') | |
min_port, max_port = IO.read('/proc/sys/net/ipv4/ip_local_port_range').split.map(&:to_i) | |
port_available = proc do |port| | |
available = true |
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 | |
WIFI_IF=wlp2s0 | |
WIFI_NET=fsociety5 | |
WIFI_DEF=`nmcli -g name con show --active` | |
PING_ENDPOINT="8.8.8.8" | |
OK_MSG="Have internet! :)" | |
ERR_MSG="Have no internet :(" | |
CON_ERR_MSG="Can't connect $WIFI_NET" |
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 | |
require 'fileutils' | |
# | |
# Usage: | |
# chromium-ssh-proxy ssh-host local-port | |
BASE_DIR = '/tmp' | |
host, port, = ARGV |
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
[190674.174663] Restarting tasks ... done. | |
[190674.232124] PM: Syncing filesystems ... done. | |
[190674.241368] PM: Preparing system for sleep (freeze) | |
[190674.241516] Freezing user space processes ... | |
[190674.504228] r8169 0000:01:00.0 enp1s0: rtl_counters_cond == 1 (loop: 1000, delay: 10). | |
[190694.252367] Freezing of tasks failed after 20.009 seconds (1 tasks refusing to freeze, wq_busy=0): | |
[190694.252531] laptop_mode D ffff88009c717ce8 0 24192 23784 0x00000004 | |
[190694.252549] ffff88009c717ce8 00ff88009c717d20 ffff8800c42f0000 ffff8800a9a5c9c0 | |
[190694.252562] ffff88009c718000 ffff8800c9e24170 ffff8800c9e240b0 0000000000000000 |
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
michael@blackbox:~$/usr/bin/gem server -b 0.0.0.0 | |
Server started at http://0.0.0.0:8808 | |
192.168.20.163 - - [22/Nov/2016:14:27:32 EET] "GET /Axiom/ HTTP/1.1" 404 269 | |
- -> /Axiom/ | |
192.168.20.163 - - [22/Nov/2016:14:27:33 EET] "GET / HTTP/1.1" 200 25691 | |
- -> / | |
192.168.20.163 - - [22/Nov/2016:14:27:33 EET] "GET /gem-server-rdoc-style.css HTTP/1.1" 200 4313 | |
http://bb:8808/ -> /gem-server-rdoc-style.css | |
192.168.20.163 - - [22/Nov/2016:14:27:34 EET] "GET / HTTP/1.1" 200 25691 | |
- -> / |
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 | |
require 'net/http' | |
require 'json' | |
$token = '<pushbullet-token>' | |
$title = ARGV[0] || [`whoami`, '@', `hostname`].map(&:strip).join | |
$body = $stdin.read | |
uri = URI('https://api.pushbullet.com') |
NewerOlder