Skip to content

Instantly share code, notes, and snippets.

View midned's full-sized avatar
🏠
Working from home

Álvaro C midned

🏠
Working from home
  • Vitech
  • Montevideo
View GitHub Profile
use std::char;
type Board = [[char; 3]; 3];
static BOARD: Board = [
['C', 'B', 'X'],
['A', 'A', 'A'],
['N', 'N', 'T']
];
@midned
midned / Makefile
Last active July 21, 2016 02:41
Makefile
# Use gcc to compile
CC = gcc
# wildcard allows you to use * to select multiple files on a directory
# $(wildcard gen/logic/*.c) will sellect all files inside gen/logic/ that end with .c
SOURCE_FILES := $(wildcard gen/logic/*.c) $(wildcard gen/display/*.c) $(wildcard man/*.c)
# Now, all object files are stored right where source files are.
# This prevents having trouble when multiple files have the same name but they
# are in different directories. Resulting with .o files with the same name
# inside the obj/ directory.
inline constexpr bool isSpecialScheme(const char* scheme) {
return scheme == "ftp" || scheme == "file" || scheme == "gopher" || scheme == "http" || scheme == "https" || scheme == "ws" || scheme == "wss";
}
@midned
midned / Signal.cpp
Created March 14, 2015 23:16
c++ signals
#include <vector>
#include <functional>
#include "Signal.h"
template<typename ...Arguments>
void Signal<Arguments...>::connect(std::function<void (Arguments...)> listener) {
listeners.push_back(listener);
}
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[]) {
int opcion;
int numero;
@midned
midned / gist:6587105
Last active February 18, 2016 14:45
fun attack
setInterval(function(){
document.body.style.background = 'rgba('+Math.floor(Math.random()*255)+', '+Math.floor(Math.random()*255)+', '+Math.floor(Math.random()*255)+', 1)';
},50);
@midned
midned / gist:5887752
Last active December 19, 2015 03:08
Event listening with #swag
Node.prototype.on = Node.prototype.addEventListener;
Node.prototype.off = Node.prototype.removeEventListener;
var elem = document.getElementById('some-element');
function yolo(){
console.log('yolo');
}
elem.on('click', yolo);
function $(selector, context)
{
if (!(context instanceof Element)) {
context = document;
}
return context.querySelectorAll(selector);
}
// querySelectorAll() returns a NodeList object so we need to get the first one
(coffee -o ../assets/js -cw coffee) & (jade -w -P jade/index.jade --out ../) & (stylus --out ../assets/css -w stylus) &
@midned
midned / demo.coffee
Last active December 13, 2015 20:28
Handle the routes in Javascript using HTML5 pushState (uses Zepto.js and https://github.com/balupton/History.js)
# Create the router that will handle routes to 'site.com/app'
router = new Routy.Router 'app'
# also you can:
# router = new Routy.Router 'app', 'a.routy-link'
# to only listen clicks to links with the "routy-link" class
# or:
# router = new Routy.Router 'app', null, '#container'
# to listen clicks for every link inside the element with the "container" id
# this will handle 'app/' and 'app/home'