Skip to content

Instantly share code, notes, and snippets.

View cjhanks's full-sized avatar
🔥

zeekoni cjhanks

🔥
View GitHub Profile
@cjhanks
cjhanks / remove_if.cpp
Created July 6, 2016 22:37
Example Remove IF
// vim: ts=2 sw=2 et
#include <cassert>
#include <algorithm>
#include <vector>
#include <iostream>
template <typename Container, typename Predicate>
void
RemoveIf(Container& container, Predicate predicate)
@cjhanks
cjhanks / threadsafe_bitset.hpp
Created July 4, 2016 18:09
Simple Dynamic threadsafe bitset
// vim: ts=2 sw=2 et
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <atomic>
#include <vector>
namespace bits {
template <typename Storage, bool Atomic>
@cjhanks
cjhanks / quadkey_py3.py
Created April 7, 2016 23:23
Python3 QuadKey/Tiling
from math import (
pi,
cos,
sin,
log,
atan,
exp
)
@cjhanks
cjhanks / mpdownload.py
Created February 11, 2016 23:38
Example mp download boto
#!/usr/bin/env python
from boto import connect_s3
from argparse import ArgumentParser
from tempfile import TemporaryFile
from shutil import copyfileobj
from ssl import SSLError
from socket import error as SocketError
@cjhanks
cjhanks / disassembly
Created January 23, 2016 00:01
ExampleGO
package main
func main() {
for i:= 0; i < 1000000; i++ {
400c00: 48 31 c0 xor %rax,%rax
400c03: 48 3d 40 42 0f 00 cmp $0xf4240,%rax
400c09: 7d 0b jge 400c16 <main.main+0x16>
400c0b: 48 ff c0 inc %rax
400c0e: 48 3d 40 42 0f 00 cmp $0xf4240,%rax
400c14: 7c f5 jl 400c0b <main.main+0xb>
@cjhanks
cjhanks / disassembly
Created January 22, 2016 23:50
Decompiled
a.out: file format elf64-x86-64
Disassembly of section .init:
00000000004003a8 <_init>:
4003a8: 48 83 ec 08 sub $0x8,%rsp
4003ac: 48 8b 05 45 0c 20 00 mov 0x200c45(%rip),%rax # 600ff8 <_DYNAMIC+0x1d0>
4003b3: 48 85 c0 test %rax,%rax
@cjhanks
cjhanks / troll.cpp
Created January 21, 2016 20:35
I can trull
#include <cmath>
#include <algorithm>
#include <iostream>
#include <tuple>
#include <vector>
int
main()
{
using namespace std;
@cjhanks
cjhanks / ratelimit.sh
Created December 28, 2015 16:51
TC Rate limiting
#!/bin/bash
# vim: ts=2 sw=2 et ai tw=80
################################################################################
# Script designed to shape system bandwidth usage based on the very fine
# reference found https://www.iplocation.net/traffic-control
################################################################################
set -e
# -- CONSTANTS
TC=/sbin/tc
@cjhanks
cjhanks / 2008-1a.py
Last active December 12, 2015 13:12
CodeJam Stuff
from sys import stdin
def compute(A, B):
A.sort(reverse=True)
B.sort(reverse=False)
return sum(i * j for i, j in zip(A, B))
test_cases = int(next(stdin))
for case in range(test_cases):
_ = next(stdin)
@cjhanks
cjhanks / ExitHandler.cpp
Created December 10, 2015 12:04
on_exit Handler
#include "ExitHandler.hpp"
#include <cstdlib>
#include <vector>
namespace ExitHandler {
namespace {
std::vector<AtExitFunctor> Functors;