Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / repeat_testing.pl
Created June 17, 2012 18:33
Basic illustration of repeat testing of significance error in Perl
#!/usr/bin/perl
use strict;
use warnings;
use Statistics::Gtest;
use Statistics::Distributions;
use Data::Dumper;
#
# Just set up some basics
@mackstann
mackstann / gist:4229933
Created December 7, 2012 01:16
Gigantic recursive directory lister
// http://www.olark.com/spw/2011/08/you-can-list-a-directory-with-8-million-files-but-not-with-ls/
#define _GNU_SOURCE
#include <dirent.h> /* Defines DT_* constants */
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/syscall.h>
@EmbeddedAndroid
EmbeddedAndroid / gist:54d6a7f8a8f13e8fdf71
Last active July 13, 2018 08:07
nv-uboot on Chromebook2
1) Enter Developer Mode
Disclaimer. I will take no responsibility if you somehow brick your chrome book. You should only attempt the following if you are familiar with embedded system hackery :)
With the laptop turned off, hold down the escape and refresh keys, then press the power key
The device is now in Recovery Mode, pressing Ctrl-D will enable Developer Mode.
Confirm the action by pressing Enter.
@justenwalker
justenwalker / README.md
Created August 30, 2014 18:03
Ansible Dynamic Inventory script for etcd

etcd dynamic inventory script

Generarates inventory for ansible from etcd using python-etcd library.

The script assumes etcd.ini to be present alongside it. To choose a different path, set the ETCD_INI_PATH environment variable:

export ETCD_INI_PATH=/path/to/etcd.ini
@adoc
adoc / migrate.py
Created March 18, 2015 09:42
SQLAlchemy Migration Tool
#!/usr/bin/env python
"""
# Original Author: Tyler Lesmann
# Original Source: http://www.tylerlesmann.com/2009/apr/27/copying-databases-across-platforms-sqlalchemy/
# TODO: Look at https://gist.github.com/thoas/1589496 if any
# "sequencing" issues come in to play.
@devynspencer
devynspencer / freeipa.py
Last active April 23, 2024 20:53
Use FreeIPA hostgroups as a dynamic inventory source for Ansible. Badass.
#!/usr/bin/env python
import argparse
import json
from ipalib import api
def initialize():
'''
This function initializes the FreeIPA/IPA API. This function requires
@SeeJayDee
SeeJayDee / tiny_IRremote.cpp
Last active June 24, 2024 03:36
tiny_IRremote - Arduino IRremote ported to the ATtiny
/*
* tiny_IRremote
* Version 0.2 July, 2016
* Christian D'Abrera
* Fixed what was originally rather broken code from http://www.gammon.com.au/Arduino/
* ...itself based on work by Ken Shirriff.
*
* This code was tested for both sending and receiving IR on an ATtiny85 DIP-8 chip.
* IMPORTANT: IRsend only works from PB4 ("pin 4" according to Arduino). You will need to
* determine which physical pin this corresponds to for your chip, and connect your transmitter
@samueljon
samueljon / toggleHT.sh
Last active May 31, 2024 09:51
Disable / Enable HyperThreading cores on runtime - linux
#!/bin/bash
HYPERTHREADING=1
function toggleHyperThreading() {
for CPU in /sys/devices/system/cpu/cpu[0-9]*; do
CPUID=`basename $CPU | cut -b4-`
echo -en "CPU: $CPUID\t"
[ -e $CPU/online ] && echo "1" > $CPU/online
THREAD1=`cat $CPU/topology/thread_siblings_list | cut -f1 -d,`
@rbarzic
rbarzic / gist:809f3426dc65c82ae928cd5c325844a1
Created October 21, 2016 09:27
Python Xml to Dict & Dict to XML
#!/usr/bin/env python
from xml.etree import ElementTree as ET
import pprint as pp
import argparse
from collections import defaultdict
# From http://stackoverflow.com/questions/2148119/how-to-convert-an-xml-string-to-a-dictionary-in-python/10077069#10077069
def etree_to_dict(t):
d = {t.tag: {} if t.attrib else None}
@TheMatt2
TheMatt2 / pathtype.py
Last active October 6, 2023 04:25
Python PathType helper type for input validation in argparse for paths.
"""
PathType
A helper type for input validation in argparse for paths.
This provides a convienent way to check the paths type, existance, and
potentially use "-" to reference stdin or stdout.
This class is provided as an alternative to argparse.FileType(), which
does not open the path, only validates it and supports directories.