Skip to content

Instantly share code, notes, and snippets.

View mildsunrise's full-sized avatar
🦊
*rolls*

Alba Mendez mildsunrise

🦊
*rolls*
View GitHub Profile
@mildsunrise
mildsunrise / gcd.coffee
Last active January 14, 2018 16:00
Greatest Common Divisor (GCD), simplified
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 March 1, 2012 12:43
Greatest Common Divisor (GCD), compressed
gcd={a,b->b?gcd(b,a%b):a}
mcm={a,b->a*b/gcd(a,b)}
@mildsunrise
mildsunrise / proxy.coffee
Last active October 2, 2015 20:08
Fast, simple, extensible Node.JS direct proxy.
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 July 17, 2012 16:06
"clear" command in Python
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 October 11, 2015 10:58
Greatest Common Divisor comes to Stylus!
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 December 18, 2015 11:29
You see, comparing versions is a form of art.
// 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 || \
@mildsunrise
mildsunrise / dabblet.css
Created June 23, 2013 11:33
Inner text shadow
/* 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);
@mildsunrise
mildsunrise / tour.html
Last active December 20, 2015 01:09
Simple tour
<!-- 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 December 21, 2015 10:49
Best way to check wether a square is "next to" another square.
# 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
@mildsunrise
mildsunrise / dabblet.css
Created September 18, 2013 13:11
Shadow effects
/**
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!