Skip to content

Instantly share code, notes, and snippets.

#commit models
class Commit < ActiveRecord::Base
attr_accessible :commit_url, :author, :commit_message
set_inheritance_column :provider
end
class GithubCommit < Commit
end
#story model
class Story < ActiveRecord::Base
@skinnyjames
skinnyjames / application-errors.js
Last active January 6, 2017 02:11
Custom Error Handling in Node with Promises
module.exports = {
ValidationError: class extends Error{
constructor(message){
super(message || "This input is invalid")
}
},
DatabaseError: class extends Error {
constructor(message){
super(message || "The database call failed")
}
@skinnyjames
skinnyjames / model.js
Created January 7, 2017 21:08
validator.js
validator = new Validator({
presence: ['address', 'email', 'password', 'password_confirmation'],
regex: {
email: '[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}'
},
length: {
password: '> 10',
password_confirmation: '> 10'
},
custom: [
@skinnyjames
skinnyjames / app.elm
Last active July 24, 2017 14:01
Elm Subs
main =
Navigation.program Types.UrlChange
{ init = Update.init
, view = Views.view
, update = Update.update
, subscriptions = subscriptions
}
-- Subscriptions
@skinnyjames
skinnyjames / Main.elm
Last active August 2, 2017 12:46
Lightbox
import Html exposing (..)
import Html.Attributes as Attr
import Html.Events as Evt exposing (onClick)
import Html.Events.Extra as Evte
import Html.Keyed as Keyed
import Material
{- Program -}
main =
Html.program
@skinnyjames
skinnyjames / Lightbox.elm
Last active October 6, 2017 05:30
Lightbox.elm
import Html exposing (..)
import Html.Attributes as Attr
import Html.Events exposing (onClick)
main =
Html.program
{ init = (initialModel, Cmd.none)
, view = view
, update = update
$(document.ready(){
$('add-button').click(function(e){
$('ingredients-div-form-inputs').append('<input type="text" name="ingredients[]">')
})
})
var email = require('email-anonymizer')({
domain: 'xyz.com',
})
email.send({
'from': 'seangregory@protonmail.com',
'to': 'seanchristophergregory@gmail.com',
'body': 'hello world'
})
.then((response) => {
@skinnyjames
skinnyjames / test.php
Last active June 14, 2018 01:01
php aggregate
$new_array = array();
foreach($array as $vehicle_id) {
if(isset($new_array[$vechicle_id])) {
$new_array[$vehicle_id] += 1;
} else {
$new_array[$vehicle_id] = 1;
}
}
function sum($carry, $vehicle_id) {
@skinnyjames
skinnyjames / riding-for-the-feeling.js
Created July 5, 2019 18:19
Riding for the Feeling - original song by Bill Callahan
// It's never easy to say goodbye
var goodbye = function(){
// to the faces
let to = function(faces=[]){
if( faces && Array.isArray(faces) && faces.length > 1 ) {