Skip to content

Instantly share code, notes, and snippets.

View snaewe's full-sized avatar

Stefan Naewe snaewe

  • Planet Earth (UTC+2)
View GitHub Profile
//
// GNU GPL v2
// [email protected]
// hydraraptor.blogspot.com
//
// Adapts ESP12 module to 0.1" grid.
//
eps = 1/128; // small fudge factor to stop CSG barfing on coincident faces.
layer_height = 0.25; // slicer layer height
extrusion_width = 0.5; // slicer extrusion width
@adnbr
adnbr / attiny13-adc-pwm.c
Last active June 12, 2024 10:32
ADC input directly to PWM output, on an ATtiny13.
/* ---------------------------------------------------------------------
* PWM LED Brightness control for ATtiny13.
* Datasheet for ATtiny13: http://www.atmel.com/images/doc2535.pdf
*
* Pin configuration -
* PB1/OC0B: LED output (Pin 6)
* PB2/ADC1: Potentiometer input (Pin 7)
*
* ~100 bytes.
*
@felipec
felipec / autogroups
Last active November 22, 2020 04:02
Display a list of all the processes listed by their autogroup (CONFIG_SCHED_AUTOGROUP)
#!/usr/bin/env ruby
$autogroups = Hash.new { |h,k| h[k] = [] }
Dir.glob('/proc/*').each do |e|
pid = File.basename(e).to_i
next if pid == 0
begin
cmdline = File.read(e + '/cmdline').split("\0").join(" ")
next if cmdline.empty?
@jonas
jonas / progresstinate.sh
Created October 24, 2012 15:31
Show progress spinner based on chatty commands
# Usage:
# progresstinate "Building $SERVER_WAR" \
# mvn clean install
progresstinate() {
msg="$1"; shift; args="$@"; symbol="-"
printf "$msg [$symbol]"
"$@" | while read line; do
symbol="$(echo "$symbol" | tr -- '-/|\\' '/|\\-')"
printf "\b\b$symbol]"
done
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@adnbr
adnbr / counting-millis.c
Created April 21, 2012 19:01
Counting the passing of milliseconds using Timer1 on AVR.
/* Counting Milliseconds with Timer1
* ---------------------------------
* For more information see
* http://www.adnbr.co.uk/articles/counting-milliseconds
*
* 620 bytes - ATmega168 - 16MHz
*/
// 16MHz Clock
#define F_CPU 16000000UL
@aalvarado
aalvarado / reabase-on-upstream
Created September 29, 2011 16:39
bashscript for rebasing on upstream master.
#!/bin/sh
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
current_branch=$(parse_git_branch)
if [[ -n "$current_branch" ]]; then
git fetch -v upstream
git checkout master
@lentil
lentil / gist:810399
Created February 3, 2011 22:55
PEP8 pre-commit hook in Python
#!/usr/bin/env python
from __future__ import with_statement
import os
import re
import shutil
import subprocess
import sys
import tempfile
@mausch
mausch / git-shallow-submodule.sh
Created November 18, 2010 17:10
Shallow-cloned submodules in git
#!/bin/bash
# Idea from http://stackoverflow.com/questions/2144406/git-shallow-submodules
git submodule init
for i in $(git submodule | sed -e 's/.* //'); do
spath=$(git config -f .gitmodules --get submodule.$i.path)
surl=$(git config -f .gitmodules --get submodule.$i.url)
git clone --depth 1 $surl $spath
done
git submodule update
@kennethreitz
kennethreitz / sync.py
Created October 10, 2010 19:08
GitHub Syncer. Clones or Pulls all GitHub repos (including watched list).
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Kenneth Reitz's GitHub Syncer
This script uses the GitHub API to get a list of all forked, mirrored, public, and
private repos in your GitHub account. If the repo already exists locally, it will
update it via git-pull. Otherwise, it will properly clone the repo.
It will organize your repos into the following directory structure: