Skip to content

Instantly share code, notes, and snippets.

View EduardoLopes's full-sized avatar

Eduardo Lopes EduardoLopes

View GitHub Profile
@anissen
anissen / Test.hx
Created March 7, 2016 20:44
Diamond-square algorithm for generating realistic terrain
class Heightmap {
var size :Int;
var tiles :Array<Array<Null<Float>>>;
var d :Int;
public function new() {
}
@anissen
anissen / Perlin.hx
Last active April 12, 2016 13:33
Animated perlin noise example
class Perlin {
public var repeat :Int;
public function new(repeat :Int = -1) {
this.repeat = repeat;
}
public function OctavePerlin(x :Float, y :Float, z :Float, octaves :Int, persistence :Float) {
var total :Float = 0;
var frequency :Float = 1;
@anissen
anissen / perlin.hx
Last active March 5, 2017 18:16
Perlin noise test
// Haxe implementation ported from https://gist.github.com/Flafla2/f0260a861be0ebdeef76
// Related article: http://flafla2.github.io/2014/08/09/perlinnoise.html
class Perlin {
public var repeat :Int;
public function new(repeat :Int = -1) {
this.repeat = repeat;
}
@ruby0x1
ruby0x1 / Random.hx
Last active August 29, 2015 14:17
Random.hx
package ;
//Adapted from code by Grant Skinner, see bottom of file.
//This is cut from https://github.com/underscorediscovery/luxe under MIT license
/**
Given an `initial` value for the seed, subsequent generated numbers will be predictable,
and the `seed` value updated to reflect the current seed which can be used to resume predictability
from an ongoing set. Uses a Park–Miller pseudo random number generator.
@fadookie
fadookie / TempoManager.cs
Last active August 29, 2015 14:13
Unity Tempo Manager Example
/**
* This is an example of how to make a class that fires off events to the BPM of a song.
* I haven't tested it and it may require work to compile, this is based off a much more complex
* manager from another project.
*
* Copyright (c) 2015 Eliot Lash
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
@alganet
alganet / tipagem_primitiva.md
Last active August 12, 2019 22:48
PHP Prático: Tipagem Primitiva

PHP Prático: Tipagem Primitiva

A primeira coisa a saber sobre a tipagem do PHP é que ela não é parecida com Java, JavaScript, Python, Ruby, C, C++, C# ou qualquer linguagem que tenha uma tipagem baseada em alguma dessas citadas. A tipagem do PHP é incomparável, e assim como tudo que não pode ser comparado é difícil de ser explicada.

De qualquer forma, a tipagem do PHP é extremamente simples se você apenas confiar na sua intuição. A primeira coisa que você tem que saber sobre a tipagem do PHP é que ela faz malabarismos. É exatamente essa a palavra: malabarismo. E o PHP é um ótimo malabarista, exceto por alguns poucos deslizes fáceis de decorar. O type juggling, traduzido para "malabarismo com tipos" é a habilidade que o PHP tem de tomar decisões intuitivas sobre conversões de tipos. Em termos grosseiros, o PHP decide toda e qualquer tipagem de variáveis em tempo de execução, não compilação (pros pedante aí que tão lendo).

Note bem: tipagem de variáveis. O PHP é multi-paradigma e, ao m

@pete-otaqui
pete-otaqui / happytime-amd.js
Last active February 10, 2018 18:00
A better setTimeout, setInterval and requestAnimationFrame, wrapped as an AMD module and fine for many JSHint setups.
/*
See http://paulirish.com/2011/requestanimationframe-for-smart-animating/
and http://blog.joelambert.co.uk/2011/06/01/a-better-settimeoutsetinterval/
*/
define([
],
function () {
'use strict';
@jareware
jareware / SCSS.md
Last active April 23, 2024 22:13
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

@johanmeiring
johanmeiring / gist:3002458
Created June 27, 2012 08:32
"git lg" alias for pretty git log
# From http://garmoncheg.blogspot.com/2012/06/pretty-git-log.html
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"
@gre
gre / easing.js
Last active April 23, 2024 04:20
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {