This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://events.ccc.de/congress/2011/Fahrplan/attachments/2007_28C3_Effective_DoS_on_web_application_platforms.pdf | |
import random | |
# djbx31a backward | |
def rev(h, s): | |
for c in reversed(s): | |
h = ((h - ord(c)) * 3186588639) & 0xffffffff; | |
return h |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Digraph: | |
def __init__(self): | |
self.d = {} | |
def has(self, x, y): | |
return x in self.d and y in self.d[x] | |
def _safe_get(self, x): | |
return self.d.setdefault(x, set()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using Age = unsigned int; | |
using Name = std::string; | |
using Country = std::string; | |
template <class PersonSubtype> | |
class Person | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#define STRONG_TYPEDEF(original, newtype) \ | |
class newtype : public original \ | |
{ \ | |
using original::original; \ | |
}; | |
using Age = unsigned int; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gets list of key walls from a sorted list of walls | |
def _keywalls(walls): | |
prevheight = pos = highest = 0 | |
keywalls = [] | |
for pos, height in walls: | |
if height > highest: # raises globally | |
highest = height | |
elif height >= prevheight: # raises locally | |
while keywalls[-1][1] < height: | |
keywalls.pop() # discard recent walls until we see with one higher than height (always occurs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::cmp; | |
// Note: this is a suboptimal solution made to exercise the Rust language. | |
// Approach A: using a struct/class | |
// Gotcha: Had to add lifetime specifier to store a reference to the byte array of a external | |
// string inside my struct. | |
struct Rnaa<'a> { | |
chain: &'a [u8], // 'a is to get rid of "missing lifetype specifier" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Download na busca do legendas.tv | |
// @namespace http://tampermonkey.net/ | |
// @version 0.4 | |
// @description Permite download de legendas a partir dos resultados de busca do site legendas.tv | |
// @author Pedro Pedruzzi | |
// @match http://legendas.tv/busca/* | |
// @match https://legendas.tv/busca/* | |
// @grant none | |
// @downloadURL https://gist.githubusercontent.com/pedropedruzzi/f25a010f8a787352575d8f312433979b/raw/download-na-busca-do-legendas-tv.user.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def solve(a): | |
n = len(a) | |
# get inside the loop by moving n steps (better approach is part 1 of Floyds's below) | |
x = 0 | |
for i in range(n): | |
x = a[x] | |
# measure the period | |
period = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package algorithms; | |
import java.util.Arrays; | |
import java.util.LinkedList; | |
import java.util.Random; | |
public class QuickSort { | |
private static class Interval { | |
int low; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name MiBACT Antenati direct image links on galleries | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Replaces links on image galleries with direct (faster) image links | |
// @author Pedro Pedruzzi | |
// @match http://dl.antenati.san.beniculturali.it/v/* | |
// @grant none | |
// @downloadURL https://gist.github.com/pedrox/365fd278393b651a9e6780e7866c469d/raw/MiBACT-Antenati-direct-image-links.user.js | |
// ==/UserScript== |
OlderNewer