Skip to content

Instantly share code, notes, and snippets.

View mitchellporter's full-sized avatar

Mitchell Porter mitchellporter

  • Seattle, WA
View GitHub Profile
//: Mocks Playground
import UIKit
struct User {
}
struct PushNotificationController {
let registrar: PushNotificationRegistrar
init(registrar: PushNotificationRegistrar) {
@paulirish
paulirish / how-to-view-source-of-chrome-extension.md
Last active May 15, 2024 20:30
How to view-source of a Chrome extension

Option 1: Command-line download extension as zip and extract

extension_id=jifpbeccnghkjeaalbbjmodiffmgedin   # change this ID
curl -L -o "$extension_id.zip" "https://clients2.google.com/service/update2/crx?response=redirect&os=mac&arch=x86-64&nacl_arch=x86-64&prod=chromecrx&prodchannel=stable&prodversion=44.0.2403.130&x=id%3D$extension_id%26uc" 
unzip -d "$extension_id-source" "$extension_id.zip"

Thx to crxviewer for the magic download URL.

@dardo82
dardo82 / periscope.sh
Last active August 19, 2016 02:36
Save Periscope Videos
#!/bin/zsh
cd "${0%/*}/../conf/url/"
for user in $(cat ../users.list); do
TWEETS=$(t search timeline -d -l user "#Periscope:" | grep -v " RT @")
OLDIFS=$IFS; IFS=$'\n'
for tweet in $(echo $TWEETS); do
DATE=$(echo $tweet | cut -d\ -f2-6)
OLD_LC_ALL=$LC_ALL; export LC_ALL="POSIX"
SEC=$(($(date +%s) - $(date -j -f ' %b %e %H:%M ' "$DATE" +%s)))
@wosephjeber
wosephjeber / ngrok-installation.md
Last active May 6, 2024 20:19
Installing ngrok on Mac

Installing ngrok on OSX

For Homebrew v2.6.x and below:

brew cask install ngrok

For Homebrew v2.7.x and above:

@onmyway133
onmyway133 / SimpleCache.m
Last active September 26, 2015 19:47
SimpleCache.m
// CacheItem.h
@interface CacheItem : RLMObject
@property NSString *key;
@property NSData *value;
@end
// CacheItem.m
@implementation CacheItem
@danielmcclure
danielmcclure / facebook-wca-standard-events.html
Last active January 14, 2024 14:54
Sample Facebook Standard Events for New Facebook WCA (Website Custom Audience) Pixel
<!-- Facebook Custom Audience Pixel Code - Placed on Every Page of Site -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', '{{facebook pixel}}');
fbq('track', 'PageView');
</script>
import UIKit
/*
I'm not sure why `@NSCopying` doesn't seem to be copying the object in the example below.
I'm attempting to write code that follows the "initialization with a configuration object" pattern, like `NSURLSession`.
Ideally the configuration would be a struct, but since I'm still interoperating with Obj-C that's not an option.
*/
class Foo : NSObject, NSCopying {
var bar = "bar"
@benjamincharity
benjamincharity / contacts.js
Last active January 9, 2023 16:06
Create a downloadable file of VCARD formatted address for iOS from a JSON array.
var contacts =
[
{
"notes": [
{
"description": "Fugiat aute pariatur excepteur elit."
}
],
"tels": [
{
@Unitech
Unitech / bootstrap
Last active February 9, 2018 15:22
PM2 / Keymetrics for Heroku/Rackspace/Joyent/Amazon Elasticbeanstalk/Azure...
http://pm2.keymetrics.io/docs/usage/use-pm2-with-cloud-providers/
@joyrexus
joyrexus / README.md
Last active June 8, 2023 07:45
form-data vs -urlencoded

Nice answer on stackoverflow to the question of when to use one or the other content-types for POSTing data, viz. application/x-www-form-urlencoded and multipart/form-data.

“The moral of the story is, if you have binary (non-alphanumeric) data (or a significantly sized payload) to transmit, use multipart/form-data. Otherwise, use application/x-www-form-urlencoded.”


Matt Bridges' answer in full:

The MIME types you mention are the two Content-Type headers for HTTP POST requests that user-agents (browsers) must support. The purpose of both of those types of requests is to send a list of name/value pairs to the server. Depending on the type and amount of data being transmitted, one of the methods will be more efficient than the other. To understand why, you have to look at what each is doing