Skip to content

Instantly share code, notes, and snippets.

@axelmagn
axelmagn / gist:dc92a8b59cf8ad67bef65841446022c7
Created January 12, 2017 14:48
Word replacement rules for Trump->Voldemort
{
"version": "2.0.10",
"replacements": [
{
"active": true,
"case": "Maintain",
"repA": "/\\b((President)\\s*(Elect)?|Mr\\.)\\s*(Donald\\s*(John|J\\.|J)?)?\\s*Trump\\b/i",
"repB": "Lord Voldemort",
"type": "RegEx"
},
@axelmagn
axelmagn / runscript.sh
Created May 21, 2014 20:31
Java Runscript Template
#!/bin/bash
PROJECT_DIR="$( cd "$( dirname "$(readlink -f "$0")" )" && pwd )"
# or to get one directory up (if runscript is on a bin/ folder)
# PROJECT_DIR="$( cd "$( dirname "$(readlink -f "$0")" )/.." && pwd )"
java -jar $PROJECT_DIR/target/XXXX.jar "$@"
extern crate rand;
use std::f64;
use std::iter::range_step_inclusive;
use std::io;
use std::num;
use rand::{task_rng,Rng};
static G : [int, ..9] = [247570,280596,280600,249748,18578,18577,231184,16,16];
struct Vector3 {
@axelmagn
axelmagn / lock.sh
Created February 22, 2014 04:43
Run i3lock with the screen obfuscated as a background. Requires ImageMagick
import -window root $HOME/.i3lockbg
convert -scale 10% 1000% $HOME/.i3lockbg $HOME/.i3lockbg
i3lock -i $HOME/.i3lockbg
@axelmagn
axelmagn / prime_factor.py
Created March 19, 2013 04:33
find largest prime factor of a number
def largest_prime_factor(num):
i = 2
largest_pfactor = 0
while i <= num:
if num % i == 0:
largest_pfactor = i
num /= i
else:
i += 1
@axelmagn
axelmagn / .bashrc
Created March 6, 2013 21:55
bashrc coloration + git line
# with git line
set_prompt() {
local OPEN="\[";
local CLOSE="\]";
local BGREEN="${OPEN}$(tput setaf 2 ; tput bold)${CLOSE}"
local BBLUE="${OPEN}$(tput setaf 4 ; tput bold)${CLOSE}"
local BRED="${OPEN}$(tput setaf 1 ; tput bold)${CLOSE}"
local COLOROFF="${OPEN}$(tput sgr0)${CLOSE}"
export PS1='${debian_chroot:+($debian_chroot)}'"${BRED}"'$(__git_ps1 "{%s} ")'"${BGREEN}"'\u@\h'"${BBLUE}"' \W \$ '"${COLOROFF}"