Skip to content

Instantly share code, notes, and snippets.

View jneufeld's full-sized avatar

jon jneufeld

  • Canada
View GitHub Profile
@jneufeld
jneufeld / fix_github_https_repo.sh
Created November 28, 2022 02:12 — forked from m14t/fix_github_https_repo.sh
Convert HTTPS github clones to use SSH
#/bin/bash
#-- Script to automate https://help.github.com/articles/why-is-git-always-asking-for-my-password
REPO_URL=`git remote -v | grep -m1 '^origin' | sed -Ene's#.*(https://[^[:space:]]*).*#\1#p'`
if [ -z "$REPO_URL" ]; then
echo "-- ERROR: Could not identify Repo url."
echo " It is possible this repo is already using SSH instead of HTTPS."
exit
fi
@jneufeld
jneufeld / gist:2840882
Created May 31, 2012 04:03
secret project code ;)
#!/usr/bin/python2
import time
from collections import deque
TIME_QUEUE_LENGTH = 5
HIGH_ACTIVITY_THRESHOLD = 2
def calc_rolling_avg(queue):
"""
@SuppressWarnings({ "unchecked" })
public PostSet getAllPosts(){
PostSet postSet= new PostSet();
PersistenceManager pm = getPersistenceManager();
Query q = pm.newQuery(Post.class);
try{
List<Post> posts = (List<Post>)q.execute();
for(Post p : posts){
@jneufeld
jneufeld / overwrite-ra2.c
Created February 29, 2012 04:58
Practice program for overwriting return address
#include <stdio.h>
void function (int a, int b, int c)
{
char buffer1[5];
char buffer2[10];
int *ret;
ret = buffer1 + 24;
(*ret) += 7;
@jneufeld
jneufeld / overwrite-ra.c
Created February 29, 2012 04:34
Practice program for overwriting return address
#include <stdio.h>
void function (int a, int b, int c)
{
char buffer1[5];
char buffer2[10];
//int *ret;
//ret = buffer1 + ?;
//(*ret) += ?;
@jneufeld
jneufeld / gist:1917856
Created February 26, 2012 17:26
gcc memory allocation in x86_64
sub $0x60,%rsp
lea -0x4(%rbp),%rdx
lea -0x60(%rbp),%rcx
@jneufeld
jneufeld / stack4-stdin.c
Created February 26, 2012 17:16
Tricky buffer overflow practice problem
#include <stdio.h>
int main() {
int cookie;
char buf[80];
printf("buf: %08x cookie: %08x\n", &buf, &cookie);
gets(buf);
if (cookie == 0x000d0a00)
printf("you win!\n");
@jneufeld
jneufeld / stack1-stdin.c
Created February 26, 2012 16:52
Tiny buffer overflow practice program
#include <stdio.h>
int main() {
int cookie;
char buf[80];
printf("buf: %08x cookie: %08x\n", &buf, &cookie);
gets(buf);
if (cookie == 0x41424344)
printf("you win!\n");
@jneufeld
jneufeld / results.txt
Created December 29, 2011 00:31
Small results set of testing Nehalem's L1 cache
=== test2 ===
No Filler:
N % misses time
1000000 0.55 0.329
1000000 0.55 0.329
1000000 0.54 0.331
1000000 0.45 0.353
1000000 0.55 0.330
1000000 0.52 0.334
1000000 0.55 0.330
@jneufeld
jneufeld / test2.c
Created December 29, 2011 00:27
Exploiting Nehalem's L1 data cache bandwidth with test variables
// This program exploits Nehalem's L2 data cache bandwidth of 64 bytes by using
// two threads to increment a test variable, allocating memory in both a single
// 64 byte slice and in two separate slices. To ensure 8 byte variables, long
// int is used for test variables. Changing the filler length from 56 to 48
// bytes places both test variables in the same 64 byte slice and testing
// confirms the 64 byte bandwidth of the L1 data cache (via increased cache
// misses).
//
// When run without the filler, the test variables are in the same 64 byte slice
// and performance suffers in both cache misses and running time. With the