Skip to content

Instantly share code, notes, and snippets.

@chrise86
chrise86 / carrierwave.rb
Created September 8, 2016 15:55 — forked from iqbalhasnan/carrierwave.rb
carrierwave mini_magick image processing - quality, strip, exif rotation, gaussian blur, interlace
#config/initializers/carrierwave.rb
module CarrierWave
module MiniMagick
# Rotates the image based on the EXIF Orientation
def exif_rotation
manipulate! do |img|
img.auto_orient
img = yield(img) if block_given?
img
end
@chrise86
chrise86 / DropZone.jsx
Created August 20, 2016 17:35 — forked from pizzarob/01_DropZone.jsx
HTML5 Drag and Drop React Component
import React, {PropTypes} from 'react';
import classNames from 'classnames';
class BatchDropZone extends React.Component {
static propTypes = {
// function that recieves an array of files
receiveFiles: PropTypes.func.isRequired,

Keybase proof

I hereby claim:

  • I am chrise86 on github.
  • I am chrisedwards (https://keybase.io/chrisedwards) on keybase.
  • I have a public key whose fingerprint is 5D2F 502D 07D4 F2E2 1CD1 10AA C8CB 36A0 219B 6E85

To claim this, I am signing this object:

// transform cropper dataURI output to a Blob which Dropzone accepts
function dataURItoBlob(dataURI) {
var byteString = atob(dataURI.split(',')[1]);
var ab = new ArrayBuffer(byteString.length);
var ia = new Uint8Array(ab);
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
return new Blob([ab], { type: 'image/jpeg' });
}
@chrise86
chrise86 / contactform.js
Created October 16, 2015 20:56 — forked from insin/contactform.js
React contact form example
/** @jsx React.DOM */
var STATES = [
'AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI',
'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS',
'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR',
'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY'
]
var Example = React.createClass({
@chrise86
chrise86 / Much much simpler option selector for Shopify
Last active September 3, 2015 08:53 — forked from zakhardage/Much much simpler option selector for Shopify
Much simpler version of Shopify's option_selection.js for separating product options into their own dropdown menus.
<form action="/cart/add" method="post">
{% if product.variants.size > 1 %}
{% if product.options[0] %}
{% assign used = '' %}
<label for="select-one">{{ product.options[0] }}</label>
<select id='select-one' onchange="letsDoThis()">
{% for variant in product.variants %}
{% unless used contains variant.option1 %}
<option value="{{ variant.option1 }}">{{ variant.option1 }}</option>
{% capture used %}{{ used }} {{ variant.option1 }}{% endcapture %}
@chrise86
chrise86 / custom_event
Last active August 29, 2015 14:27 — forked from frequent/custom_event
Custom Event handler for IE8+
var util = {};
/**
* IE8 compatible custom event listener
* @method listenToCustomEvents
* @param {string} eventName Event to listen for
* @param {method} callback Method to run on event
*/
util.listenToCustomEvents = function (event_name, callback) {
if (document.addEventListener) {
@chrise86
chrise86 / search.html.haml
Last active August 29, 2015 14:27 — forked from kurioscreative/search.html.haml
Geocoder: Over query limit Javascript Fix
= form_tag :search, method: :get, id:'search' do |f|
= text_field_tag :q, '', placeholder:'City, address, or zip code'
= hidden_field_tag :c, ''
= submit_tag "Go"
require 'uri'
require 'net/http'
class RedirectResolver
def self.resolve(uri)
uri_input = uri
if uri.is_a? String
uri = URI.parse(uri)
end
@chrise86
chrise86 / .powenv
Last active August 29, 2015 14:25 — forked from dre1080/.powenv
# In your app's root.
# Make Pow!! export all the env variables contained in the .env file used by Foreman.
export $(cat .env)