Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:

Chad McElligott chadxz

:shipit:
View GitHub Profile
View git-prunelocal
#!/bin/bash
#
# Prune local tracking branches that have been removed upstream.
# Your remote tracking branches can be removed automatically by setting `fetch.prune` to true or running `git fetch -prune`.
# Another command to clean up your remote tracking branches is `git remote prune <remote>`.
#
# Author: @leshill
# https://gist.github.com/leshill/9a1088a17f94cef24831
# Modifications by: @chadxz
if [[ $# = 1 && $1 == '-n' ]]; then
@chadxz
chadxz / serialPromises.js
Last active Dec 8, 2015
Serial promises
View serialPromises.js
const keyedObj = {
foo: 'fooVal',
bar: 'barVal',
baz: 'bazVal'
};
function concatAsync(acc, val) {
console.log(`processing '${val}'`);
return new Promise(resolve => {
resolve(acc.concat(val));
@chadxz
chadxz / Chrome 46 WebRTC Renegotiation Issues.md
Last active Dec 16, 2015
Chrome 46 WebRTC Renegotiation Issues
View Chrome 46 WebRTC Renegotiation Issues.md

Chrome 46 WebRTC Renegotiation Issues

The below SDP is recreated using the following steps:

  • Participant A offers audio+video to Participant B
  • B answers with audio+video
  • Call connected.
  • A renegotiates to remove audio, making it a video-only call from it's side
    • calls getUserMedia with { audio: false, video: true }
    • removes all streams from the peer connection, and adds the stream from getUserMedia
@chadxz
chadxz / StartupActivity.java
Last active Nov 17, 2015
Registering a push token with respoke-sdk-android
View StartupActivity.java
/**
* Sorry if there are some imports or bits missing that are needed
* to make sense of this. I'm copy/pasting from a working example and
* trying to tease out things that are not relevant to push notification
* registration.
*/
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Context;
import android.content.Intent;
@chadxz
chadxz / keybase.md
Created May 21, 2015
Keybase verification
View keybase.md

Keybase proof

I hereby claim:

  • I am chadxz on github.
  • I am chadxz (https://keybase.io/chadxz) on keybase.
  • I have a public key whose fingerprint is E7CC 2911 9EE3 FD53 BB0D 37A5 2A94 4B00 61AD 9442

To claim this, I am signing this object:

@chadxz
chadxz / app.js
Created Apr 14, 2014
using path to simplify require
View app.js
// js/app.js
define(['utils'], function (utils) {
'use strict';
return {
initialize: function () {
utils.helloWorld();
}
};
@chadxz
chadxz / protecting static assets in sails.js.md
Last active Jan 4, 2016
protecting static assets in sails.js
View protecting static assets in sails.js.md

With these files in place, and given you had a static file at assets/protected/hello.txt with the words 'hello world' in it, and another file at assets/robots.txt, you could do sails lift and do a GET on http://localhost:1337/robots.txt and have the file returned normally, but do a GET on http://localhost:1337/protected/hello.txt and you would get 'you are not allowed!'.

You can extend this example to do things like HTTP basic authentication, filtering based on origin, etc.

This gist is inspired by this stackoverflow link

@chadxz
chadxz / CustomMergeVars.cs
Created Sep 23, 2013
Using MailChimp.NET MergeVars in ASP.NET WebForms. This is primarily to illustrate the use of the MergeVar class for sending custom merge variables via the subscribe method.
View CustomMergeVars.cs
using MailChimp.Lists;
using System.Runtime.Serialization;
namespace MyNamespace {
[DataContract]
public class CustomMergeVars: MergeVar
{
[DataMember(Name="FNAME")]
public string FirstName { get; set; }
You can’t perform that action at this time.