Skip to content

Instantly share code, notes, and snippets.

Avatar

William Denniss WilliamDenniss

View GitHub Profile
@WilliamDenniss
WilliamDenniss / json_escape.rb
Created Apr 28, 2013
Monkey patch ActiveSupport to bring back to_json unicode character encoding. There is a better way if you have control over the to_json call, use JSON.generate(object, :ascii_only => true). Read more @ http://omegadelta.net/2013/04/28/changes-to-how-rails-3-2-13-and-4-0-encodes-unicode-in-json/
View json_escape.rb
module ActiveSupport
module JSON
module Encoding
class << self
# from https://github.com/rails/rails/blob/v3.2.12/activesupport/lib/active_support/json/encoding.rb#L121
def escape(string)
if string.respond_to?(:force_encoding)
string = string.encode(::Encoding::UTF_8, :undef => :replace).force_encoding(::Encoding::BINARY)
end
View heroku.rake
## Restart a Heroku Web Application
## Adapted from a script by mscottford for restarting workers: https://gist.github.com/2028552
## Instructions:
## * Save this script in lib/tasks
## * Gemfile: gem 'heroku-api', :git => 'https://github.com/heroku/heroku.rb.git'
## * Commit Gemfile* and lib/tasks
## * $ heroku config:add APP_NAME='name of the Heroku app'
## * $ heroku config:add HEROKU_API_KEY='the API key found on the Heroku "My Account" page'
## * Deploy and test with $ heroku run rake heroku:webs:restart[10] (Look at process uptime with $ heroku ps)
View openid-configuration
{
"issuer": "https://accounts.google.com",
"authorization_endpoint": "https://accounts.google.com/o/oauth2/v2/auth",
"token_endpoint": "https://www.googleapis.com/oauth2/v4/token",
"userinfo_endpoint": "https://www.googleapis.com/oauth2/v3/userinfo",
"revocation_endpoint": "https://accounts.google.com/o/oauth2/revoke",
"jwks_uri": "https://www.googleapis.com/oauth2/v3/certs",
"response_types_supported": [
"code",
"token",
View gist:3eb75160f99ec69be46e
{
"issuer": "accounts.google.com",
"authorization_endpoint": "https://accounts.google.com/o/oauth2/auth",
"token_endpoint": "https://www.googleapis.com/oauth2/v3/token",
"userinfo_endpoint": "https://www.googleapis.com/oauth2/v3/userinfo",
"revocation_endpoint": "https://accounts.google.com/o/oauth2/revoke",
"jwks_uri": "https://www.googleapis.com/oauth2/v2/certs",
"response_types_supported": [
"code",
"token",
@WilliamDenniss
WilliamDenniss / extractcomment.py
Last active Aug 12, 2017 — forked from mikeshi80/extractcomment.py
Extract the comments from the C/C++ style source code to the same name add .cmt ext name. Usage is `python extractcomment.py topdir .ext1 .ext2 ...`. You can set the encoding to read and write file correctly. Reference the source here http://www.cppblog.com/luyulaile/archive/2012/12/03/195907.html
View extractcomment.py
#!/usr/bin/env python
import sys
import re
import os.path
import codecs
import os
encoding = 'cp932'
@WilliamDenniss
WilliamDenniss / AppAuthExampleViewController.m
Created Feb 20, 2016
Creating an authorization request with AppAuth using the 'plain' PKCE challenge method.
View AppAuthExampleViewController.m
// builds authentication request
NSString *state = [OIDAuthorizationRequest generateState];
NSString *codeVerifier = [OIDAuthorizationRequest generateCodeVerifier];
OIDAuthorizationRequest *request =
[[OIDAuthorizationRequest alloc] initWithConfiguration:configuration
clientId:kClientID
scope:@"openid profile"
redirectURL:redirectURI
responseType:OIDResponseTypeCode
state:state
@WilliamDenniss
WilliamDenniss / count_helm_tests.sh
Last active Jun 23, 2017
Counts the number of helm tests in subfolders
View count_helm_tests.sh
#!/bin/bash
# Iterates all subdirectors of the current path.
for d in */ ; do
# Count instances of test annotations in folder.
COUNT=`egrep -r "test-success|test-failure" "$d" | wc -l`
# Colors!
COUNT_COLOR=$([ $COUNT -gt 0 ] && echo "$(tput setaf 2)" || echo "$(tput setaf 1)")
@WilliamDenniss
WilliamDenniss / Dockerfile
Created Sep 17, 2017 — forked from buth/Dockerfile
Docker Install ImageMagick
View Dockerfile
RUN \
curl -sfLO http://www.imagemagick.org/download/ImageMagick-6.9.0-4.tar.gz && \
echo 'cf51a1c6ebf627c627a8e6ac20aecce5f1425907c2cdb98c5a60f329c5c6caf2 ImageMagick-6.9.0-4.tar.gz' | sha256sum -c - && \
tar -xzf ImageMagick-6.9.0-4.tar.gz && \
cd ImageMagick-6.9.0-4 && \
./configure --prefix /usr/local && \
make install && \
cd .. && \
rm -rf ImageMagick*
@WilliamDenniss
WilliamDenniss / archive_branch.sh
Created Sep 17, 2017
Creates a tag with a common format for an old branch, gives instructions to delete.
View archive_branch.sh
#!/bin/bash
git tag -a archive/$1 $1 -m "Archive of branch $1."
echo "Branch: `git rev-parse $1`"
echo "Tag: `git rev-list -n 1 archive/$1`"
echo "Run: git push origin --delete $1"
echo " git branch -d $1"
@WilliamDenniss
WilliamDenniss / AppAuthCustomBrowser.md
Last active Mar 24, 2020
AppAuth for iOS with Custom Browser
View AppAuthCustomBrowser.md

Custom Browser support for AppAuth for iOS has been implemented. Here's how to configure AppAuth to use a custom browser:

First, add the following array to your Info.plist (in XCode, right click -> Open As -> Source Code)

	<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>googlechromes</string>
		<string>opera-https</string>
		<string>firefox</string>