Skip to content

Instantly share code, notes, and snippets.

View telamon's full-sized avatar
🥲
probing for lost signals

Tony Ivanov telamon

🥲
probing for lost signals
View GitHub Profile
@telamon
telamon / delta.py
Last active August 29, 2015 14:00
DeltaTime dependend positioning.
float accumlatedTime=0;
Sprite cow;
float runSpeed = 1; # in pixels per second
float fallingAccelleration = 0.3; # how fast the fall should reach topspeed plummeting.
float maxFallVelocity = 3.0; # Should not be able to fall faster than 3px/s
onFrame(float deltaTime):
accumulatedTime + = deltaTime;
# Timestamp when a jump reached it's peak height and you're scheduled with a romantic date with gravity.
@telamon
telamon / Gemfile.lock
Created May 3, 2014 11:06
Lockfile generated by Tumblargh/Middleman dependencies.
PATH
remote: ../tumblargh
specs:
tumblargh (0.2.2)
activesupport (>= 3.1)
api_cache
nokogiri
treetop
GEM
<!DOCTYPE html>
<html ng-app="app">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-rc.3/angular.min.js"></script>
<script type="text/javascript">
var app = angular.module('app',['ng']);
app.controller('MainCtrl', function($scope){
});
@telamon
telamon / array_group.rb
Created April 27, 2011 12:55
JS array.inGroupsOf() behaviour for Ruby
class Array
def groups_of(s)
resp = []
g=[]
self.each do |i|
g << i
if g.count == s
resp << g
g= []
end
@telamon
telamon / short_hash.rb
Created May 16, 2011 16:34
Really short(6chars) hash method
# Really short hash, (no extra collisions besides the known CRC32 )
# Correct term for this encoding should be "Trimmed Urlsafe Base Encoded CRC32 Hash" or TUBECH?.. two-bitch encoding, lol.
# String.send(:include , ShortHash)
# "Hello World".short_hash # => "VrEXSg"
module ShortHash
require 'base64'
@telamon
telamon / effect_rotate.js
Created May 24, 2011 16:46
Effect.Rotate patch for Scriptaculous
Element.getTransform= function (element){
var properties = [
'transform',
'WebkitTransform',
'MozTransform',
'msTransform',
'OTransform'
];
var p;
while (p = properties.shift()) {
@telamon
telamon / gravatar_helper.rb
Created May 24, 2011 17:37
Simple Gravatar helper for Rails
module GravatarHelper
def gravatar_tag(email,*args)
opts = args.extract_options!
opts[:class]||=""
opts[:class]+=" gravatar"
size = opts.delete(:size) || 80
require 'digest/md5'
default=""
@telamon
telamon / buffer_mapper.rb
Created June 1, 2011 13:38
BufferMapper provides lazy-loading bindings for a binary buffer
module Raumod::BufferMapper
# See http://ruby-doc.org/core/classes/String.html#M001112
# for map types.
def data_map;@data_map;end
def data;@data;end
def data_entry(method)
offset = data_map[method][:offset]
type = data_map[method][:type]
d = data[offset..-1].unpack(type)
@telamon
telamon / mylib.js
Created February 24, 2012 13:05
JavaScript web library pattern
(function(){ // Wrap everything up in a function
var count,person; // These become private to this wrapped scope, and do not clutter the global namespace.
count=0; // Modify private count var,
person= function(name){
this.name = name;
count++;
@telamon
telamon / JoglInputSystemCustom.java
Created March 26, 2012 23:15
Custom JoglInputSystem
/**
* Suppress mouse events if they hit panel with id "glassPane"
* unless a MouseDragged gesture is in process to ensure that every MouseClickedEvent that hits
* will be followed by an MouseReleasedEvent even if it's coords do not overlap any other nifty elements.
*/
private final JoglInputSystem inputSystem = new JoglInputSystem() {
boolean niftyBusy=false;
@Override
public void mouseDragged(MouseEvent mouseEvent) {