Skip to content

Instantly share code, notes, and snippets.

Avatar

Jak Charlton jakcharlton

View GitHub Profile
@jakcharlton
jakcharlton / getParameterByName
Last active Aug 29, 2015
Get the LeadMachine ID from the query string
View getParameterByName
<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 Aug 29, 2015
Wufoo form embed code
View wufoo-embed.js
<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 Sep 18, 2015 — forked from davemo/README.md
Pre commit git hook to stop dumb checkins
View README.md

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
View eof-indented.rb
# with EOF indented, using <<-
map = <<-EOF
function() {
this.tags.forEach(function(z) {emit(z,{count:1});});
}
EOF
View eof-at-first-char.rb
# with EOF put at first character position
map = <<EOF
function() {
this.tags.forEach(function(z) {emit(z,{count:1});});
}
EOF
View eof-in-wrong-place.txt
map = <<EOF
function() {
this.tags.forEach(function(z) {emit(z,{count:1});});
}
EOF
View emptying_mongo.rb
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)
View embed_many.rb
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
View gemlist.rb
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
View controllerfactory.cs
public class ControllerFactory : IControllerFactory
{
readonly IWindsorContainer container;
public ControllerFactory() : this(((IContainerAccessor) HttpContext.Current.ApplicationInstance).Container)
{
}
public ControllerFactory(IWindsorContainer container)
{