Skip to content

Instantly share code, notes, and snippets.

View rbk's full-sized avatar

Richard Keller rbk

View GitHub Profile
@JonCatmull
JonCatmull / curly_swap.php
Last active August 29, 2015 14:10
Function to Swap words inside double curly braces for entries in an array
<?php
function curlySwap($shortcodes,$string) {
return preg_replace_callback(
'/\{\{(\w+)\}\}/',
function ($match) {
global $shortcodes;
return $shortcodes[substr($match[0], 2, -2)];
},
$string
);
@telephone
telephone / gist:3869611
Created October 11, 2012 01:34 — forked from Belgand/gist:2856947
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Ubuntu)

General

Ctrl+KB toggle side bar
Ctrl+Shift+P command palette
Ctrl+` python console
Ctrl+N new file

Editing

@rbk
rbk / functions.php
Created June 8, 2016 19:55
Query WordPress and add the metadata to the result.
<?php
/*
*
* Get posts with a standard query
* Include all the meta data in the result
*
*/
function get_posts_with_meta( $args ) {
$query = get_posts($args);
@rbk
rbk / gist:9878aaeaab45e7f29a99
Created October 7, 2014 07:24
Awesome git logging! Paste this in terminal and check logs with: git lg
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@rbk
rbk / rest-api-doc-example.md
Last active June 7, 2019 19:40
Example of REST API documentation (Based on Twitter, 2018)
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setHTTPMethod:@"GET"];
NSString *url = @"http://localhost:5000/api/updates/";
if(checksum){
url = [NSString stringWithFormat:@"%@?checksum=%@", url, checksum];
}
[request setURL:[NSURL URLWithString:url]];
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *err) {
NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
@philfreo
philfreo / simple_allow_all.xml
Last active October 23, 2019 02:39
AWS S3 CORS policy examples
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
<AllowedHeader>Content-*</AllowedHeader>
<AllowedHeader>Host</AllowedHeader>
</CORSRule>
@bradfrost
bradfrost / anatomy-of-a-successful-readme.md
Last active November 11, 2020 20:41
Anatomy of a successful README

Name of Project [version number] Build Status: Linux

]

[Introduction text about the project. This should be a short summary of the project that explains what it is and why anyone should care about it]

[optional image]

Getting Started

Requirements

[include a bulleted list of any dependencies your project requires. Include links to the dependencies, and additionally links to helpful resources to get up and running with the project's dependencies]

@paulera
paulera / burndown.html
Last active July 15, 2021 07:31
Burndown chart built using Chart.js
<html>
<!-- See live at https://codepen.io/paulera/pen/ejGKEr -->
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
<script>
/**
* Sum elements of an array up to the index provided.
*/
@charleskorn
charleskorn / superagent.js
Last active September 6, 2021 06:40 — forked from pherris/superagent.js
A Jest mock for superagent. Place in your __mocks__ directory.
'use strict';
var mockDelay;
var mockError;
var mockResponse = {
status: function () {
return 200;
},
ok: true,
get: jest.genMockFunction(),