Skip to content

Instantly share code, notes, and snippets.

View thearn's full-sized avatar

Tristan Hearn thearn

  • NASA Glenn Research Center
  • Cleveland, OH
View GitHub Profile
1) Read an image from file
2) Display an image that you read from file
3) Capture Video using your webcam and display the feed
4) Display back and white live stream from your webcam.
5) Have a slider to change brightness of the webcam live stream. Display.
6) Have a slider to change contrast of the webcam live stream. Display.
7) Capture a snapshot from your webcam. Then display difference between live video stream and this snapshot. (Background subtraction)
8) Display Canny edge image from your live webcam stream
9) Have a slider to change smoothness / sharpness of image from live webcam stream.
10) Display histogram of colors (RGB) from your live webcam stream
@takeshixx
takeshixx / hb-test.py
Last active March 9, 2024 13:37
OpenSSL heartbeat PoC with STARTTLS support.
#!/usr/bin/env python2
"""
Author: takeshix <takeshix@adversec.com>
PoC code for CVE-2014-0160. Original PoC by Jared Stafford (jspenguin@jspenguin.org).
Supportes all versions of TLS and has STARTTLS support for SMTP,POP3,IMAP,FTP and XMPP.
"""
import sys,struct,socket
from argparse import ArgumentParser
@justecorruptio
justecorruptio / 2048.c
Created April 4, 2014 03:49
Tiny 2048 in C!
M[16],X=16,W,k;main(){T(system("stty cbreak")
);puts(W&1?"WIN":"LOSE");}K[]={2,3,1};s(f,d,i
,j,l,P){for(i=4;i--;)for(j=k=l=0;k<4;)j<4?P=M
[w(d,i,j++)],W|=P>>11,l*P&&(f?M[w(d,i,k)]=l<<
(l==P):0,k++),l=l?P?l-P?P:0:l:P:(f?M[w(d,i,k)
]=l:0,++k,W|=2*!l,l=0);}w(d,i,j){return d?w(d
-1,j,3-i):4*i+j;}T(i){for(i=X+rand()%X;M[i%X]
*i;i--);i?M[i%X]=2<<rand()%2:0;for(W=i=0;i<4;
)s(0,i++);for(i=X,puts("\e[2J\e[H");i--;i%4||
puts(""))printf(M[i]?"%4d|":" |",M[i]);W-2
@jakob223
jakob223 / Jakob Friend key
Created February 16, 2014 22:04
Jakob Project Euler Friend Key
32374595215431_4d851f5b4b9c77a92f8fdd01b1092fb3
@briankung
briankung / The Project Euler Sprint Rules.md
Last active December 14, 2017 02:20
The Project Euler Sprint Rules

The Project Euler Sprint Hack Nights

Project Euler Sprint Hack Nights are beginner friendly events where you can work on your own projects or engage in a friendly competition called the Project Euler Sprint.

The Project Euler Sprint is a friendly competition involving solving Project Euler ([http://projecteuler.net][projecteuler]) problems for points. Project Euler is a series of increasingly difficult computational math problems that must be solved with code (generally speaking - we've had some impressive solutions in pen and paper as well as on an Excel spreadsheet).

Each problem is harder than the last, so each problem is worth its problem number in points. Problem #1 is easy, so it's worth 1 point, while problem #50 is much harder, but worth 50 points. You can form teams of 4 people and solutions can be in any language as long as it's coded there. More detailed rules below.

Sprint Rules

@grantslatton
grantslatton / fizzbuzz.c
Last active August 19, 2022 11:20
FizzBuzz solved using only bit twiddling. It essentially uses two deterministic finite automata for divisibility testing.
#include <stdio.h>
int f0(unsigned int x) { return x? (x&(1<<31)? f1(x<<1) : f0(x<<1)) : 1; }
int f1(unsigned int x) { return x? (x&(1<<31)? f3(x<<1) : f2(x<<1)) : 0; }
int f2(unsigned int x) { return x? (x&(1<<31)? f0(x<<1) : f4(x<<1)) : 0; }
int f3(unsigned int x) { return x? (x&(1<<31)? f2(x<<1) : f1(x<<1)) : 0; }
int f4(unsigned int x) { return x? (x&(1<<31)? f4(x<<1) : f3(x<<1)) : 0; }
int t0(unsigned int x) { return x? (x&(1<<31)? t1(x<<1) : t0(x<<1)) : 1; }
int t1(unsigned int x) { return x? (x&(1<<31)? t0(x<<1) : t2(x<<1)) : 0; }
int t2(unsigned int x) { return x? (x&(1<<31)? t2(x<<1) : t1(x<<1)) : 0; }
@chackley
chackley / Vaccine-Autism Evidence
Created April 26, 2013 17:05
List of scientific articles regarding the hypothesis that vaccines are related to incidence of autism in children.
Lancet. 2004 Sep 11-17;364(9438):963-9. MMR vaccination and pervasive developmental disorders: a case-control study. PMID 15364187
294 cases and 4469 controls were included. 1010 cases (78.1%) had MMR vaccination recorded before diagnosis, compared with 3671 controls (82.1%) before the age at which their matched case was diagnosed. After adjustment for age at joining the database, the odds ratio for association between MMR and pervasive developmental disorder was 0.86 (95% CI 0.68-1.09). Our findings suggest that MMR vaccination is not associated with an increased risk of pervasive developmental disorders.
Odds ratio below 1 suggests decreased, not increased, risk of autism with vaccine. CI crosses 1 so the effect of vaccine preventing autism is non-significant.
N Engl J Med. 2002 Nov 7;347(19):1477-82. A population-based study of measles, mumps, and rubella vaccination and autism. PMID 12421889
Of the 537,303 children in the cohort (representing 2,129,864 person-years), 440,655 (82.0 percent) had received t
@thearn
thearn / ip.py
Last active December 16, 2015 11:59
A python code to determine a computer's external IP address, which is then written to a text file. Run from a dropbox folder (or something similar), this provides a very simple way to determine your home's dynamic external IP address remotely.
import urllib
import re
import time
import datetime
def get_ip():
group = re.compile(u'(?P<ip>\d+\.\d+\.\d+\.\d+)').search(
urllib.URLopener().open('http://jsonip.com/').read()).groupdict()
return group['ip']
@thearn
thearn / fft_series.py
Last active December 16, 2015 11:49
Class for buffering an incoming data series and computing an FFT
import numpy as np
import time
class bandProcess(object):
"""
Component to isolate specific frequency bands
"""
@thearn
thearn / brew.py
Last active December 16, 2015 10:59
A simple command-line app to help profile homebrew'ed beer. User inputs starting temperature, starting original gravity, and the app will compute and print temperature-adjusted original gravity and max potential ABV. Final (post-fermentation) temperature and specific-gravity can also be input to calculate effective ABV, calories per serving, and…
def adjust(t, og):
t2 = 1.34722124e-4 * t
t3 = 2.04052596e-6 * t ** 2
t4 = 2.32820948e-9 * t ** 3
sgcf = 1.00130346 - t2 + t3 - t4
sg = og * sgcf
adjusted_og = sg
OE = -668.962 + 1262.45 * sg - 776.43 * sg * sg + 182.94 * sg * sg * sg
abv_max = (sg - 1) * 105 * 1.25