Want to fork your own gists? No fork button? No problem! Install this user script by clicking refork.user.js' "raw" link down below: ⇓
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
var keys = {up: 38, right: 39, down: 40, left: 37}; for(var i = 65; i < 91; i++) keys[String.fromCharCode(i+32)] = 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
if(location.search == "?music") { | |
//Do music! | |
var clientId = "dd250c3d9ef318565e6f22e871b87fb8"; | |
var musicUrl = "http://soundcloud.com/alex-nicholls/snakes-theme"; | |
$.getJSON( | |
'http://api.soundcloud.com/resolve.json?callback=?', { | |
url: musicUrl, | |
client_id: clientId | |
}, function(data) { | |
if(data.streamable && data.stream_url) { |
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
groups: | |
default: | |
default: true | |
permissions: | |
- modifyworld.* | |
- bukkit.broadcast.user | |
- group.default | |
- ultimatearena.player | |
- hcw.ban.world.world |
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
#!/usr/bin/env python | |
import itertools | |
def f(a, b, c, d): | |
return a*b + b*c + c*d + a*d | |
print max(f(*p) for p in itertools.permutations([1,2,3,4])) |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>name</key> | |
<string>Indent</string> | |
<key>scope</key> | |
<string>source.lua</string> | |
<key>settings</key> | |
<dict> |
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
<snippet> | |
<content><![CDATA[for _, child in pairs(${1:parent}:GetChildren()) do | |
${0} | |
end]]></content> | |
<tabTrigger>children</tabTrigger> | |
<scope>source.lua</scope> | |
<description>iterate children</description> | |
</snippet> |
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
--quick implementation of python's id function. Fails for built in roblox objects | |
id = function(o) | |
return type(o) == "table" and o.__id__ or tonumber(tostring(o):sub(-8, -1). 16) | |
end | |
class = setmetatable({}, { | |
__call = function(_, name, implementer) | |
local cls = {__init__ = function() end, __name__ = name} | |
local instancemt = {} |
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
merge = function(seqs) | |
local res = {} | |
while true do | |
--filter out empty sequences | |
local nonemptyseqs = {} | |
for _, seq in ipairs(seqs) do | |
if #seq > 0 then table.insert(nonemptyseqs, seq) end | |
end | |
--all sequences empty? we're done! | |
if #nonemptyseqs == 0 then return res 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
local ItemSet = {} | |
ItemSet.__index = ItemSet | |
ItemSet.new = function(mapping) | |
return setmetatable({mapping=mapping}, ItemSet) | |
end | |
-- internal functions | |
local _useItem = function(self, fn, name) | |
local i = self:slot(name) | |
turtle.select(i) |