Skip to content

Instantly share code, notes, and snippets.

@cooljl31
cooljl31 / gist:ff562b533edc22e44f53fcf40f6d56c4
Created March 26, 2018 09:51 — forked from mattconnolly/gist:4158961
RSpec basic authentication helper module for request and controller specs
module AuthHelper
def http_login
user = 'username'
pw = 'password'
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user,pw)
end
end
module AuthRequestHelper
#
@cooljl31
cooljl31 / server_configuration.md
Last active March 15, 2018 13:46 — forked from ttp/server_configuration.md
New Ubuntu server configuration nginx, ruby, passenger, postgresql, php, wordpress, mysql

Locale fix

sudo vim /etc/default/locale

LANGUAGE=en_US.UTF-8
LANG=en_US.UTF-8
LC_TYPE=en_US.UTF-8
LC_ALL=en_US.UTF-8

reconfigure locales

@cooljl31
cooljl31 / ckeditor-responsive-images.js
Created February 27, 2018 18:46 — forked from fabiomaggio/ckeditor-responsive-images.js
Make inserted images in CKEditor automatically responsive
// If you want inserted images in a CKEditor to be responsive
// you can use the following code. It creates a htmlfilter for the
// image tag that replaces inline "width" and "style" definitions with
// their corresponding attributes and add's (in this example) the
// Bootstrap "img-responsive" class.
CKEDITOR.on('instanceReady', function (ev) {
ev.editor.dataProcessor.htmlFilter.addRules( {
elements : {
img: function( el ) {
// Add bootstrap "img-responsive" class to each inserted image
@cooljl31
cooljl31 / gulpfile-express.js
Created February 20, 2018 13:32 — forked from mollerse/gulpfile-express.js
Gulpfile for livereload + static server
var gulp = require('gulp'),
sass = require('gulp-sass'),
browserify = require('gulp-browserify'),
concat = require('gulp-concat'),
embedlr = require('gulp-embedlr'),
refresh = require('gulp-livereload'),
lrserver = require('tiny-lr')(),
express = require('express'),
livereload = require('connect-livereload')
livereloadport = 35729,
@cooljl31
cooljl31 / common-media-queries.css
Created February 7, 2018 22:13
Common Media Queries
/* This is a small sampling of the various approaches to media queries. The
point is: they're all over the board. Part of the "issue" (if you can call
it that) may be due to the intended audience of each site/framework. Another
may be that it's really difficult to test for a lot of different devices.
Regardless, it would be really nice if there was standard baseline that
could be used as a starting point for maximum compatibility and coverage. */
/* ==========================================================================
Frameworks
========================================================================== */
@cooljl31
cooljl31 / _typography.scss
Created January 16, 2018 12:53 — forked from mikedidthis/_typography.scss
A More Modern Scale for Web Typography - With REMS
// Modern Scale for Web Typography
// Ref: http://typecast.com/blog/a-more-modern-scale-for-web-typography
// -----------------------------------------------------------------------------
// Mobile
// -----------------------------------------------------------------------------
// Elem | Font | Line
// -----------------------------------------------------------------------------
// Body | 16px | 20px
// h1 | 32px | 40px
// h2 | 26px | 30px
@cooljl31
cooljl31 / blur.css
Created December 29, 2017 21:31 — forked from vishaltelangre/blur.css
cross browser blur filter using css
.blur {
-webkit-filter: blur(3px);
-moz-filter: blur(3px);
-ms-filter: blur(3px);
-o-filter: blur(3px);
/* FF doesn't support blur filter, but SVG */
filter: url("data:image/svg+xml;utf8,<svg height='0' xmlns='http://www.w3.org/2000/svg'><filter id='svgBlur' x='-5%' y='-5%' width='110%' height='110%'><feGaussianBlur in='SourceGraphic' stdDeviation='5'/></filter></svg>#svgBlur");
filter: progid: DXImageTransform.Microsoft.Blur(PixelRadius = '3');
filter: blur(3px);
}
@cooljl31
cooljl31 / 00_OSX_Docker_Machine_Setup.md
Created October 16, 2017 05:52 — forked from bitjockey42/00_OSX_Docker_Machine_Setup.md
Use native virtualization on OS X docker with xhyve

What this?

So one of the painful points of using docker on OS X is that you need to run a virtualbox VM, which often suffers from performance issues. With xhyve, a OS X virtualization system, and docker-machine-xhyve you can now have docker use the native OS X hypervisor to run containers.

No more dealing with virtualbox shenanigans!

In this script, I've also set up a way to autoconfigure terminal sessions to load docker's environment vars (dependent on docker-machine) so you do not have to run eval $(docker-machine env whatever) every time you open a new terminal window.

Requirements

@cooljl31
cooljl31 / factories.rake
Created September 13, 2017 12:15 — forked from kurbmedia/factories.rake
Generates FactoryGirl factories.rb from the database tables/columns
namespace :factories do
task :generate => :environment do
# Make a new factory file, moving the old one to factories_old.rb if one exists.
factory_file = "#{Rails.root}/spec/factories"
FileUtils.mv("#{factory_file}.rb", "#{factory_file}_old.rb") if File.exists?("#{factory_file}.rb")
fixture_file = File.open("#{factory_file}.rb", 'w') do |file|
@cooljl31
cooljl31 / gist:168ca1f7d0fac5aba7424bdeaf06c3d9
Created September 13, 2017 07:48 — forked from tobyhede/gist:3179978
Ruby/Rails date format cheat sheet
From http://linux.die.net/man/3/strftime
%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%e - Day of the month without leading 0 (1..31)
%g - Year in YY (00-99)