Skip to content

Instantly share code, notes, and snippets.

View colormono's full-sized avatar
🤓
I’m learning as I go

Mariano Rivas colormono

🤓
I’m learning as I go
View GitHub Profile
@colormono
colormono / Boucing
Created June 24, 2013 12:19
Bouncing. The object bounce when reach the screen borders.
void bounce(){
if ( (location.x > width) || (location.x < 0) ) {
velocity.x = velocity.x * -1;
}
if ( (location.y > height) || (location.y < 0) ) {
velocity.y = velocity.y * -1;
}
}
@colormono
colormono / Toloidal
Created June 27, 2013 15:11
Efecto Pacman, sale de un lado y aparece por el opuesto.
void checkEdges() {
if (location.x > width) {
location.x = 0;
} else if (location.x < 0) {
location.x = width;
}
if (location.y > height) {
location.y = 0;
@colormono
colormono / countdown.js
Last active December 19, 2015 02:38 — forked from atinux/countdown.js
var countDown = function (endDate, el) {
el = el || $('body');
var leadingZero = function (nb) {
return (nb < 10) ? "0" + nb : + nb;
};
var updateTimer = function (seconds) {
var days = Math.floor(seconds / 86400);
seconds -= days * 86400;
var hours = Math.floor(seconds / 3600);
seconds -= hours * (3600);
@colormono
colormono / jade.md
Last active December 19, 2015 22:49

Using Yeoman and Jade

Getting started

  • Make sure you have yo installed: npm install -g yo
  • Run: yo webapp
  • Install grunt-contrib-jade: npm install grunt-contrib-jade --save-dev

Customization

@colormono
colormono / debugThis
Created August 29, 2013 18:01
Debug errors
try{
// Your code here
// If an error occures, catch it and show me
} catch( err ){
alert( "Error at line # " + err.line.toString() + "\r" + err.toString() );
}
@colormono
colormono / getLayerNames
Created August 29, 2013 18:06
Get layers names from a composition
/* Get layers names from a composition */ { app.beginUndoGroup("Demo Script"); var proj = app.project; var myFirstComp = proj.item(1); var myList = new Array(); for( var i=1; i <= myFirstComp.numLayers; i++ ){ myList[ myList.length ] = myFirstComp.layer(i).name; } var myListCorrected = myList.toString().replace( new RegExp( ",", "g" ), "\r" ); alert (myFirstComp.name + ":\r" + myListCorrected); app.endUndoGroup(); }
@colormono
colormono / addToCompositions
Created August 29, 2013 20:25
Add solids to multiple compositions
/* Add solids to multiple compositions */ try{ // Variables var proj = app.project; var itemsTotal = proj.numItems; var solidColor = [0, 0, 1]; var curItem, curItemLayers, compName, compWidth, compHeight, compPAR, compDur, solidName, curSolid, totalComps; var itemAry = new Array(); // Loop through project item app.beginUndoGroup("Add new solids"); for( var i=1; i<= itemsTotal; i++ ){ // Item assignment curItem = proj.item(i); // Check if item is a comp if ( curItem instanceof CompItem ){ itemAry[itemAry.length] = curItem; } } totalComps = itemAry.length; for( var c=0; c<totalComps; c++ ){ // Variable assignment curItemLayers = itemAry[c].layers; compName = itemAry[c].name; compWidth = itemAry[c].width; compHeight = itemAry[c].height; compPAR = itemAry[c].pixelAsp
add_filter('post_thumbnail_html', 'slug_responsive_img', 5, 5);
//Image sizes for Interchange
add_image_size( 'fd-lrg', 1024, 99999);
add_image_size( 'fd-med', 768, 99999);
add_image_size( 'fd-sm', 320, 9999);
function slug_responsive_img($html, $post_id, $post_thumbnail_id, $size, $attr) {
//make image links
$attachment_id = $post_thumbnail_id;
$default = wp_get_attachment_image_src($attachment_id);
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://npmjs.org/install.sh | sh
@colormono
colormono / OSC Listen and Send
Created July 27, 2014 17:56
OSC Listen and Send
/*
This sketch demonstrates the use of OSC in Resolume Avenue 3 and TouchOSC
an application made for the iPhone that can send OSC messages.
So install TouchOSC on your Iphone or Ipod touch (available in the App store)
*/
// start OSC config
import oscP5.*;
import netP5.*;