Skip to content

Instantly share code, notes, and snippets.

View andresfelipemendez's full-sized avatar

Andrés Felipe Méndez andresfelipemendez

View GitHub Profile
@andresfelipemendez
andresfelipemendez / gist:7030688
Created October 17, 2013 19:20
fullwidth img clipping
// function fullViewportBackground (image, viewport) {
// var contenedor = $('body'),
// imagen = contenedor.children('img'),
// width = imagen.width(),
// height = imagen.height(),
// iratio = width/height,
// cwidth = contenedor.width(),
// cheigth = contenedor.height(),
// cratio = cwidth/cheigth;
var express = require('express')
, app = express()
, server = require('http').createServer(app)
, io = require('socket.io').listen(server)
, fs = require('fs')
, path = require('path')
, gpio = require('rpi-gpio')
server.listen(8000);
@andresfelipemendez
andresfelipemendez / calendar
Last active August 29, 2015 14:16
calendar generator
/*jslint plusplus: true */
function daysInMonth(month, year) {
'use strict';
return new Date(year, month, 0).getDate();
}
function generateCalendar(year) {
'use strict';
var calendar = {},
month,
/*globals Snap,*/
var s = new Snap(500, 375),
blue1 = '#1CC9C4',
blue2 = '#1A9FC2',
yellow = '#FFC83F',
red = '#C23150',
brown = '#AC9B7A',
purple = '#4B5E80',
white = '#EAE8B7';
@andresfelipemendez
andresfelipemendez / getEvents.js
Created April 6, 2015 14:01
get events and draw them
for(var event in Schedule.getEvents(tipoEvento,rango[fechaInicio,fechaFinal]) {
Calendar.drawEvent(tipoEvento,fechaEvento,horaInicio,horaFinal);
}
// packages/appslife:schedule/server/getEvents.js
@andresfelipemendez
andresfelipemendez / Rotate.cs
Created July 7, 2015 01:28
Rotation, the object at the center will rotate towards the target
Vector3 pos = Camera.main.ScreenToWorldPoint (new Vector3 (${Target}.position.x, ${Target}.position.y, 5));
float angle = Mathf.Atan((pos.y - ${Center}.position.y) / (pos.x - ${Center}.position.x)) * Mathf.Rad2Deg;
if(pos.x < transform.position.x){ angle += 180; } // avoid 'flipping' the rotation
${Center}.transform.rotation = Quaternion.Euler(0, 0, angle);
@andresfelipemendez
andresfelipemendez / Controller.cs
Last active January 21, 2016 03:37
Quacopter Controller
void Awake ()
{
hover = (body.mass * Physics.gravity.y) / -4;
}
void FixedUpdate ()
{
// compensate the spring in the controller to simulate the thortle without the spring in a real quadcopter controller
float thrust = hover + (Input.GetAxis ("Throttle") * throttle);
// FR front right
@andresfelipemendez
andresfelipemendez / private.xml
Created September 16, 2015 19:12
karabiner row remap
<?xml version="1.0"?>
<root>
<item>
<name>how row arrows</name>
<identifier>private.leftopt_plus_k_to_down</identifier>
<autogen>
__KeyToKey__
KeyCode::K,
ModifierFlag::OPTION_L,
KeyCode::CURSOR_DOWN
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
;;; init.el --- Spacemacs Initialization File
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;