Skip to content

Instantly share code, notes, and snippets.

View SinisterMinister's full-sized avatar

Codey Whitt SinisterMinister

  • VisualGuruz
  • Remote
View GitHub Profile
api.find = function (model, options, conditions) {
console.info(options); // {limit: 1}
return new RSVP.Promise(function (resolve, reject) {
console.info(options); // undefined WTF?!
var options = options || {},
defaults = {
limit: null,
offset: null,
orderBy: null,
direction: null
@SinisterMinister
SinisterMinister / curry.js
Last active December 22, 2015 13:28
Flexible for currying a function.
/**
* Helper for currying a function.
*
* ### Usage
*
* ```javascript
* // Some function you want to partially apply
* function someFunc(a, b, c, d) {return arguments;}
*
* // Curry the function
var user = ORM.factory('user');
user.where(function (user) {
user.where('id').between(1, 10);
}).orWhere(function (user) {
user.where('id').between(100, 200);
}).orWhere({
active: true,
banned: false
}).findAll();
@SinisterMinister
SinisterMinister / awesomeorm.js
Last active December 20, 2015 02:49
WIP of figuring out the interface
/**
* This is a WIP of potential usage of the ORM in a NodeJS implementation. Let's try implementing
* this as a module for other parts of the app to use. Less instantiation for later
*/
var ORM = require('awesomeorm-base'),
repository = require('awesomeorm-repository-rest')('http://rest.example.com/schema'),
dataParser = require('awesomeorm-data-jsonapi'),
modelBuilder = require('awesomeorm-model-encasulated');
/*!
* jQuery JavaScript Library v1.4.1
* http://jquery.com/
*
* Copyright 2010, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Includes Sizzle.js
* http://sizzlejs.com/
alert('Oh snap!');
@SinisterMinister
SinisterMinister / q.md
Last active November 12, 2018 06:33
JS Interview questions

Javascript Interview Questions

General interview questions for a front-end JS developer.

Questions

  • What is the spec Javascript implements and what versions of it are you most current with?

  • Does JavaScript support the use of classes?

Unit Tests
Internal Caching
✓ Should throw an exception when trying to get a key that doesn't exist
✓ Should set and retrieve a key from the cache
✓ Should delete a key from the cache
Helpers
hasTagType()
✓ Should return the index of an array where a tag type exists
✓ Should return false if the type is not found
mergeTagsWithDefault()
/**
* Gets the dependent keys of the computed proerpty
* @return {array} Array of dependent keys
*/
ComputedPropertyPrototype.getDependentKeys = function() {
// Create a new container to pass by value
var newArray = [];
// Add the keys to the container
for (var i = this._dependentKeys.length - 1; i >= 0; i--) {
@SinisterMinister
SinisterMinister / homework.md
Last active December 18, 2015 08:59
Marty's Homework

Marty's Homework

Classes and Objects: Lesson 1

Instructions

Make answers to the following problems below using PHP. For now, you can psuedocode the methods with comments, or you can create your own implementations if you feel adventurous. Use any resources you like. Also, one thing I forgot to mention in your lesson: there is a naming convention for things in classes. If a name starts with a single