Skip to content

Instantly share code, notes, and snippets.

@qgustavor
qgustavor / dabblet.css
Created February 20, 2013 00:32
Minecraft Disks
/**
* Minecraft Disks
*/
body{
background: black url(http://minecraftstal.com/stal.png) 0/30px;
animation: disks 2s linear 0 infinite;
min-height: 100%;
overflow: hidden;
}
@qgustavor
qgustavor / mcprotocol.bat
Last active July 15, 2024 01:25
Minecraft Protocol Handler: enable minecraft:// protocol in Windows
@echo off
rem => Minecraft Protocol Handler
rem Enable minecraft:\\ protocol in Windows
rem Usage: minecraft:\\hostname.tld:port
color 1f
set input=%1
if a%input%z == az set input=null
# MCEdit Filter by CrushedPixel
# http://youtube.com/CrushedPixel
# source: http://www.mediafire.com/view/o6af3cuo45pj9pn/CPTerraformingClay.py
displayName = "Natural Blocks to Clay"
inputs = ()
blocks = [
['35:0', 80], # white stained clay
@qgustavor
qgustavor / gist:6345817
Created August 26, 2013 19:49
.party()!
class Game
(awesome) ->
@party = -> ->
if awesome
'Party!'
minecraft = new Game(yes)
minecraft.party()!
@qgustavor
qgustavor / gist:8810385
Last active January 9, 2024 18:45
REPL
// REPL - Ler, compilar, mostrar, repetir
!function repl ( // colocar ! atrás da função: economiza um caractere, ao invés de usar ()
input // para não ter que colocar "var " colocamos nos argumentos
) {
input = prompt('Insira um comando:'); // "prompt" lê a entrada
if (input) // se o usuário entrou com um comando, então:
alert(eval(input)), // alerta o resultado do comando, usando "eval"
setTimeout(repl) // chama a função novamente depois de 4ms
}() // executa a função, iniciando o loop
@qgustavor
qgustavor / infinite-scroll.js
Created February 25, 2014 15:51
Scroll infinito
window.onscroll = function onScroll() {
var htmlEl = document.documentElement,
alturaJanela = htmlEl.clientHeight,
alturaTotal = Math.max(document.body.scrollHeight, htmlEl.scrollHeight, document.body.offsetHeight, htmlEl.offsetHeight, htmlEl.clientHeight);
// Aplique a lógica que quiser, usei: se o scroll
if(alturaTotal - 2 * alturaJanela < window.scrollY) {
carregarDados();
}
window.onscroll = null;
@qgustavor
qgustavor / gist:11261348
Created April 24, 2014 16:46
Browser recursion test
/** Get the maximum call stack and the error it generates */
(function () {
var results = {};
(function f (a) {
try {
f(a+1);
} catch (e) {
results[a] = e;
}
}(0));
@qgustavor
qgustavor / example.js
Last active August 29, 2015 14:03
Advanced compilation version of hasChainOfKeys
// Example usage:
var example1 = {foo: {bar: 1}},
example2 = {foo: {bar: 1, qux: 1}},
example3 = {foo: {BAZ: 1}},
template1 = {foo: {bar: 1}}
template2 = {foo: {bar: {qux: 1}}}},
// returns true: all keys from the template exist in the object
hasChainOfKeys(example1, template1);
@qgustavor
qgustavor / isValidEmail.js
Last active August 29, 2015 14:07
isValidEmail
/**
* Validates e-mail addresses
* Supports internacionalized e-mails
*/
function isValidEmail(input) {
// Split the e-mail into local part and domain part:
var parts = input.split('@');
// It needs to have those two parts:
if (parts.length !== 2) return false;
var reservedWords = "arguments caller length name prototype __proto__".split(" ")
module.exports = createNamedParameters
function createNamedParameters(argv, fn) {
var length = fn.length
var composed = Array(length)
if (argv.length !== length) throw new Error("Argument lengths don't match")
function composing() {