Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
struct Vec3d {
int x;
int y;
int z;
};
@phase
phase / rename_images.groovy
Created March 19, 2016 18:12
Groovy Script to rename a bunch of images by number
int count = 1
new File("C:/Users/phase/Pictures/FloridaVisits").eachFile() { file ->
if(file.getName().endsWith(".jpg")) {
String absolutePath = file.getAbsolutePath()
String filePath = absolutePath.substring(0,absolutePath.lastIndexOf(File.separator))
println file.getAbsolutePath() + " -> " + filePath+"\\"+count+".jpg"
file.renameTo(new File(filePath+"\\"+count+++".jpg"))
}
}
@phase
phase / subforumlist.tpl
Created March 25, 2016 08:21
List Subforums in Blargboard
{foreach $categories as $cat}
{foreach $cat.forums as $forum}
<tr class="cell1">
<td class="cell2 newMarker">{$forum.new}</td>
<td>
<h4{if $forum.ignored} class="ignored"{/if}>{$forum.link}</h4>
<span class="smallFonts{if $forum.ignored} ignored{/if}">
{$forum.description}
{if $forum.localmods}<br>Moderated by: {$forum.localmods}{/if}
</span>
@phase
phase / killtty.sh
Created April 12, 2016 06:08
Kill TTYs
kill $(ps -u phase | grep -Po '^\s*\d+(?= tty)') -9
@phase
phase / string.sh
Last active May 17, 2016 03:19 — forked from earthgecko/bash.generate.random.alphanumeric.string.sh
shell/bash generate random string
#!/bin/bash
# bash generate random 5 character string)
cat /dev/urandom | tr -dc 'a-z' | fold -w 5 | head -n 1
@phase
phase / lang.txt
Created May 18, 2016 16:19
Some examples
#lang: https://github.com/phase/lang-jit-compiler
int double (int x) {
x * x # last expression returned
}
int a (int b, int c) {
int d = 7
int e = a * b
int g = double double d
From c5c7f68d947f366fef739e0ac3a655baed507bfe Mon Sep 17 00:00:00 2001
From: Jadon Fowler <[email protected]>
Date: Thu, 19 May 2016 18:13:48 -0600
Subject: [PATCH] Optimize conversion to Mojang-style UUIDs by avoiding regex
diff --git a/api/src/main/java/net/md_5/bungee/api/ServerPing.java b/api/src/main/java/net/md_5/bungee/api/ServerPing.java
index 314a1d2..6804ad9 100644
--- a/api/src/main/java/net/md_5/bungee/api/ServerPing.java
+++ b/api/src/main/java/net/md_5/bungee/api/ServerPing.java
@@ -73,7 +73,7 @@ public class ServerPing
@phase
phase / VEXREX_emu.py
Created June 1, 2016 02:38
The worst Python code I've ever seen.
import time
def ALU(A,B,IA,IB,Cin,OR,FC):
preC,Carry,C=[0 for i in range(len(A)+1)],[0 for i in range(len(A)+2)],[0 for i in range(len(A)+1)]
for i in range(len(A)):
if IA:
if A[i] == 1:
A[i] = 0
else:
A[i] = 1
if IB:
@phase
phase / layoutmaster.patch
Created June 1, 2016 11:14
Patch for lib/layout.php in https://github.com/phase/Blargboard to support Subforum listings
diff --git a/lib/layout.php b/lib/layout.php
index a36806f..4f0e7a8 100644
--- a/lib/layout.php
+++ b/lib/layout.php
@@ -7,12 +7,12 @@
function RenderTemplate($template, $options=null)
{
global $tpl, $mobileLayout, $plugintemplates, $plugins;
-
+