Skip to content

Instantly share code, notes, and snippets.

View nhc's full-sized avatar

Neil Charlton nhc

View GitHub Profile
@vktr
vktr / rule.js
Created February 10, 2018 18:54
Add Stripe Customer Id to Auth0 via custom rule
function (user, context, callback) {
user.app_metadata = user.app_metadata || {};
if ('stripe_customer_id' in user.app_metadata) {
context.idToken['https://example.com/stripe_customer_id'] = user.app_metadata.stripe_customer_id;
return callback(null, user, context);
}
var stripe = require('stripe')('sk_....');
var customer = {
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@AlexPashley
AlexPashley / mixins.scss
Created July 5, 2013 14:44
SASS: Mixins for CSS
/* MIXINs */
@mixin transition( $val : ease 0.5s ) {
-webkit-transition: $val;
-moz-transition:$val;
-o-transition:$val;
-ms-transition:$val;
transition:$val;
}
@mixin text-shadow( $top: 3px, $left: 3px, $blur: 3px , $colour: #333 ) {
@nhc
nhc / paperclip_conditional_resize.rb
Last active December 17, 2015 13:58
For when you don't have imagemagick on your development machine for whatever reason. This goes in your rails model and only applies styles if your in the Production environment. Also uses some stored S3 credentials for AWS S3 storage.
class ModelName < ActiveRecord::Base
has_attached_file :avatar, :styles => lambda { |attachment| ( Rails.env.production? ) ? { :medium => "104x104", :small => "60x60" } : {} }, :storage => :s3, :s3_credentials => "#{Rails.root}/config/s3.yml", :path => "/:style/:id/:filename"
end
@jkudish
jkudish / gist:1338692
Created November 4, 2011 05:02
THIS FILE EXPLAINS HOW TO USE THE sld_register_taxonomy() FUNCTION
<?php
// THIS FILE EXPLAINS HOW TO USE THE sld_register_taxonomy() FUNCTION FROM THE FOLLOWING WP PLUGIN: https://github.com/jkudish/sld-custom-content-and-taxonomies
/**
* sld_register_taxonomy()
* @param $taxonomy_slug the slug of the taxonomy to register
* @param $post_types, the post types that use this taxonomy
* @param $optional_singular_name, the singular name for this post type
* @param $optional_args can be passed all of the same arguments as register_taxonomy()
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')