Skip to content

Instantly share code, notes, and snippets.

View yamadapc's full-sized avatar
🎼

Pedro Tacla Yamada yamadapc

🎼
View GitHub Profile
@yamadapc
yamadapc / annoying-renzo.py
Last active December 31, 2015 09:09
v0.0.1 Codename Renzo
# v0.0.1 Codename Renzo
from random import randint
import sys
import os
def say_dyslexic(msgs):
for msg in msgs: os.system("say -r " + str(randint(0, 300)) + " " + msg)
def intro():
for i in range(5): say_dyslexic(["o", "renzoo"])
@yamadapc
yamadapc / roman2decimal.js
Last active January 3, 2016 07:19
roman2decimal
'use strict';
module.exports = function(roman) {
var roman_array = roman.split('');
var dec_array = roman_array.map(function(roman_alg) {
return ROMAN_MAP[roman_alg];
});
var same = 1;
'use strict';
module.exports = function toUnderscore(s) {
return (s.charAt(0) + s.slice(1).replace(/[A-Z]/g, '-$&')).toLowerCase()
}
var mongoose = require('mongoose');
var native = mongoose.Document.prototype.toObject;
module.exports = function(schema/* options [could make it safer :)]*/) {
schema.methods.toObject = function() {
var _this = this;
var obj = mongoose.Document.prototype.toObject.apply(this, arguments);
var extraneous = Object.keys(this).filter(function(key) {
'use strict';
var escapedCharsRegExp = /([.?*+^$[\]\\(){}|-])/g;
function escapeRegExp(str) {
return str && str.replace && str.replace(escapedCharsRegExp, '\\$1');
}
function safeRegExp(str) {
return new RegExp(escapeRegExp(str));
}
var Promise = require('bluebird');
_ = require('lodash');
/**
* Map an object, or a promise of an object, with the given `mapper` function
* with the signature `(value, key, obj)` where `value` is an object's `key`
* property's value.
*
* If the `mapper` function returns promises or thenables, the returned promise
* will wait for all the mapped results to be resolved as well.
function a_id(){r='';s=arguments[0];for($=++[[]][+[]]-1;$<s.length*(++[[]][+[]]);$+=++[[]][+[]])r+=s[$];return r.split('');}
'use strict';
var mongoose = require('mongoose'),
Promise = require('bluebird');
mongoose.connect('mongodb://localhost/test');
var SomethingSchema = new mongoose.Schema({
name: String
});
@yamadapc
yamadapc / playing-with-stylus.styl
Last active August 29, 2015 13:57
I'm just playing with stylus; it's funny markup is the kind of thing which *should* be as dynamic as possible :P
/**
* Sets a selector to a variable.
*
* @example
*
* font-size-h1 = 10px
* from-variable(h1, font-size)
*
* would yield:
*
@yamadapc
yamadapc / tabularize-pretty-colon.vim
Created March 28, 2014 17:12
Tabularize pretty ":"
vnoremap <leader><leader>; :Tabularize/:\zs/l1r0