Skip to content

Instantly share code, notes, and snippets.

🤠
Yeee-haw!

Eran Schoellhorn Swingline0

🤠
Yeee-haw!
Block or report user

Report or block Swingline0

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Swingline0
Swingline0 / external-links.js
Created Oct 12, 2016
Rewrite links leaving site
View external-links.js
View hack.php
$cat_counts = (new F\MaybeEmpty($full_query->get_posts()))
->bind($posts ==> array_map($p ==> wp_get_post_categories($p->ID), $posts))
->bind('tft\fp\flatten')
->bind($cats ==> F\reduce($cats, function($carry, $id) {
$carry[$id]++;
return $carry;
}), [])
->extract();
View gist:946fc45a993a0406c8b4
// given:
var sayHello = (function (name) {
var text = 'Hello, ' + name;
return function () {
console.log(text);
};
})('REX');
sayHello(); // This prints 'REX' to the console
@Swingline0
Swingline0 / Init
Last active Aug 29, 2015
Singleton style plugin reference
View Init
if ( ! defined( 'ABSPATH' ) ) exit;
add_action( 'plugins_loaded', array( 'Plugin_Class_Name', 'get_instance' ) );
class Plugin_Class_Name {
private static $instance = null;
public static function get_instance() {
if ( ! isset( self::$instance ) )
View keybase.md

Keybase proof

I hereby claim:

  • I am Swingline0 on github.
  • I am eransch (https://keybase.io/eransch) on keybase.
  • I have a public key whose fingerprint is 5D6D FDEF B837 4F69 B67E 2B7F 875B 489C D5AA 4DBB

To claim this, I am signing this object:

@Swingline0
Swingline0 / Vagrantfile
Created Aug 27, 2014
Heroku Vagrantfile
View Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "heroku"
config.vm.box_url = "https://dl.dropboxusercontent.com/s/rnc0p8zl91borei/heroku.box"
config.vm.network "forwarded_port", guest: 8000, host: 8080
config.vm.network "forwarded_port", guest: 1080, host: 9080
config.vm.network :private_network, ip: '192.168.50.50'
config.vm.synced_folder '.', '/vagrant', nfs: true
config.vm.provider "virtualbox" do |v|
host = RbConfig::CONFIG['host_os']
View gist:ef8a8d777b05980a0f17
var url = 'http://www.reddit.com/r/all.json',
redditData = {};
var redditGetter = function(){
http.get(url, function(res) {
var body = '';
res.on('data', function(chunk) {
body += chunk;
});
res.on('end', function() {
@Swingline0
Swingline0 / gist:4a04469a95796281ccc1
Created Aug 6, 2014
Custom Post Type Query, Groupped by Categories
View gist:4a04469a95796281ccc1
// Add Shortcode
function equipment_list_shortcode( $atts ) {
// Attributes
extract( shortcode_atts(
array(
'trip' => '',
), $atts )
);
@Swingline0
Swingline0 / disallow-po-box.php
Last active Aug 29, 2015
Disallow a PO Box in WooCommerce
View disallow-po-box.php
<?php
add_action('woocommerce_after_checkout_validation', 'deny_pobox_postcode');
function deny_pobox_postcode($posted) {
global $woocommerce;
$postcode = (isset($posted['shipping_address_1'])) ? $posted['shipping_address_1'] : $posted['billing_address_1'];
$postcode = strtolower(str_replace(' ', '', $postcode));
You can’t perform that action at this time.