This file contains 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
-- From https://github.com/karai17/Simple-Tiled-Implementation/blob/4ac519dbd5efdc0c6a70c35b9125faebe347772f/map.lua#L217 | |
local ffi = require("ffi") | |
local function getDecompressedData(data) | |
local d = {} | |
local decoded = ffi.cast("uint32_t*", data) | |
for i=0, data:len() / ffi.sizeof("uint32_t") do | |
table.insert(d, tonumber(decoded[i])) | |
end |
This file contains 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
require "gd" | |
function project(px, py, pz, win_width, win_height, fov, cam) | |
local factor = fov / (cam+pz) | |
local x = px*factor + win_width/2 | |
local y = -py*factor + win_height/2 | |
return x, y | |
end | |
local base = gd.createFromJpeg("base.jpg") |
This file contains 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 love.load() | |
player = { | |
grid_x = 256, | |
grid_y = 256, | |
act_x = 256, | |
act_y = 256, | |
speed = 10 | |
} | |
map = { |
This file contains 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
package main; | |
import java.util.*; | |
import org.jibble.pircbot.*; | |
public class CyberBot extends PircBot { | |
boolean noGame = true, prep, inGame; | |
String chan = "#cyberzone"; | |
ArrayList<Player> players = new ArrayList<Player>(); |
This file contains 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 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 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 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 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 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 |