Skip to content

Instantly share code, notes, and snippets.

View zorab47's full-sized avatar
⌨️

Charles Maresh zorab47

⌨️
View GitHub Profile
@robksawyer
robksawyer / marketo_example.html
Last active October 30, 2020 00:36
Solution to using UTM parameters & cookies to capture lead source information. See https://nation.marketo.com/thread/24866
<script type="text/javascript">
// getQueryParams
//This grabs the UTM parameters from the URL
function getQueryParams(qs) {
qs = qs.split("+").join(" ");
var params = {}, tokens,
re = /[?&]?([^=]+)=([^&]*)/g;
while (tokens = re.exec(qs)) {
params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
}
@talwrii
talwrii / jqcheatsheet.md
Last active December 16, 2020 15:13
jq cheatsheet

jq cheatsheet

Extract field from list of objects

jq 'map(.foo)'

[ { foo: 1 }, { foo: 2 } ]
[1, 2]

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a
# Has your OS/FS/disk lost your data?
# cd to the directory containing your project repositories and run the command
# below. (It's long; make sure you get it all.) It finds all of your git repos
# and runs paranoid fscks in them to check their integrity.
(set -e && find . -type d -and -iname '.git' | while read p; do (cd "$(dirname "$p")" && (set -x && git fsck --full --strict)); done) && echo "OK"
# I have 81 git repos in my ~/proj directory and had no errors.
@dougc84
dougc84 / model.rb
Last active July 17, 2017 04:44
Ransack - Polymorphic Associations Search Ransacker
class MyModel < ActiveRecord::Base
belongs_to :owner, polymorphic: true
ransacker :owner_name, formatter: proc { |value|
# To use this, you have to know what all of the possible owner types can be.
# For this example, the #owner_type could be either Group or Advertiser.
# The fields we want to search on are:
# Group#name
# Advertiser#contact_name
#
@rodneyrehm
rodneyrehm / gist:40e7946c0cff68a31cea
Last active November 7, 2022 09:11
Diagrams for Documentation

some tools for diagrams in software documentation

Diagrams For Documentation

Obvious Choices

ASCII

# RSpec matcher to spec delegations.
# Forked from https://gist.github.com/ssimeonov/5942729 with fixes
# for arity + custom prefix.
#
# Usage:
#
# describe Post do
# it { should delegate(:name).to(:author).with_prefix } # post.author_name
# it { should delegate(:name).to(:author).with_prefix(:any) } # post.any_name
# it { should delegate(:month).to(:created_at) }
@tfausak
tfausak / doctest.rb
Last active May 22, 2018 13:12
Test Ruby code in Markdown files.
#!/usr/bin/env ruby
pattern = /^```(.*)/
capturing = false
language = ''
lines = {}
File.open(ARGV.shift).each_line do |line|
match = pattern.match(line)
@mudassir0909
mudassir0909 / selectable_placeholder.js
Last active September 30, 2017 03:18
Selectable Placeholder for selectize dropdown plugin
Selectize.define('selectable_placeholder', function( options ) {
var self = this;
options = $.extend({
placeholder: self.settings.placeholder,
html: function ( data ) {
return (
'<div class="selectize-dropdown-content placeholder-container">' +
'<div data-selectable class="option">' + data.placeholder + '</div>' +
'</div>'
@justinweiss
justinweiss / filterable.rb
Last active January 11, 2024 07:28
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with names based on the keys in <tt>filtering_params</tt>
# with their associated values. For example, "{ status: 'delayed' }" would call