Skip to content

Instantly share code, notes, and snippets.

View rcstr's full-sized avatar
:shipit:
Engineering

Rommel Castro rcstr

:shipit:
Engineering
View GitHub Profile
$("li .active span", '#list').each(bindEvenToSpan);
function bindEvenToSpan(i, elem) {
var $this = $(elem);
if($this.hasClass('shouldReact')) {
$this.on('mouseenter', addCssToSpan);
}
}
// is text or equation?
if (target.data.type === 'text') {
boundingBox.deleteIcon.position = {
x: target.bounds.topRight._x + 30,
y: target.bounds.topRight._y + 20
};
} else if(target.data.type === 'equation') {
boundingBox.deleteIcon.position = {
x: target.bounds.topRight._x + 90,
y: target.bounds.topRight._y + 40
@rcstr
rcstr / stock_route.js
Last active August 29, 2015 14:02
version with promise
AcornsTest.StockRoute = Ember.Route.extend({
model: function(params) {
"use strict";
var url_params = params.slug.split('|'),
url = AcornsTest.Config.quandl.URL + '/' + url_params[0] + '/' + url_params[1] + '.json',
stockInStore = this.store.getById('stock', url_params[1]),
promise = Ember.Deferred.create(),
today = new Date(),
yearAgo = new Date(),
self = this;
Array.prototype.diff = function(a) {
return this.filter(function(i) {return !(a.indexOf(i) > -1);});
};
.Absolute-Center {
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
@rcstr
rcstr / closures.php
Created September 28, 2013 04:08
Ejemplo basico de closures en PHP 5.4
<?php
class Calc {
public function mult($by = 1) {
return function($number) use($by) {
return $by * $number;
};
}
}
$calc = new Calc;
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database('./db.db');
var fs = require('fs');
var outputFilename = './output.json';
var jsonOutput = db.serialize(function() {
db.each("SELECT * FROM sqlite_master WHERE type='table'", function(err, table) {
db.each("SELECT * FROM " + table.tbl_name, function(err, row) {
# Enable Rewriting
RewriteEngine on
# Rewrite user URLs
# Input: /PAGE/
# Output: index.php?id=PAGE
RewriteRule ^(\w+)/?$ index.php?id=$1
// Visualize at:
// http://www.regexplained.co.uk/?pattern=%2F%5E(%3F%3A(%3F%3A0%5BxX%5D%5B0-9a-fA-F%5D%2B)%7C(%3F%3A0%5BoO%5D%5B0-7%5D%2B)%7C(%3F%3A0%5BbB%5D%5B01%5D%2B)%7C(%3F%3A%5Cd%2B%5C.%5Cd*(%3F%3A%5BeE%5D%5B%2B-%5D%3F%5Cd%2B)%3F)%7C(%3F%3A%5C.%5Cd%2B(%3F%3A%5BeE%5D%5B%2B-%5D%3F%5Cd%2B)%3F)%7C(%3F%3A%5Cd%2B(%3F%3A%5BeE%5D%5B%2B-%5D%3F%5Cd%2B)%3F))%24%2F
function isNumberLiteral(txt) {
var re = /^(?:(?:0[xX][0-9a-fA-F]+)|(?:0[oO][0-7]+)|(?:0[bB][01]+)|(?:\d+\.\d*(?:[eE][+-]?\d+)?)|(?:\.\d+(?:[eE][+-]?\d+)?)|(?:\d+(?:[eE][+-]?\d+)?))$/;
return re.test(txt);
}
isNumberLiteral("42"); // true
isNumberLiteral("-42"); // false
@rcstr
rcstr / fixed.html
Last active December 20, 2015 22:18
<fixed> example
<fixed position="top">
<nav>
<ul>
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">4</a></li>
<li><a href="#">4</a></li>
</ul>
</nav>
</fixed>