Skip to content

Instantly share code, notes, and snippets.

View blackfist's full-sized avatar

Kevin Thompson blackfist

View GitHub Profile
@blackfist
blackfist / gist:6419155
Last active February 8, 2023 01:31
Professors: Stop Assigning Group Projects!

This week is the start of grad school. Since I'm also working full time I decided to take it easy and only registered for two classes. I know that is a small sample size, but I'm pretty disappointed to learn that both of the classes have a lot of group projects involved in them. And I remember from my time as an undergrad student that (almost) every professor was assigning group projects too. Ugh group projects suck! I had hoped that I would be done with group projets when I left undergrad behind. Collaborative learning: the go-to pedagogy for lazy professors when service learning isn't available for some reason.

First, a distinction

I draw a distinction between group projects and group work. To me, a group project is a larger deliverable where the intent is that students will work together over a longer period of time. Group work, on the other hand, is what I call it when you have students break into smaller groups within the class period to discuss something amongst themselves and possibly produce a sho

@blackfist
blackfist / gist:7200902
Created October 28, 2013 17:22
How to use csv.DictReader even when you're dealing with shitty data and header row names are duplicated. First you have to make an array of unique header names and tell the DictReader to use that instead of the first row of the file.
anus = reader(open('bullshit_file.csv','rU'))
fieldnames = []
# Read the first row of the csv file and put all the values into a list. Duplicates will not be overwritten.
for headername in anus.next():
if headername not in fieldnames:
fieldnames.append(headername)
else:
fieldnames.append(headername + " Other")
@blackfist
blackfist / create.json
Last active July 21, 2018 04:55
Creating VERIS incidents using python
{
"metadata": {
"name": "",
"signature": "sha256:be8501a2940fce195e5db05103c87f13e2dac07ac27e35cf5895ccad9045aace"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@blackfist
blackfist / malware.md
Last active June 4, 2018 14:02
Recommended reading for malware analysis
  1. http://computer-forensics.sans.org/blog/2010/11/12/get-started-with-malware-analysis
  2. http://zeltser.com/malware-analysis-toolkit/
  3. http://zeltser.com/vmware-malware-analysis/
  4. http://computer-forensics.sans.org/blog/2010/10/11/3-phases-malware-analysis-behavioral-code-memory-forensics/
  5. BotMiner: Clustering Analysis of Network Traffic for Protocol- and Structure-Independent Botnet Detection https://www.usenix.org/legacy/event/sec08/tech/full_papers/gu/gu.pdf
  6. Mining the Network Behavior of Bots http://isg.rhul.ac.uk/sullivan/pubs/tr/2009-12.pdf
  7. Behavioral Clustering of HTTP-Based Malware and Signature Generation Using Malicious Network Traces https://www.usenix.org/legacy/event/nsdi10/tech/full_papers/perdisci.pdf
  8. From Throw-Away Traffic to Bots: Detecting the Rise of DGA-Based Malware https://www.usenix.org/system/files/conference/usenixsecurity12/sec12-final127.pdf
  9. Obfuscation of executable code to improve resistance to static disassembly http://www.cs.arizona.edu/~debray/Pub
@blackfist
blackfist / mailgun.ex
Last active April 3, 2018 14:00
Example of using Elixir and HTTPotion to send mail to Mailgun using the api.
defmodule Mailgun do
@doc """
Sends a basic message to an address. Expects a mailgun domain environment
variable (MAILGUN_DOMIAN) and a mailgun api key environment variable
(MAILGUN_API_KEY).
"""
@spec mail(String.t) :: String.t
def mail(toAddress) do
url = "https://api.mailgun.net/v3/#{System.get_env("MAILGUN_DOMAIN")}/messages"
headers = ["User-Agent": "Elixir",
@blackfist
blackfist / painted_desert.nlogo
Created February 2, 2017 03:23
netlogo painted desert challenge
@blackfist
blackfist / termites_kevin.nlogo
Created February 2, 2017 03:21
netlogo termites picking up any color
@blackfist
blackfist / 1_explanation.md
Last active April 15, 2016 21:33
Elixir event handling -- am I failing at "let it crash?"

I have a genserver that is taking messages from a websocket and passing them to an event handler. The event handler receives a map from the genserver and takes action where appropriate. So for example, in response to a new user create event, the event handler would check if the user's email address comes from a suspicious domain, and if so, take some actions to reduce abuse.

So in event_handler.ex you can see that when a new message comes in for a user create event, I pass the message to UserHandler.handle_suspicious_domain. That function returns the same map which I pass to UserHandler.handle_suspicious_ip. But I'm not sure if that's idomatic since I'm not transforming the map, I'm just passing it from function to function.

Then you can see in user_handler.ex that I take the domain name through a set of transformations and then make a decision. Looking at line 25 you can see that I have a function that does nothing and only exists to prevent a crash. That seems wasteful and