Skip to content

Instantly share code, notes, and snippets.

Avatar

Alba Mendez mildsunrise

View GitHub Profile
@mildsunrise
mildsunrise / gcd.coffee
Last active Jan 14, 2018
Greatest Common Divisor (GCD), simplified
View gcd.coffee
gcd = (a,b) -> if b then gcd b, a%b else a
mcm = (a,b) -> a*b / gcd(a,b)
@mildsunrise
mildsunrise / gcd.groovy
Created Mar 1, 2012
Greatest Common Divisor (GCD), compressed
View gcd.groovy
gcd={a,b->b?gcd(b,a%b):a}
mcm={a,b->a*b/gcd(a,b)}
@mildsunrise
mildsunrise / proxy.coffee
Last active Oct 2, 2015
Fast, simple, extensible Node.JS direct proxy.
View proxy.coffee
http = require 'http'
util = require 'util'
url = require 'url'
server = http.createServer (req, res) ->
request = url.parse req.url
request.headers = req.headers
request.method = req.method
@mildsunrise
mildsunrise / clear.py
Created Jul 17, 2012
"clear" command in Python
View clear.py
class clear:
def __call__(self):
import os
if os.name==('ce','nt','dos'): os.system('cls')
elif os.name=='posix': os.system('clear')
else: print('\n'*120)
def __neg__(self): self()
def __repr__(self):
self();return ''
@mildsunrise
mildsunrise / gcd.styl
Last active Oct 11, 2015
Greatest Common Divisor comes to Stylus!
View gcd.styl
gcd(a,b)
unless b
return a
gcd(b, a%b)
mcm(a,b)
a*b / gcd(a,b)
@mildsunrise
mildsunrise / the-macro.c
Last active Dec 18, 2015
You see, comparing versions is a form of art.
View the-macro.c
// My artistic composition is able to compare
// two versions in a single expression! YAY!
#define FOO_AVAILABLE(major, \
minor, \
patch) \
\
( FOO_MAJOR_VERSION >major || \
( FOO_MAJOR_VERSION==major && \
\
( FOO_MINOR_VERSION >minor || \
View dabblet.css
/* Inner text shadow */
@import url(http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700,300italic);
h1 {
font: bold 6em 'open sans condensed';
text-align: center;
/** This is where the magic happens **/
background-color: rgba(204,129,0,.9);
View tour.html
<!-- the slides -->
<div id="slides">
<div class="slide">
<!-- Content of slide #1 -->
</div>
<div class="slide">
<!-- Content of slide #2 -->
</div>
<div class="slide">
<!-- Content of slide #3 -->
@mildsunrise
mildsunrise / is-it-next-to.py
Last active Dec 21, 2015
Best way to check wether a square is "next to" another square.
View is-it-next-to.py
# Returns `True` if the square at `a` is in one of the
# **eight surrounding squares** of `b`; `False` otherwise.
def nextTo(a, b):
x = a[0] - b[0]
y = a[1] - b[1]
d = x*x + y*y
return 0 < d < 3
View dabblet.css
/**
Shadow effects
==============
Multiple text-shadows can be stacked to
create wonderful, realistic effects.
Oh, and CSS allows for expressiveness too.
Try zooming in and disabling some shadows!