Skip to content

Instantly share code, notes, and snippets.

View stephenfeather's full-sized avatar

Stephen Feather stephenfeather

View GitHub Profile
@ajself
ajself / rotatable.swift
Last active January 31, 2021 06:09
Rotate UIViewControllers that conform to a protocol
/*
This is an update to an example found on http://www.jairobjunior.com/blog/2016/03/05/how-to-rotate-only-one-view-controller-to-landscape-in-ios-slash-swift/
The code there works, with some updating to the latest Swift, but the pattern isn't very Swifty. The following is what I found to be more helpful.
*/
/*
First, create a protocol that UIViewController's can conform to.
This is in opposition to using `Selector()` and checking for the presence of an empty function.
*/
@tankbar
tankbar / wc-add-images-order-email-table.php
Created September 29, 2017 12:20 — forked from bekarice/wc-add-images-order-email-table.php
Add images to WooCommerce emails
// Edit order items table template defaults
function sww_add_wc_order_email_images( $table, $order ) {
ob_start();
$template = $plain_text ? 'emails/plain/email-order-items.php' : 'emails/email-order-items.php';
wc_get_template( $template, array(
'order' => $order,
'items' => $order->get_items(),
'show_download_links' => $show_download_links,
@jessedobbelaere
jessedobbelaere / userstyle.css
Last active June 1, 2017 19:14
Flowdock Classic (<May 2017) theme
/**
* On 2017-05-30, Flowdock did some UI changes. This is an attempt to ease the pain.
* Save this file as userstyle.css and put it inside ~/Library/Application Support/Flowdock/, then hit CMD+R to reload Flowdock.
*
* https://gist.github.com/jessedobbelaere/95c02699b2e0acd35762d204797b74f9
* @author Jesse Dobbelaere (@JesseDobbelaere)
*/
/* Improve the font */
body {
@tankbar
tankbar / functions.php
Created March 30, 2017 12:58
Add PDF to WooCommerce Order Email
<?php
add_filter( 'woocommerce_email_attachments', 'attach_terms_conditions_pdf_to_email', 10, 3);
function attach_terms_conditions_pdf_to_email ( $attachments , $id, $object ) {
$your_pdf_path = get_template_directory() . '/terms.pdf';
$attachments[] = $your_pdf_path;
return $attachments;
}
@Phoenix2k
Phoenix2k / distance_between.js
Last active February 27, 2023 19:07
JavaScript: Distance between two coordinates
/**
* Distance between two coordinates
*
* @author Salvador Dali
*
* @param { number } lat_1 - Latitude of first point
* @param { number } lon_1 - Longitude of first point
* @param { number } lat_2 - Latitude of second point
* @param { number } lon_2 - Longitude of second point
*
@joepie91
joepie91 / promises-faq.md
Last active June 25, 2023 09:02
The Promises FAQ - addressing the most common questions and misconceptions about Promises.
// there are many json-schema validators available, I prefer ajv
let Ajv = require('ajv')
let ajv = Ajv({ allErrors:true })
let swagger = require('./docs/my-swagger-definition')
// validation middleware
let validateSchema = (parameters) => {
return (req, res, next) => {
let errors = []
parameters.map(param => {
@MikeNGarrett
MikeNGarrett / wp-config.php
Last active April 26, 2024 10:15
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@rnagle
rnagle / wpdb_default_tables.sql
Last active March 28, 2024 22:37
Default WordPress Database Table Create Statements
DROP TABLE IF EXISTS wp_users;
CREATE TABLE wp_users (
ID bigint(20) unsigned NOT NULL auto_increment,
user_login varchar(60) NOT NULL default '',
user_pass varchar(64) NOT NULL default '',
user_nicename varchar(50) NOT NULL default '',
user_email varchar(100) NOT NULL default '',
user_url varchar(100) NOT NULL default '',
user_registered datetime NOT NULL default '0000-00-00 00:00:00',
user_activation_key varchar(60) NOT NULL default '',
@robertjpayne
robertjpayne / SwiftStaticCompile.rb
Last active April 23, 2017 15:40
A ruby function to generate a static library + clang module from a single Swift source file
require "Subprocess"
require "tmpdir"
#
# Currently will only convert a single swift code file into a static library
# and cannot include any Objective-C code.
#
# Usage: generate("/path/to/MyCode.swift", :ios)
#
def generate(file, platform, dst=nil)