Skip to content

Instantly share code, notes, and snippets.

View rodorgas's full-sized avatar
🧑‍💻
Typing…

Rodrigo Orem rodorgas

🧑‍💻
Typing…
View GitHub Profile
@rodorgas
rodorgas / validate-django-session.txt
Created February 10, 2022 23:56
Validate Django session with JavaScript or Python
# python version
import hmac, base64, hashlib
const secret = '??'
def validate_session(session_data):
try:
hash, serialized = base64.b64decode(session_data).decode('utf-8').split(':', 1)
print(serialized)
@rodorgas
rodorgas / menu-edisciplinas-razoavel.css
Last active August 16, 2021 15:57
Menu de navegação do eDisciplinas razoável
@-moz-document domain("edisciplinas.usp.br") {
.block_navigation .block_tree ul ul {
padding-left: 0;
}
.block_navigation .block_tree ul ul ul {
padding-left: 1rem;
}
.block_navigation .block_tree .tree_item.branch,
@rodorgas
rodorgas / .tmux.conf
Created October 5, 2020 22:26
my tmux config
# remap prefix from 'C-b' to 'C-x'
unbind C-b
set-option -g prefix C-x
bind-key C-x send-prefix
# ctrl-a (not the prefix, but after) to go to last window
bind-key C-a last-window
# hot conf reload
bind r source-file ~/.tmux.conf
# remap prefix from 'C-b' to 'C-x'
unbind C-b
set-option -g prefix C-x
bind-key C-x send-prefix
# ctrl-a (not the prefix, but after) to go to last window
bind-key C-a last-window
# hot conf reload
bind r source-file ~/.tmux.conf
// Toca alarme quando a fila atingir os valores abaixo:
let limites = [310000, 100000, 50000, 10000, 1000];
// Define intervalo de verificação em segundos
let intervalo = 30;
function alarm() {
var audio = new Audio('https://linux.ime.usp.br/~orem/alarme.mp3');
audio.play();
}

Programação dinâmica 2

Guardar informações na memória para não ter que fazer uma computação muitas vezes.

int fib(int i) {
    if (i == 1 || i == 0) return 1;
    return fib(i-1) + fib(i-1);
}

funções da stl

queue

push(x) no final da fila, pop(x), front(x) retorna o valor do 1o. elemento da fila, size(), empty()

queue<int> q;
q.push(1);
print(q.front());
q.pop();
@rodorgas
rodorgas / program.c
Created March 2, 2018 11:19
Prova MAC
#include <stdio.h>
#include <string.h>
const char grupos[10][5] = {"", "", "abc", "def", "ghi", "jkl",
"mno", "pqrs", "tuv", "wxyz"};
void gerarPalavra(int number[], int curr_digit, char output[], int n)
{
int i;
if (curr_digit == n)
{
@rodorgas
rodorgas / gist:1ebef07ef8135e3b81746e0a52218f2b
Created December 30, 2017 17:57
Change referer to Facebook
javascript:location.href='http://facebook.com/l.php?u='+encodeURIComponent(location.href)