Skip to content

Instantly share code, notes, and snippets.

View chrisladd's full-sized avatar

Chris Ladd chrisladd

View GitHub Profile
@olenhad
olenhad / AVAudioPCMBuffer+Additions.m
Last active January 2, 2021 02:49
Combining AVAudioPCMBuffers. Assumes non interleaved format
@implementation AVAudioPCMBuffer (LiveAdditions)
- (AVAudioPCMBuffer *)combineWithBuffer:(AVAudioPCMBuffer *)buffer {
if (![buffer.format isEqual:self.format]) {
return nil;
}
AVAudioPCMBuffer *combined = [[AVAudioPCMBuffer alloc] initWithPCMFormat:self.format frameCapacity:self.frameCapacity + buffer.frameCapacity];
combined.frameLength = self.frameLength + buffer.frameLength;
@joncardasis
joncardasis / Storing-Images-On-Github.md
Last active April 29, 2025 07:03
Storing Images and Demos in your Repo

Storing Images and Demos in your Repo

In this quick walkthough you'll learn how to create a separate branch in your repo to house your screenshots and demo gifs for use in your master's readme.

How to

1. Clone a fresh copy of your repo

In order to prevent any loss of work it is best to clone the repo in a separate location to complete this task.

2. Create a new branch

Create a new branch in your repo by using git checkout --orphan assets

@lucnap
lucnap / fb-page-access-token-no-expire
Last active October 22, 2021 09:53
How to get a Facebook Page Access Token that doesn't expire Never!
How to get a Facebook Page Access Token that doesn't expire Never!
- Go to http://developers.facebook.com/tools/explorer/
- Get a User Access Token with a permission "manage_pages"
- Convert this short-lived access token into a long-lived one by making this Graph API call:
https://graph.facebook.com/v2.6/oauth/access_token?client_id=<your FB App ID >&client_secret=<your FB App secret>&grant_type=fb_exchange_token&fb_exchange_token=<your short-lived access token>
- Make a call Graph API:
https://graph.facebook.com/v2.6/<your personal account FB user id>/accounts?access_token=<your long-lived access token>
- The returned access_token has no expiration unless you change your password or not more admin of the target page or deauthorize FB page
@jshbrntt
jshbrntt / videos2web.sh
Last active December 28, 2021 21:41
Script to convert videos to web compatible formats.
#!/bin/bash
printf "\e[1;36m\n\
_ _ ____ _ \n\
__ _(_) __| | ___ ___ ___|___ \__ _____| |__ \n\
\ \ / / |/ _\` |/ _ \/ _ \/ __| __) \ \ /\ / / _ \ '_ \ \n\
\ V /| | (_| | __/ (_) \__ \/ __/ \ V V / __/ |_) | \n\
\_/ |_|\__,_|\___|\___/|___/_____| \_/\_/ \___|_.__/ \n\
https://gist.github.com/joshua-barnett/0764f654ba992b663ee9\n\
Usage: \n\
$ ./videos2web.sh input_directory/ output_directory \e[m\\n"
@blork
blork / extensions.m
Last active May 20, 2021 14:25
Dealing with various extension data types
NSExtensionItem *item = self.extensionContext.inputItems.firstObject;
NSItemProvider *itemProvider = item.attachments.firstObject;
// Shared plain text is stored here. Content varies wildly based on app.
NSString *sharedPlainText = [item.attributedContentText string];
if ([itemProvider hasItemConformingToTypeIdentifier:(NSString *)kUTTypePropertyList]) {
[itemProvider loadItemForTypeIdentifier:(NSString *)kUTTypePropertyList
options:nil
completionHandler:^(NSDictionary *item, NSError *error) {
@milesmatthias
milesmatthias / directory_upload.rb
Created September 1, 2014 00:57
S3 directory upload in ruby. Switched http://avi.io/blog/2013/12/03/upload-folder-to-s3-recursively to use the official aws ruby sdk.
#!/usr/bin/env ruby
require 'rubygems'
require 'aws-sdk'
class S3FolderUpload
attr_reader :folder_path, :total_files, :s3_bucket
attr_accessor :files
@kroger
kroger / convert.sh
Last active May 7, 2018 18:48
midi-to-mp3
fluidsynth -F output.wav ~/Soundfonts/my-soundfont.sf2 myfile.midi
lame output.wav
@cihancimen
cihancimen / string_contains_emoji
Created November 26, 2012 00:54
Check if an NSString contains an emoji character
- (BOOL)stringContainsEmoji:(NSString *)string {
__block BOOL returnValue = NO;
[string enumerateSubstringsInRange:NSMakeRange(0, [string length]) options:NSStringEnumerationByComposedCharacterSequences usingBlock:
^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
const unichar hs = [substring characterAtIndex:0];
// surrogate pair
if (0xd800 <= hs && hs <= 0xdbff) {
if (substring.length > 1) {
const unichar ls = [substring characterAtIndex:1];
@jbroadway
jbroadway / Slimdown.md
Last active February 20, 2025 13:00
Slimdown - A simple regex-based Markdown parser.