Skip to content

Instantly share code, notes, and snippets.

View jakcharlton's full-sized avatar

Jak Charlton jakcharlton

View GitHub Profile
@jakcharlton
jakcharlton / getParameterByName
Last active August 29, 2015 14:05
Get the LeadMachine ID from the query string
<script type="text/javascript">
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
var lead_id = getParameterByName('lead_id');
</script>
@jakcharlton
jakcharlton / wufoo-embed.js
Last active August 29, 2015 14:05
Wufoo form embed code
<script type="text/javascript">var m7x3w7;(function(d, t) { var s = d.createElement(t), options = { 'userName':'username', 'formHash':'m7x3w7', 'autoResize':true, 'height':'234',
// NOTE: This is the line we are adding to the default snippet.
'defaultValues':'field13=' + lead_id,
'async':true,
'header':'show'};
s.src = ('https:' == d.location.protocol ? 'https://' : 'http://') + 'wufoo.com/scripts/embed/form.js';
s.onload = s.onreadystatechange = function() { var rs = this.readyState; if (rs) if (rs != 'complete') if (rs !=
@jakcharlton
jakcharlton / README.md
Last active September 18, 2015 21:07 — forked from davemo/README.md
Pre commit git hook to stop dumb checkins

Git pre-commit Hooks

The pre-commit file listed here is setup to scan files for invalid keywords prior to commit to avoid debug or logging information making its way into production files.

Setup to scan .js, .coffee, .rb, .erb files for 'debugger' or 'binding.pry'

Installing the Hook

  • cp pre-commit .git/hooks/
  • chmod +x .git/hooks/pre-commit
# with EOF indented, using <<-
map = <<-EOF
function() {
this.tags.forEach(function(z) {emit(z,{count:1});});
}
EOF
# with EOF put at first character position
map = <<EOF
function() {
this.tags.forEach(function(z) {emit(z,{count:1});});
}
EOF
map = <<EOF
function() {
this.tags.forEach(function(z) {emit(z,{count:1});});
}
EOF
puts 'Empty the MongoDB database, exclude System stuff'
Mongoid.master.collections.select do |collection|
include = collection.name !~ /system/
puts 'Dropping ' + collection.name if include
include
end.each(&:drop)
class UserAccountsController < ApplicationController
def signin
auth = request.env['rack.auth']
user_for_provider_and_uid = UserAccount.find_by_provider_and_uid(auth['provider'], auth['uid']).first()
new_auth = Authorization.new(:user_id => auth['user_id'], :provider => auth['provider'], :uid => auth['uid'], :user_info => auth['user_info'], :credentials => auth['credentials'])
if user_for_provider_and_uid.nil?
user = signed_in? ? self.current_user : UserAccount.new(:name => auth['user_info']['name'])
user.authorizations << new_auth
source 'http://rubygems.org'
gem 'rails', '3.0.0'
gem "mongoid", "2.0.0.beta.17"
gem "bson_ext", "1.0.4"
gem 'omniauth'
$heroku = ENV['USER'] ? !! ENV['USER'].match(/^repo\d+/) : ENV.any?{|key, _| key.match(/^HEROKU_/)}
unless $heroku
public class ControllerFactory : IControllerFactory
{
readonly IWindsorContainer container;
public ControllerFactory() : this(((IContainerAccessor) HttpContext.Current.ApplicationInstance).Container)
{
}
public ControllerFactory(IWindsorContainer container)
{