This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local colors | |
local color_map_mt, colors_mt = {}, {} | |
-- set up metatable imposed on each individual color map table (rgba values) | |
function color_map_mt.__index(t, k) | |
local mt = getmetatable(t) | |
return mt[k] | |
end | |
function color_map_mt.rgb(color) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function rmb { | |
current_branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') | |
if [ "$current_branch" != "master" ]; then | |
echo "WARNING: You are on branch $current_branch, NOT master." | |
fi | |
echo "Fetching merged branches..." | |
git remote prune origin | |
remote_branches=$(git branch -r --merged | grep -v '/master$' | grep -v '/production$' | grep -v '/staging$' | grep -v "/$current_branch$") | |
local_branches=$(git branch --merged | grep -v '/master$' | grep -v '/production$' | grep -v '/staging$' | grep -v "$current_branch$") | |
if [ -z "$remote_branches" ] && [ -z "$local_branches" ]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fib = setmetatable({1, 1}, | |
{__index = function(t,n) | |
t[n] = t[n-1] + t[n-2] | |
return t[n] | |
end}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
[ | |
{ "keys": ["super+v"], "command": "paste_and_indent" }, | |
{ "keys": ["super+shift+r"], "command": "reveal_in_side_bar" }, | |
{ "keys": ["super+ctrl+r"], "command": "reveal_in_side_bar" } | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
$.fn.getTextWidth = function() { | |
var spanText = $("BODY #spanCalculateTextWidth"); | |
if (spanText.size() <= 0) { | |
spanText = $("<span id='spanCalculateTextWidth" + U_gen_id() + "' style='filter: alpha(0);'></span>"); | |
spanText.appendTo("BODY"); | |
} | |
var valu = this.val(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function permgen (a, n) | |
if n == 0 then | |
coroutine.yield(a) | |
else | |
for i=1,n do | |
-- put i-th element as the last one | |
a[n], a[i] = a[i], a[n] | |
-- generate all permutations of the other elements |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.jibble.pircbot.*; | |
import java.util.Random; | |
import java.util.ArrayList; | |
public class MyBot extends PircBot { | |
public String channel; // The name of the primary channel. | |
public ArrayList map; // The map data. 0 = empty, 1 = wumpus, 2 = shaft, 3 = bats, 4 = player. | |
public String player; // The player's nickname. | |
public boolean gameInProgress; // Whether or not there is a game in progress. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="jquery-1.6.2.js"></script> | |
</head> | |
<body> | |
<script> | |
$(document).ready(function() { | |
$.ajaxSetup ({ | |
cache: false | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
modules['subredditLinker'] = { | |
moduleID: 'subredditLinker', | |
moduleName: 'Subreddit Linker', | |
options: { }, | |
description: 'Finds any subreddit mentions that are not links and converts them into links.', | |
isEnabled: function() { | |
return RESConsole.getModulePrefs(this.moduleID); | |
}, | |
include: Array( | |
/https?:\/\/([a-z]+).reddit.com\/user\/[-\w\.]+/i, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function middleofsquare(x) | |
local m = tostring(math.pow(x, 2)):sub(4,9) | |
m = m:match("^[0]*(%d*)") --trim leading zeros | |
local offset = 1 | |
while(string.len(m) < 6) do | |
m = tostring(math.pow(x, 2)):sub(4 - offset,9 - offset) | |
m = m:match("^[0]*(%d*)") --trim leading zeros | |
offset = offset + 1 | |
end | |
return m |