Skip to content

Instantly share code, notes, and snippets.

View chadxz's full-sized avatar
:shipit:

Chad McElligott chadxz

:shipit:
View GitHub Profile
@chadxz
chadxz / app.js
Created April 14, 2014 20:25
using path to simplify require
// js/app.js
define(['utils'], function (utils) {
'use strict';
return {
initialize: function () {
utils.helloWorld();
}
};
@chadxz
chadxz / keybase.md
Created May 21, 2015 18:56
Keybase verification

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 / StartupActivity.java
Last active November 17, 2015 20:19
Registering a push token with respoke-sdk-android
/**
* 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 / serialPromises.js
Last active December 8, 2015 15:52
Serial promises
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 December 16, 2015 15:39
Chrome 46 WebRTC Renegotiation Issues

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 / CustomMergeVars.cs
Created September 23, 2013 14:40
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.
using MailChimp.Lists;
using System.Runtime.Serialization;
namespace MyNamespace {
[DataContract]
public class CustomMergeVars: MergeVar
{
[DataMember(Name="FNAME")]
public string FirstName { get; set; }
@chadxz
chadxz / protecting static assets in sails.js.md
Last active January 4, 2016 18:39
protecting static assets in sails.js

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 / git-prunelocal
Created November 17, 2016 16:59
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