Skip to content

Instantly share code, notes, and snippets.

View ranisalt's full-sized avatar

Ranieri Althoff ranisalt

View GitHub Profile
@ranisalt
ranisalt / indenter.lua
Created October 23, 2014 02:45
Lua stuff
function cleanPreviousIndentation(line)
return line:gsub("^%s+", ""):gsub("%s+$", "")
end
function escapeString(str)
return str:gsub("[()]", "%%%1")
end
function string:split(delimiter)
local array = {}
@ranisalt
ranisalt / quicksort.py
Created November 3, 2014 17:03
Quicksort funcional
def quicksort(l):
if len(l) == 0:
return l
pivot = l.pop()
return quicksort([x for x in l if x < pivot]) + [pivot] + quicksort([x for x in l if x >= pivot])
from builtins import KeyError
import string
class Steckerbrett:
def __init__(self, *args):
self.map = {}
for arg in args:
if arg[0] in self.map or arg[1] in self.map:
@ranisalt
ranisalt / automount
Last active August 29, 2015 14:16
automount usb
#!/usr/bin/bash
# /usr/local/bin/automount
label=$(blkid -o value -s LABEL $1)
if [[ "x${label}" == "x" ]]; then
label=$(blkid -o value -s UUID $1)
fi
if [[ "x${label}" != "x" ]]; then
dest="/media/${label}"
mkdir -p ${dest}
$("a").each(function(c,a){"PDF"==a.innerHTML&&$.get(a.href,function(a){$(a).find("a").each(function(a,b){"Baixar este arquivo PDF"==b.innerHTML&&window.open(b.href,null)})})});
@ranisalt
ranisalt / notas.py
Created March 22, 2015 04:38
OBI 2014 F2N2 Notas
qtd_notas = int(input())
notas = [int(nota) for nota in input().split()]
freq, top = {}, (0, 0)
for i in range(0, qtd_notas):
if notas[i] not in freq:
freq[notas[i]] = 0
freq[notas[i]] += 1
for key in freq:
@ranisalt
ranisalt / tapetes.py
Created March 22, 2015 04:57
OBI 2014 F2N2 Tapetes
compr, qtd = [int(i) for i in input().split()]
print((compr - qtd + 1) ** 2 + qtd - 1)
@ranisalt
ranisalt / blefe.py
Created March 22, 2015 06:08
OBI 2014 F2N2 Blefe
conj, seq = [int(i) for i in input().split()]
A = [int(i) for i in input().split()][:conj]
jogadas = [int(i) for i in input().split()][:seq]
B = []
for jogada in range(0, len(jogadas)):
if jogadas[jogada] in A:
B.append(jogadas[jogada])
elif len(B) == 0:
From 275f39c3faa61e59383915288de85cc90d9aca06 Mon Sep 17 00:00:00 2001
From: Ranieri Althoff <[email protected]>
Date: Sun, 19 Apr 2015 03:47:18 -0300
Subject: [PATCH 1/1] Make player walkthrough optional
---
config.lua | 1 +
src/configmanager.cpp | 1 +
src/configmanager.h | 1 +
src/player.cpp | 4 ++--
@ranisalt
ranisalt / update-ip.sh
Created April 21, 2015 03:45
Auto update IP
#!/usr/bin/env sh
sed -i "s/^\(ip\s*=\s*\)\".*\"/\1\"$(curl -s icanhazip.com)\"/" config.lua