Skip to content

Instantly share code, notes, and snippets.

@phase
phase / rewrite.sh
Created June 12, 2015 09:06
Rewrite the commits of a git repo to have your name and email
#!/bin/sh
git filter-branch --env-filter '
CORRECT_NAME="YOUR_NAME"
CORRECT_EMAIL="YOUR_EMAIL"
if [ "$GIT_COMMITTER_EMAIL" != "$CORRECT_EMAIL" ]
then
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
export GIT_COMMITTER_NAME="$CORRECT_NAME"
@phase
phase / buid.gradle
Last active August 29, 2015 14:22
Using multiple Gradle plugins for each other
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:0.12.200'
}
}
apply plugin: 'kotlin'
@phase
phase / Fish
Last active August 29, 2015 14:24 — forked from anonymous/Fish
Fish f
⍝ Variables
⎕IO←0 ⍝ Arrays start with 0
S←⍬ ⍝ This will hold the stack(s)
i←'' ⍝ This is an input buffer
s←,0 ⍝ This will hold the markers for [ and ], the first stack is at pos 0.
D←4 2⍴D,⌽D←0 1 0 ¯1 ⍝ Directions
p←0 0 ⍝ Position (start at 0,0)
v←0 ⍝ This is set to 1 when reading a string
import java.awt.Point;
import java.util.*;
public abstract class AbstractLattice implements Tiling<AbstractLattice.LatticeCell> {
// Use the idea of expansion and vertex mapping from my earlier aperiod tiling implementation.
private Map<Point, Set<LatticeCell>> vertexNeighbourhood = new HashMap<Point, Set<LatticeCell>>();
private int scale = -1;
// Geometry
private final int dx0, dy0, dx1, dy1;
@phase
phase / ReturnAdapter.java
Last active September 20, 2015 21:05 — forked from VijayKrishna/ReturnAdapter.java
Example code showing how the AdviceAdapter in ASM(.ow2.org) can be used/extended.
package self.vpalepu.stackoverflow;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
@phase
phase / pirates vs ninjas.java
Created October 11, 2015 08:12
pirates vs ninjas.java
public void giveNinjaInv(Player p) {
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 2, false));
p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 1, false));
ItemStack helm = new ItemStack(Material.LEATHER_HELMET, 1);
LeatherArmorMeta mh = (LeatherArmorMeta) helm.getItemMeta();
mh.setColor(Color.fromRGB(68, 68, 68));
helm.setItemMeta(mh);
ItemStack chest = new ItemStack(Material.LEATHER_CHESTPLATE, 1);
LeatherArmorMeta mc = (LeatherArmorMeta) chest.getItemMeta();
mc.setColor(Color.fromRGB(68, 68, 68));
@phase
phase / ToolStrength.java
Last active July 1, 2021 19:45
Tool Strengths for Minecraft 1.8. Used in https://github.com/phase/PhaseBot
package xyz.jadonfowler.phasebot.world;
import java.util.*;
import lombok.*;
import xyz.jadonfowler.phasebot.world.material.*;
public enum ToolStrength {
//@formatter:off
WOOD(2f, Material.fromString("wood_sword", "wood_pickaxe", "wood_axe", "wood_spade", "wood_hoe")),
STONE(4f, Material.fromString("stone_sword", "stone_pickaxe", "stone_axe", "stone_spade", "stone_hoe")),
@phase
phase / client.c
Last active October 25, 2015 02:54
Runtime Evaluation of code through Sockets
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
void error(char *msg) {
perror(msg);
exit(0);
}
@phase
phase / yugiooooooooooh.java
Created November 4, 2015 00:16
English parsing crap
String text = "attack 500." //description of card
String[] sentences = text.split("."); //each sentence will be parsed as a command
ArrayList<Token> tokens = new ArrayList<Token>(); //each sentence translates to a set of tokens
for(String s : sentences)
for(String word : s.split(" "))
if(word.equalsIgnoreCase("attack"))
tokens.add(new AttackToken()); //add attack token if the word is Attack
@phase
phase / zalgo.py
Last active November 8, 2015 06:02
Zalgo text generator
import random
import sys
import argparse
#Characters
superscript = [
"\u030d", "\u030e", "\u0304", "\u0305", "\u033f",
"\u0311", "\u0306", "\u0310", "\u0352", "\u0357",
"\u0351", "\u0307", "\u0308", "\u030a", "\u0342",
"\u0343", "\u0344", "\u034a", "\u034b", "\u034c",