Skip to content

Instantly share code, notes, and snippets.

@MichalPekala
MichalPekala / usbarmory-network.sh
Last active August 31, 2017 13:35
USB armory network sharing on macOS
# enable IP forwarding
sudo sysctl -w net.inet.ip.forwarding=1
# enable PF firewall
sudo pfctl -e
# Option 1: add NAT rule after en4 is up (USB armory already plugged and started)
echo "nat on en0 from en4:network to any -> (en0)" | sudo pfctl -f -
# Option 2: add NAT rule before USB armory is plugged, requires specifying its network
@MichalPekala
MichalPekala / Vagrantfile
Last active April 12, 2016 14:08
Swift Vagrant file
Vagrant.configure(2) do |config|
config.vm.box = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.hostname = "swift-developer"
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get install clang-3.6 libicu-dev -y
mkdir /opt/swift/
SWIFT_VERSION="2.2-RELEASE"
@MichalPekala
MichalPekala / swift-install.sh
Last active October 2, 2017 09:51
Swift install script
#!/bin/bash
sudo apt-get install clang libicu-dev
SWIFT_VERSION="4.0-RELEASE"
SWIFT_PLATFORM="ubuntu16.04"
wget https://swift.org/builds/swift-$(echo "$SWIFT_VERSION" | tr '[:upper:]' '[:lower:]' )/$(echo "$SWIFT_PLATFORM" | tr -d .)/swift-$SWIFT_VERSION/swift-$SWIFT_VERSION-$SWIFT_PLATFORM.tar.gz
wget https://swift.org/builds/swift-$(echo "$SWIFT_VERSION" | tr '[:upper:]' '[:lower:]' )/$(echo "$SWIFT_PLATFORM" | tr -d .)/swift-$SWIFT_VERSION/swift-$SWIFT_VERSION-$SWIFT_PLATFORM.tar.gz.sig
wget -q -O - https://swift.org/keys/all-keys.asc | gpg --import -
@MichalPekala
MichalPekala / blink.rb
Created March 24, 2013 22:48
Raspberry Pi + Ruby (WiringPi) + LED
@MichalPekala
MichalPekala / HelloWorldLCD.c
Created March 20, 2013 00:10
Raspberry Pi + LCD
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <wiringPi.h>
#include <lcd.h>
@MichalPekala
MichalPekala / wifi-network-monitor.sh
Created February 28, 2013 23:45
Raspberry Pi WiFi Network Monitor
#!/bin/bash
while true ; do
if ifconfig wlan0 | grep -q "inet addr:" ; then
sleep 60
else
echo "WiFi network connection down! Attempting reconnection."
ifup --force wlan0
sleep 10
fi
@MichalPekala
MichalPekala / .bash_profile
Last active May 17, 2017 21:45
Raspberry Pi .bash_profile
#!/bin/bash
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`
# get the load averages
read one five fifteen rest < /proc/loadavg
@MichalPekala
MichalPekala / proxy.ru
Created September 27, 2012 12:24
Rack Proxy with HTTP Basic Authentication
require 'rubygems'
require 'rack/streaming_proxy'
use Rack::Auth::Basic, "Restricted Area" do |username, password|
[username, password] == ['user', 'password']
end
use Rack::StreamingProxy do |request|
if request.path.start_with?("/proxy")
"http://other.host#{request.path}"