Skip to content

Instantly share code, notes, and snippets.

# Double
book = double("book")
allow(book).to receive(:pages)
book.pages # => nil
expect(book).to have_received(:pages)
book.foo # exception
book = double("book")
expect(book).to receive(:pages) # will not raise an error if we call book.pages
@allegrem
allegrem / ameno.py
Created December 17, 2015 18:49
Ameno Button
import pygame
from scapy.all import *
pygame.mixer.init()
pygame.mixer.music.load("ameno.wav")
playing = False
# while pygame.mixer.music.get_busy() == True:
# continue
def arp_display(pkt):
@allegrem
allegrem / gist:8f1736ed2966d4596779
Created January 6, 2015 20:31
homemade dyndns
#!/bin/bash
# this one mails you the ip if it changes
T1=`curl -s icanhazip.com`
touch old_ip.dat
read T2 < old_ip.dat
if [ "$T1" = "$T2" ]; then
echo "`date` -- ipchange script -- IP is the same: $T1 - doing nothing " | tee -a /var/log/syslog
@allegrem
allegrem / connect-pi.sh
Last active April 17, 2018 04:42
A little script which retrieves the MAC and IP addresses of the first active Raspberry Pi on the local network, and then connects to it through SSH.
#!/bin/bash
#Get the IP address of the Raspberry Pi and connect to it through SSH.
echo "*************** CONNECT-PI ***************"
echo "* /!\ You must reboot the Raspberry Pi *"
echo "* now in order to make this script work. *"
echo "******************************************"
echo
echo -n "Getting MAC address... "