Skip to content

Instantly share code, notes, and snippets.

View sasha42's full-sized avatar
☺️
Vibing

Sasha sasha42

☺️
Vibing
  • Geneva, Switzerland
View GitHub Profile
@sasha42
sasha42 / copy.sh
Created March 14, 2019 16:41
heroku copy config to env
# first install https://github.com/xavdid/heroku-config
heroku plugins:install heroku-config
# then add the following to your ~/.bashrc or ~/.zshrc
alias hc="heroku config:pull && mv .env env.sh && chmod +x env.sh && . ./env.sh"
# next you can just run hc to copy over your config
hc
#!/bin/bash
# Quick and dirty script to get IP and dl speed
# of a Pi on boot
# sleep to wait for wifi
sleep 20
# get the local IP
localip=$(/sbin/ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')
Host pi
Hostname /gsiot-t764-3eyt
Port 22
User pi
ProxyCommand /usr/local/Cellar/corkscrew/2.0/bin/corkscrew try.yaler.io 80 %h %p
#!/bin/bash
# pings 8.8.8.8 and local router, saves into log if offline with timestamp
HOSTS="8.8.8.8 192.168.1.1"
COUNT=4
for myHost in $HOSTS
do
#!/bin/bash
# saves date and average of 4 pings to 8.8.8.8 into log file
count=$(ping -c 4 8.8.8.8 | tail -1 | awk '{print $4}' | cut -d '/' -f 2)
echo "$(date) $count" > pingresponselog.txt
import time, sys, os
global pwm
from Adafruit_PWM_Servo_Driver import PWM
# Set LED parameters
pwm = PWM(0x40)
pwm.setPWMFreq(1000)
print("LEDs are initialised")
@sasha42
sasha42 / ip.sh
Created January 5, 2016 14:14
Print external+internal IP (mac)
#!/bin/bash
dig +short myip.opendns.com @resolver1.opendns.com
ifconfig en0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'
@sasha42
sasha42 / clipboard-clean.sh
Created August 30, 2015 22:58
Clear the formatting of your clipboard using a simple script placed in your (mac) dock
#!/bin/bash
# This small program cleans up the formatting of your mac clipboard
# (removes any links, coloring, font style, spacing, etc). Drag it
# into your dock and click on it whenever you want to clear some
# text's formatting. It will then close all by itself. Requires
# giving accessibility rights to terminal.
# Suggested as alias here https://news.ycombinator.com/item?id=10143852
pbpaste | pbcopy