Skip to content

Instantly share code, notes, and snippets.

View benpolinsky's full-sized avatar
🏠
Working

Ben Polinsky benpolinsky

🏠
Working
View GitHub Profile
@benpolinsky
benpolinsky / TypeScriptAssetWithErrors.ts
Last active August 12, 2022 16:19
this is a really quick way of gaining ts error reporting with parcel
const Asset = require('parcel/src/Asset');
const chalk = require('chalk')
const ts = require('typescript')
const path = require('path');
const localRequire = require('parcel/src/utils/localRequire')
class TypeScriptAssetWithError extends Asset {
constructor(name, options) {
super(name, options);
this.type = 'js';
@benpolinsky
benpolinsky / index.js
Created August 19, 2017 14:06
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
alert('hello');
# Not thoroughly tested, but this seems to solve the problem recursively
class ChangeMaker
# in cents, so the below ints are equal to
# penny, nickle, dime, quarter, dollar, five, ten, twenty, fifty, a hundred
DENOMINATIONS = [1, 5, 10, 25, 100, 500, 1000, 2000, 5000, 10000]
def initialize(cost, tendered)
@benpolinsky
benpolinsky / gist:67e776a5ab9a7062b777
Last active August 29, 2015 14:18
1st refactor of devise identity management
# refactoring of Kam Low's ::find_for_oauth
# Thanks so much for this article about managing multiple providers with omniauth
# Check it out: http://sourcey.com/rails-4-omniauth-using-devise-with-twitter-facebook-and-linkedin/
def self.find_for_oauth(auth, signed_in_resource = nil)
identity = Identity.find_for_oauth(auth)
user = signed_in_resource ? signed_in_resource : identity.user
user = find_for_oauth_email(auth) || create_for_oauth(auth) if user.nil?
update_identity(identity, user)
user
@benpolinsky
benpolinsky / gist:84cba7b845c8e7dd6b54
Created February 23, 2015 01:24
Quick and Dirty Rails Style HTML Tag Helpers
<?php
/*
*
* link_to(url, text, options)
* url and text are strings, options is an object with any additional attributes you might want on a link
* Simple. Rustic, yeah? | Use it like this:
* link_to('http://www.google.com', "Google", object ["id" => "user_link_132930482", "class" => "my_link", "alt" => "alt-text"]);
*
*/