Skip to content

Instantly share code, notes, and snippets.

@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 / 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]
#!/bin/bash
v=$1
o=$2
d=$4
loaders=('grub')
test -r /etc/default/installkernel &&
source /etc/default/installkernel
@felipec
felipec / aur-check
Last active May 5, 2021 08:08
Script to check AUR packages
#!/usr/bin/env ruby
# This script checks all your foreign packages against AUR to find newer versions
require 'net/http'
require 'json'
$packages = {}
$all = false
#!/usr/bin/env ruby
$sucrose_points = 386.5
$extract_potential = {
'2 row' => 0.79,
'crystal 10L' => 0.75,
'carapils' => 0.72,
}
@felipec
felipec / ingresos
Created August 24, 2015 19:05
Script para general ingresos correjidos del INEGI
#!/usr/bin/env ruby
$hogares = {}
open('concentradohogar.csv').each_with_index do |l,i|
next if i == 0
data = l.split(',')
viv, hog = data[0..1]
integ = data[13].tr('"', '').to_i
$hogares[[viv, hog]] = [integ, 0]
@felipec
felipec / enigma
Last active August 29, 2015 14:16
Enigma machine in Ruby
#!/usr/bin/env ruby
CHARS = ('A'..'Z')
=begin
def stringify(array)
array.map(&:join).join(' ')
end
@felipec
felipec / steam.txt
Created June 3, 2014 10:34
Steam system information
Processor Information:
Vendor: GenuineIntel
CPU Family: 0x6
CPU Model: 0x3a
CPU Stepping: 0x9
CPU Type: 0x0
Speed: 2401 Mhz
4 logical processors
2 physical processors
HyperThreading: Supported
@felipec
felipec / git-marks-check
Last active June 5, 2026 16:59
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'
@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?