Skip to content

Instantly share code, notes, and snippets.

@felipec
felipec / parseopt.rb
Last active May 26, 2021 20:29
Simple option parser
# This is now a gem
# https://rubygems.org/gems/parseopt
class ParseOpt
class Option
attr_reader :short, :long, :help
def initialize(short, long, help, &block)
@block = block
@short = short
@felipec
felipec / asus_fan.c
Created August 6, 2013 21:51
ASUS fan control
/*
*
* obj-m := fan.o
* KDIR := /lib/modules/$(shell uname -r)/build
* PWD := $(shell pwd)
*
* all:
* $(MAKE) -C $(KDIR) M=$(PWD) modules
*
* clean:
@felipec
felipec / branch-point
Created May 30, 2012 16:54
Code to find the first point a git branch started to diverge
#!/bin/bash
# actual code
find_merge ()
{
local selection extra
test "$2" && extra=" into $2"
git rev-list --min-parents=2 --grep="Merge branch '$1'$extra" --topo-order ${3:---all} | tail -1
}
@felipec
felipec / build.rb
Created November 11, 2011 03:10
git rebase challenge build helper
#!/usr/bin/env ruby
@authors = {
"david" => "David S. Miller",
"ingo" => "Ingo Molnar",
"takashi" => "Takashi Iwai",
"alexander" => "Al Viro",
"russel" => "Russell King",
"paul" => "Paul Mundt",
"tejun" => "Tejun Heo",
@felipec
felipec / gnome-survey.txt
Created August 5, 2011 18:23
GNOME user survey
GNOME user survey 2012
Welcome to the second GNOME user survey. This survey is not blessed by the GNOME team, it's built by users (and some developers as well).
This survey is anonymous, but all information that the users provide (raw data) will be publicly available to allow for independent analysis.
Note that you may skip questions as you like, but it should only take a few minutes to fill it completely.
In order to increase the validity of this survey, please ask people that normally wouldn't answer this survey to do so, also, if you know of somebody that doesn't have access, print it or make them available for them, and fill it online on their behalf. Also, if you know of somebody that couldn't possibly have access to this survey, please let us know, it's extremely important to know what kind of people can't be reached.
#!/usr/bin/env ruby
$TEST_PERIOD = 60 * 61
$SAMPLE_PERIOD = 60 * 10
$CAPACITY = 1320
$RS = 20
class Array
def mean
self.inject(0) { |sum, x| sum + x } / size.to_f
#!/bin/sh
RS=20
get_capacity()
{
c=`i2cget -y 2 0x55 0x0c w`
return $(($c * 3570 / $RS / 1000))
}
sb="/opt/scratchbox"
user="$USER"
sb_home="$sb/users/$user/home/$user"
sb_url="http://www.scratchbox.org/download/files/sbox-releases/apophis/tarball"
sb_base_dir=$(dirname $sb)
function setup_target()
{
#!/bin/sh
download_dir=/tmp/sb
sb_base_url=http://scratchbox.org/download/files/sbox-releases/apophis/tarball
sb=/opt/scratchbox
target=armv7
sb_base_dir=$(dirname $sb)
mkdir -p $download_dir
@felipec
felipec / task.c
Created September 28, 2008 20:01
continuation task test
#ifndef TRANS_H
#define TRANS_H
#include <ucontext.h>
#include <stdbool.h>
#include <stdio.h>
struct task
{