Skip to content

Instantly share code, notes, and snippets.

@awesome
awesome / opposite_of_array_intersection.rb
Created January 21, 2010 17:44
Ruby opposite of array intersection
# Ruby opposite of array intersection... or maybe the method is missing from my brain bc not enough coffee
# http://twitter.com/soawesomeman/status/8035087261
def awesome(ar_1, ar_2)
(ar_1 + ar_2) - (ar_1 & ar_2)
end
awesome([1,2,3,4], [3,4,5,6]) # => [1, 2, 5, 6]
@chetan
chetan / yardoc_cheatsheet.md
Last active November 11, 2024 08:27
YARD cheatsheet
@peterwilsoncc
peterwilsoncc / livereload.php
Created March 22, 2012 02:31
Live reload WordPress extension
<?php
/*
Plugin Name: LiveReload
Description: Adds the JavaScript for LiveReload to a WordPress site
Version: 0.0.0.0.1alpha
Author: Peter Wilson
Author URI: http://peterwilson.cc/
*/
@csalzman
csalzman / explanation
Created August 23, 2012 17:58
Build Silverpop Rulesets
Silverpop uses xml rulesets to display dynamic content in emails. When you have the content already created elsewhere, it can be a pain to create rulesets with more than one rule. This script goes out of its way to remove you from having to touch xml, instead opting for building the ruleset based on parameters in objects.
Mainly gisting this for retrieval later on by myself, however, if you want help using it contact me.
@mstrickland22
mstrickland22 / jquery-plugin-amd.js
Created September 25, 2012 19:03
JavaScript: AMD jQuery Plugin Wrapper
// Uses AMD or browser globals to create a jQuery plugin.
// It does not try to register in a CommonJS environment since
// jQuery is not likely to run in those environments.
// See jqueryPluginCommonJs.js for that version.
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
@nzakas
nzakas / gist:5511916
Created May 3, 2013 17:47
Using GitHub inside a company

I'm doing some research on how companies use GitHub Enterprise (or public GitHub) internally. If you can help out by answering a few questions, I'd greatly appreciate it.

  1. What is the primary setup? Is there an organization and each official repo is owned by that organization?
  2. Does every engineer have a fork of each repo they're working on?
  3. Are engineers allowed to push directly to the official repo? Or must all commits go through a pull request?
  4. Do engineers work on feature branches on the main repo or on their own forks?
  5. Do you require engineers to squash commits and rebase before merging?
  6. Overall, what is the workflow for getting a new commit into the main repository?
  7. What sort of hooks do you make use of?
  8. Are there any ops issues you encountered? (Scaling, unforeseen downtime, etc.)
@elidickinson
elidickinson / max_width_email.html
Created May 6, 2013 15:10
Email Template trick: max-width with outlook
<!--[if mso]>
<center>
<table><tr><td width="580">
<![endif]-->
<div style="max-width:580px; margin:0 auto;">
<p>This text will be centered and constrained to 580 pixels even on Outlook which does not support max-width CSS</p>
</div>
<!--[if mso]>
@mssola
mssola / singleton.rb
Created August 2, 2013 07:44
Different ways to create the Singleton pattern in Ruby.
##
# This files shows some possible implementations of the Singleton pattern
# in Ruby. I'm not a huge fan of the Singleton pattern, but it's nice
# in some cases. In this file I'm going to implement a simple logger.
#
##
# The first implementation that can come to our minds is to create a class
# that holds an instance as a class variable that can be accessed through
@jrfnl
jrfnl / ShortcodeReference.php
Last active December 31, 2015 23:59
Debugged version of the ShortcodeReference.php file from @bartee's WP plugin Shortcode Reference. Not all the fixes are done in the most efficient way, but at least it (sort of) works now and definitely works better than before.
<?php
/**
* DataContainer for shortcodes.
*
* @author Bart Stroeken
*/
class ShortcodeReference {
/**
* Shortcode
@emwiles
emwiles / Bullet proof email button - image free
Created February 9, 2014 14:46
Bullet proof button with Silverpop tracking code - original button code courtesy of @stigm (http://buttons.cm/). NOTE: do not view in design view within Silverpop - button loses its bullet proof-ness.
<div align="center">
<!--[if mso]>
<a href="#" xt="SPCLICK" name="main_article1_outlook" style="color:#E97F1D; text-decoration: underline;" >
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:30px;v-text-anchor:middle;width:130px;" arcsize="14%" strokecolor="#fdb515" fillcolor="#E97F1D">
<w:anchorlock/>
<center style="color:#ffffff;font-family:sans-serif;font-size:13px;font-weight:bold;">Read article</center>
</v:roundrect>
</a>
<![endif]--><![if !mso]>