Skip to content

Instantly share code, notes, and snippets.

View richhollis's full-sized avatar

Richard Hollis richhollis

View GitHub Profile
@richhollis
richhollis / response.html
Created January 10, 2017 12:30
RubyMoney/google_currency captcha html response
<!DOCTYPE html>
<html>
<head>
<script>
(function(){(function(){function e(a){this.t={};this.tick=function(a,c,b){var d=void 0!=b?b:(new Date).getTime();this.t[a]=[d,c];if(void 0==b)try{window.console.timeStamp("CSI/"+a)}catch(h){}};this.tick("start",null,a)}var a,d;window.performance&&(d=(a=window.performance.timing)&&a.responseStart);var f=0<d?new e(d):new e;window.jstiming={Timer:e,load:f};if(a){var c=a.navigationStart;0<c&&d>=c&&(window.jstiming.srt=d-c)}if(a){var b=window.jstiming.load;0<c&&d>=c&&(b.tick("_wtsrt",void 0,c),b.tick("wtsrt_","_wtsrt",
d),b.tick("tbsd_","wtsrt_"))}try{a=null,window.chrome&&window.chrome.csi&&(a=Math.floor(window.chrome.csi().pageT),b&&0<c&&(b.tick("_tbnd",void 0,window.chrome.csi().startE),b.tick("tbnd_","_tbnd",c))),null==a&&window.gtbExternal&&(a=window.gtbExternal.pageT()),null==a&&window.external&&(a=window.external.pageT,b&&0<c&&(b.tick("_tbnd",void 0,window.external.startE),b.tick("tbnd_","_tbnd",c))),a&&(window.jstiming.pt=a)}catch(g){}})();}).call(this);
</script
@richhollis
richhollis / add_user_name_to_users.rb
Last active May 9, 2020 07:26
Rails 4.2.5.1 and Devise 3.5.6 using attr_encrypted with email attribute encrypted and username clear text
class AddUserNameForAuthenticationToUsers < ActiveRecord::Migration
def up
add_column :users, :username, :string, null: false, default: ""
add_index :users, :username, unique: true
add_column :users, :encrypted_email, :string
remove_column :users, :email, :string
add_index :users, :encrypted_email
end
def down
remove_column :users, :username
@richhollis
richhollis / letsencrypt.md
Created February 1, 2016 12:41 — forked from xrstf/letsencrypt.md
Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

This document details how I setup LE on my server. Firstly, install the client as described on http://letsencrypt.readthedocs.org/en/latest/using.html and make sure you can execute it. I put it in /root/letsencrypt.

As it is not possible to change the ports used for the standalone authenticator and I already have a nginx running on port 80/443, I opted to use the webroot method for each of my domains (note that LE does not issue wildcard certificates by design, so you probably want to get a cert for www.example.com and example.com).

Configuration

For this, I placed config files into etc/letsencrypt/configs, named after <domain>.conf. The files are simple:

@richhollis
richhollis / application.rb
Created January 8, 2016 18:00 — forked from averyvery/application.rb
Inline CSS or JS in Rails
config.assets.precompile += [
# precompile any CSS or JS file that doesn't start with _
/(^inline[^_\/]|\/[^_])[^\/]*.(js|css)$/,
...
@richhollis
richhollis / .fonts.conf
Last active August 29, 2015 14:08 — forked from silv3rm00n/.fonts.conf
Fix rspec and capybara errors
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!--
Documented at
http://linux.die.net/man/5/fonts-conf
To check font mapping run the command at terminal
$ fc-match 'helvetica Neue'

Setting up a PositiveSSL Wildcard Certificate from Comodo for Apache with Trusted by Microsoft and Firefox

This gist was greatly helped by the direction in this gist:

https://gist.github.com/bradmontgomery/6487319

Examine your certificate in the browser (Chrome):

  • Click on the padlock
  • Click Connection
1033edge.com
11mail.com
123.com
123box.net
123india.com
123mail.cl
123qwe.co.uk
150ml.com
15meg4free.com
163.com
@richhollis
richhollis / cors_middleware.rb
Last active August 16, 2017 20:33
CorsMiddleware which can be useful for testing SwaggerUI resources in development
class CorsMiddleware
def initialize(app)
@app = app
end
def call(env)
default_headers = {
'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Methods' => 'GET, POST, DELETE, PUT, PATCH, OPTIONS',
'Access-Control-Allow-Headers' => 'Content-Type, api_key, Authorization, origin'
@richhollis
richhollis / gist:4185765d817b106c3aab
Created August 29, 2014 16:25
Test backbone pubSub event triggers call their expected functions in jasmine spec
class BackbonePubSub
@verifyEvent: (klass, name, methodName, callMethod = "registerEvents") ->
match = false
oldFn = Backbone.pubSub.on # get existing pubSub.on method
class KlassNoConstructor extends klass # extend original class so we can disable constructor
constructor: -> # zap the constructor of the target class
instance = new KlassNoConstructor
Backbone.pubSub.on = (triggerName, method) ->
match = true if triggerName == name and method == instance[methodName] # are we triggering on the right method?