Skip to content

Instantly share code, notes, and snippets.

View BideoWego's full-sized avatar
:octocat:
Yarp

BideoWego BideoWego

:octocat:
Yarp
View GitHub Profile
@BideoWego
BideoWego / us_states.json
Last active April 19, 2017 13:55
The 50 States of the USA in JSON
[
{ "name": "Alabama" },
{ "name": "Alaska" },
{ "name": "Arizona" },
{ "name": "Arkansas" },
{ "name": "California" },
{ "name": "Colorado" },
{ "name": "Connecticut" },
{ "name": "Delaware" },
{ "name": "Florida" },
@BideoWego
BideoWego / helpers.url.index.js
Created April 16, 2017 07:37
Code for recursively requiring helpers and allows extending them
// Requires the `qs` package
var qs = require('qs');
var path = require('path');
var url = require('url');
module.exports = (helpers) => {
helpers.registerDirectory('url/', (helper) => {
Object.keys(helper).forEach((key) => {
@BideoWego
BideoWego / spec_helper.js
Created April 7, 2017 22:03
Jasmine Node `beforeAll`
var SpecHelper = {};
var _flags = {
didRun: {}
};
@BideoWego
BideoWego / flash_helper.js
Last active April 12, 2017 16:05
Express view helpers loader. Loads all modules in folder and registers all functions on every module under `Helpers.registered`
var FlashHelper = {};
FlashHelper.bootstrapAlertClassFor = function(key) {
return {
"error": "danger",
"alert": "danger",
"notice": "info"
}[key] || key;
};
@BideoWego
BideoWego / assessment_js_ii_notes.md
Last active September 20, 2016 20:06
JS II Assessment Do's and Don'ts

assessment_js_ii_notes

Questions

  1. How can you include an init function in your module and why is it useful?
@BideoWego
BideoWego / edge_list.rb
Created July 13, 2016 15:39
Create an edge list with weights
# Creates an Edge List of People
# e.g. [ [Person1, Person2, weight],
# [Person4, Person8, weight],
# ... ]
require 'pry-byebug'
Person = Struct.new(:id, :name)
NAMES = [
"Harry", "Sally", "Sam", "Michael", "Michelle", "Alok", "Dan", "Nick", "Olga", "Alice", "Joseph", "Donald", "Garrett", "Xin", "Mike", "Adam", "Peter", "Andur", "Tom", "Boris"
@BideoWego
BideoWego / Searchable.rb
Last active July 9, 2018 07:13
Model Searchable concern for Rails
module Searchable
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
@@searchable_fields = []
@@searchable_scope = nil
def search(q, method=nil)
@BideoWego
BideoWego / FlashService.js
Last active April 7, 2016 06:44
Angular flash message alert service and directive with Rails style alert type names and a Bootstrap template
// ----------------------------------------
// FlashService
// ----------------------------------------
// Usage:
// 1. Inject FlashService into your controller
// 2. Bind to $scope
// $scope.flash = FlashService;
// or
// Use internally as FlashService
// 3. Use in your view or controller
@BideoWego
BideoWego / Pro.terminal.xml
Last active March 28, 2016 20:14
My Terminal Profile Preferences
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BackgroundBlur</key>
<real>0.0</real>
<key>BackgroundColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OV05TV2hpdGVcTlNDb2xvclNwYWNlViRjbGFzc00w
@BideoWego
BideoWego / JavaScript-Dos-and-Donts.js
Last active March 24, 2016 00:38
A list of JavaScript gotchas and best practices mostly dealing with the MVC and Module pattern
// --------------------------------------------------
// JavaScript Do's and Dont's
// --------------------------------------------------
//
// This is a list of gotchas and best practices
// mostly dealing with the MVC and Module pattern
//