Skip to content

Instantly share code, notes, and snippets.

@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 / 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
{
@felipec
felipec / git-marks-check
Last active September 8, 2016 02:32
Tool to check and fix git-remote-hg marks
#!/usr/bin/env ruby
require 'json'
$fix = false
$verbose = false
$git_marks = {}
$r_marks = {}
$note_marks = {}
$mode = 'hg'
#!/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
#!/bin/bash
v=$1
o=$2
d=$4
loaders=('grub')
test -r /etc/default/installkernel &&
source /etc/default/installkernel
@felipec
felipec / scanl.rb
Created January 12, 2018 01:21
Simple scanl implementation
class Array
def scanl(init)
self.reduce([init]) { |a, e| a.push(yield(a.last, e)) }
end
end
accum = [5, 10, 15].scanl(0) { |a, b| a + b }[1..-1]
@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 / grhg-walk-test
Created June 20, 2019 19:47
Script to test different git-remote-hg revision walking algorithms
#!/usr/bin/env python2
from mercurial import hg, ui, dagop, smartset
import sys, time
class Marks:
def __init__(self):
self.marks = None
@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 / 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?