Skip to content

Instantly share code, notes, and snippets.

View alangarf's full-sized avatar
💭
What's this button d... 💥

Alan Garfield alangarf

💭
What's this button d... 💥
View GitHub Profile
@alangarf
alangarf / flipflop.py
Last active May 1, 2021 23:04
Migen flipflop test
"""
Flip Flop
"""
from random import randrange
from migen.fhdl.module import Module
from migen.fhdl.structure import Signal
from migen.fhdl import verilog
from migen import run_simulation
@alangarf
alangarf / keybase.md
Created March 20, 2018 01:19
Keybase proof

Keybase proof

I hereby claim:

  • I am alangarf on github.
  • I am alangarf (https://keybase.io/alangarf) on keybase.
  • I have a public key ASCUneDEm8yIbtpClAgmd8Lk1mSuGPtXeMzTNz9SgU104wo

To claim this, I am signing this object:

@alangarf
alangarf / m68k issue with exceptions
Last active April 19, 2017 06:37
m68k exception nuts
Silly issue with m68k never going into exception functions.
@alangarf
alangarf / ssh_to
Created July 7, 2016 05:02
SSHs to an AWS instance with an ASG hostname
#!/bin/bash
IFS=$'\n'
unsorted_hosts=($(aws ec2 describe-instances --query "Reservations[].Instances[].{Name:Tags[?Key=='Name'].Value|[0]}" --output text --filters "Name=tag:Name,Values=*$1*"))
hosts=($(sort -V <<<"${unsorted_hosts[*]}"))
unset IFS
len=$(expr ${#hosts[@]} - 1)
for i in $(seq 0 $len); do
id=$(expr $i + 1)
@alangarf
alangarf / restart_minions.sh
Created January 15, 2016 04:02
Shell script to restart all the salt minions on instances in the same VPC and AZ as this master running the script
#!/bin/bash
eth0_mac=$(curl -s http://169.254.169.254/latest/meta-data/mac)
eth0_ip=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4/)
vpc_id=$(curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/$eth0_mac/vpc-id)
az=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone/)
region=${az::-1}
instances=$(aws --region $region ec2 describe-instances --filters "Name=vpc-id,Values=$vpc_id" "Name=availability-zone,Values=$az" --query 'Reservations[*].Instances[*].PrivateIpAddress' --output=text)
@alangarf
alangarf / spi-dlg2416.v
Created October 8, 2014 20:42
Verilog state machine to create an SPI interface to a DLG2416 display using a CPLD
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Engineer: Alan Garfield <alan@fromorbit.com>
//
// Create Date: 14:26:42 02/20/2011
// Design Name: DLG2416 to SPI
// Module Name: spidlg
// Project Name:
// Target Devices: XC9536
// Description: Creates an SPI interface to the 8bit DLG2416 display
@alangarf
alangarf / gist:48b1b65d27a6fbafb03c
Last active August 29, 2015 14:06
Getting the disk prefix of the volumes in AWS. sda vs xvda
disk_prefix=`lsblk | grep -e "disk /$" | cut -c -3`
@alangarf
alangarf / gist:3aa7bb470af6bf20547c
Created September 15, 2014 00:23
Curses Widgits
import curses
class WidgitWrapper(object):
"""
A widgit wrapper class to handle the framing of the widgit
"""
def __init__(self, win, y, x, height, width):
self.parent_win = win
self.y_pos = y
@alangarf
alangarf / gist:f51f72fab03543f758a3
Created July 28, 2014 01:11
SQS ElasticMQ connection with boto
import boto.sqs.regioninfo
import boto
region = boto.sqs.regioninfo.RegionInfo(name='elasticmq', endpoint='localhost')
conn = boto.connect_sqs(aws_access_key_id="x", aws_secret_access_key="x", region=region, is_secure=False, port=9324)
conn.get_all_queues()