Skip to content

Instantly share code, notes, and snippets.

View charlieschwabacher's full-sized avatar

Charlie Schwabacher charlieschwabacher

  • San Francisco Bay Area
View GitHub Profile
@charlieschwabacher
charlieschwabacher / server.js
Created July 3, 2016 22:47
corss origin server.js for blogs example
import express from 'express';
import importAll from 'import-all';
import gestaltServer from 'gestalt-server';
import gestaltPostgres from 'gestalt-postgres';
import cors from 'cors';
const apiApp = express();
apiApp.use(cors({
origin: 'http://localhost:3000',
credentials: true,
# setup variables
$window = $ window
$section = $ '.tour-section'
$intro = $ '.tour-intro'
adjustWindow = ->
winH = $window.height()
win2 = winH * 2
@charlieschwabacher
charlieschwabacher / gist:b8db8e3fb666c3c15d66
Created September 29, 2014 08:23
immutable data model in coffee script
module.exports = (inputData, onChange, historySize = 100) ->
data = inputData
undos = []
redos = []
class Cursor
constructor: (@path = []) ->
cursor: (path = []) ->
/* mock placeholder on required inputs type month */
input[type=month],
input[type=date],
input[type=time]
&[required]:invalid
&:after
content: attr(placeholder)
color: #d8d8d8
position: absolute
left: $margin/2
@charlieschwabacher
charlieschwabacher / gist:8360182
Created January 10, 2014 18:46
cors middleware
# This middleware allows cross origin remote API requests, using either JSONP or CORS.
#
# JSONP requests are modified before being passed on to the wrapped application in order
# to allow responses to have a unified format. JSONP is served when a jsonp=true get
# parameter is included in a http GET request. The middleware will update the method of
# these requests based on a 'method' parameter before passing them on. For POST and PUT
# requests, the request content will be updated based on the 'data' get parameter. For all
# JSONP requests, get parameters used by the middleware will be removed before the request
# is passed on. The response recieved from the wrapped application will then be wrapped
# in a callback function named with the 'callback' parameter from the original request, and
@charlieschwabacher
charlieschwabacher / gist:2885591
Created June 6, 2012 23:59
Proposed module to sanitize and escape attributes
module SanitizeAttributes
#override setters of some string or text attributes to sanitize w/ Sanitize.clean before setting
def sanitize_attribute(attribute)
self.send(:define_method, "#{attribute}=") do |arg|
self[attribute] = Sanitize.clean arg
end
end
def sanitize_attributes(*attributes)
@charlieschwabacher
charlieschwabacher / gist:1096850
Created July 21, 2011 09:31
Javascript string presentation methods with underscore.js (upper, lower, capitalize, title)
String.prototype.upper = function() {
return _.reduce(this.split(""), function(memo, chr) { return memo + chr.toUpperCase() }, "")
}
String.prototype.lower = function() {
return _.reduce(this.split(""), function(memo, chr) { return memo + chr.toLowerCase() }, "")
}
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
String.prototype.title = function() {
@charlieschwabacher
charlieschwabacher / mixins.scss
Created July 21, 2011 07:41
SCSS mixins for cross browser CSS3 border-radius, transition, gradient, and box shadow
//Cross browser CSS3 mixins
@mixin box-shadow($left, $top, $radius, $color) {
box-shadow: $left $top $radius $color;
-webkit-box-shadow: $left $top $radius $color;
-moz-box-shadow: $left $top $radius $color;
}
@mixin transition($property, $duration, $easing: linear) {
transition: $property $duration $easing;