Skip to content

Instantly share code, notes, and snippets.

View syrusakbary's full-sized avatar
💪
Building @wasmerio

Syrus Akbary syrusakbary

💪
Building @wasmerio
View GitHub Profile
@syrusakbary
syrusakbary / fib.rb
Last active June 9, 2024 12:33
Fibonacci algorithm in O(1) ;)
SQRT_5 = Math.sqrt(5)
GOLDEN_NUMBER = (1+SQRT_5)/2
def fib(n)
(1/SQRT_5*(GOLDEN_NUMBER**n-(-1/GOLDEN_NUMBER)**n)).to_i
end
puts fib(7)
@syrusakbary
syrusakbary / robot.js
Created December 5, 2012 00:02 — forked from cgardner/robot.js
derp
var Robot = function(robot){
robot.turnLeft(robot.angle % 90);
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if (robot.parentId) {
robot.ahead(1);
robot.turnGunRight(1);
}
else {
@syrusakbary
syrusakbary / robot.js
Created December 5, 2012 00:02 — forked from cgardner/robot.js
derp
var Robot = function(robot){
robot.turnLeft(robot.angle % 90);
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if (robot.parentId) {
robot.ahead(1);
robot.turnGunRight(1);
}
else {
@syrusakbary
syrusakbary / django_boostrap.jade
Created September 11, 2012 19:13
Example of using pyjade with Django and Django-boostrap-toolkit
- load bootstrap_toolkit
!= form|as_bootstrap
@syrusakbary
syrusakbary / pyjade_plaincompiler.py
Created August 6, 2012 21:22
Compilador de pyjade sin utilizar ningún motor de templates (Django, Jinja2 o Mako)
from pyjade.ext.html import HTMLCompiler
from pyjade.utils import process
plantilla = "h1= titulo"
contexto = {"titulo": "Titulo principal"}
def compilar(plantilla, contexto):
compiler = HTMLCompiler
compiler.global_context = contexto
return process(plantilla,compiler=compiler)
@syrusakbary
syrusakbary / 3_4.m
Created December 16, 2011 10:55
Errores (problema 3 hoja 4)
>> A = [1 0 0; 0 1 0; 0 0 1; 1 -1 0; 1 0 -1; 0 1 -1;]
A =
1 0 0
0 1 0
0 0 1
1 -1 0
1 0 -1
0 1 -1
@syrusakbary
syrusakbary / carga.m
Created November 18, 2011 10:52
Problema 1 de la hoja 3 de Teoría de Errores
function [t,y]=carga(fichero)
[t,y] = textread(fichero, '%f %f');
t = t';
y = y';
end