Skip to content

Instantly share code, notes, and snippets.

View ADelRosarioH's full-sized avatar
:octocat:
I may be slow to respond.

Anthony Del Rosario ADelRosarioH

:octocat:
I may be slow to respond.
View GitHub Profile
// trying to confuse my mind (and i think i made it jeje!)
(function(moom){
moom('moom');
moom.moomoom = function(moom){
return moom(moom);
};
moom.moomoom(function(moom){
moom(function(){
console.log('moom');
// lastMod.js
module.exports = exports = function lastModifiedPlugin (schema, options) {
schema.add({ lastMod: Date })
schema.pre('save', function (next) {
this.lastMod = new Date
next()
})
if (options && options.index) {
/**
* Created with JetBrains WebStorm.
* User: ynonperek
* Date: 1/28/13
* Time: 9:14 PM
*
* Mongoose plugin that adds a hashed password field
*/
var bcrypt = require('bcrypt');
@ADelRosarioH
ADelRosarioH / random digits
Created May 22, 2014 19:25
Generate random digits
public string digits()
{
var bytes = new byte[4];
var rng = RandomNumberGenerator.Create();
rng.GetBytes(bytes);
uint random = BitConverter.ToUInt32(bytes, 0) % 100000000;
return String.Format("{0:D8}", random);
}
@ADelRosarioH
ADelRosarioH / Mapper.cs
Created April 28, 2015 13:45
Simple Object to Object Mapper.
public sealed class Mapper
{
public delegate void Rule<F, T>(F from, T to)
where F : class
where T : class;
public static T Map<F, T>(F primary, params Rule<F, T>[] rules)
where F : class
where T : class
{
@ADelRosarioH
ADelRosarioH / Transverser.apxc
Created May 12, 2016 14:59
Takes a list object and apply the specified filters and returns a result
public class Transverser {
private String rawJson;
private Object parsedJson;
private final String PATH_TOKEN = '/';
private final String FILTER_START_TOKEN = '[';
private final String FILTER_END_TOKEN = ']';
private final String COMBO_START_TOKEN = '(';
private final String COMBO_END_TOKEN = ')';
``THE ROBOT AND THE BABY''
A story by John McCarthy
``Mistress, your baby is doing poorly. He needs your attention.''
``Stop bothering me, you fucking robot.''
``Mistress, the baby won't eat. If he doesn't get some human love, the Internet pediatrics book says he will die.''
``Love the fucking baby, yourself.''
function stepsToPosition(a, b){
var limit = 1000;
var steps = 0;
var o = {};
var x = 0, y = 0;
var moves = 3;
for(var i = 0; i < limit; i++) {
var r = (x < a) ? (x + 2 < a ? 2 : 1) : 1;
@ADelRosarioH
ADelRosarioH / GetAllPRofiles.java
Last active January 12, 2017 18:41
Select all profiles that have access to an sobject in salesforce
List<ObjectPermissions> permissionSetAssignmentIds = [SELECT ParentId
FROM ObjectPermissions
WHERE
PermissionsCreate = True AND
PermissionsRead = True AND
PermissionsEdit = True AND
PermissionsDelete = False AND
PermissionsViewAllRecords = False AND
PermissionsModifyAllRecords = False AND
function toggleClass(elemenet, className){
var classList = elemenet.className.split(' ');
var indexOfClassName = classList.indexOf(className);
if(indexOfClassName > -1) classList.splice(indexOfClassName, 1);
else classList.push(className);
elemenet.className = classList instanceof Array ? classList.join(' ') : classList;
}