Skip to content

Instantly share code, notes, and snippets.

View msmithstubbs's full-sized avatar

Matt Stubbs msmithstubbs

View GitHub Profile
@maltekrupa
maltekrupa / basic-auth.swift
Last active September 10, 2021 05:18
HTTP Basic Authentication using URLSession and URLCredentialStorage in swift 4 with xcode 9
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
let credential = URLCredential(user: “username@gmail.com”, password: “password”, persistence: URLCredential.Persistence.forSession)
let protectionSpace = URLProtectionSpace(host: "example.com", port: 443, protocol: "https", realm: "Restricted", authenticationMethod: NSURLAuthenticationMethodHTTPBasic)
URLCredentialStorage.shared.setDefaultCredential(credential, for: protectionSpace)
let config = URLSessionConfiguration.default
<!DOCTYPE html>
<html>
<head>
<title>Troop</title>
<%= stylesheet_link_tag 'application' %>
<%= javascript_include_tag 'application' %>
<%= csrf_meta_tags %>
</head>
<body>
@ivanvanderbyl
ivanvanderbyl / gist:4222308
Created December 6, 2012 06:55
Postgres 9.1 to 9.2 upgrade guide for Ubuntu 12.04
sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install postgresql-9.2 postgresql-server-dev-9.2 postgresql-contrib-9.2
sudo su -l postgres
psql -d template1 -p 5433
CREATE EXTENSION IF NOT EXISTS hstore;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
service postgresql stop
/usr/lib/postgresql/9.2/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.2/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.2/main/ -O "-c config_file=/etc/postgresql/9.2/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"
@msmithstubbs
msmithstubbs / gist:3897852
Last active October 11, 2015 17:58
Back In Stock registration form template
<!doctype html>
<!--[if lt IE 7]> <html class="ie6"> <![endif]-->
<!--[if IE 7]> <html class="ie7"> <![endif]-->
<!--[if IE 8]> <html class="ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html> <!--<![endif]-->
<head>
<meta name="viewport" content="width=device-width">
<style>
/*
* simple reset
@stugoo
stugoo / index.html
Created October 12, 2012 16:38
simple jquery overlay
<body>
<a href="#linkToTsnCs" class="showTerms">terms &amp; conditions</a>
<body>
@aheckmann
aheckmann / gg-1351c8470075b095.js
Created September 28, 2012 18:34
default_doc_array
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var assert = require('assert')
console.log('\n===========');
console.log(' mongoose version: %s', mongoose.version);
console.log('========\n\n');
var dbname = 'testing_gg-1351c8470075b095';
# A Sidekiq background job worker tha knows how to render Rails views
# Don't worry, I *think* I know what I'm doing ;)
class RenderWorker < AbstractController::Base
include AbstractController::Rendering
include AbstractController::Logger # dependency from actionview calling logging
include Rails.application.routes.url_helpers
include Sidekiq::Worker
append_view_path "#{Rails.root}/app/views" # from AbstractController::ViewPaths
@ryanb
ryanb / chef_solo_bootstrap.sh
Created April 5, 2012 04:35
Bootstrap Chef Solo
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -xvzf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125/
./configure --prefix=/usr/local
make
make install
@ivar
ivar / install.sh
Created June 17, 2011 16:39 — forked from mrrooijen/install.sh
Ruby 1.9.2 c.load patch with RVM
#!/bin/sh
#install me via:
#curl https://raw.github.com/gist/1031770/8d8400cbca40faa18bccc29d2f4d4b66371f5d7f/install.sh | sh
curl https://raw.github.com/gist/1008945/7532898172cd9f03b4c0d0db145bc2440dcbb2f6/load.patch > /tmp/load.patch
rvm get head # always good to make sure you're up to date with RVM
rvm reload
rvm cleanup all
rvm install ruby-1.9.2-p180 --patch /tmp/load.patch -n patched
<h1>Demo code for "Extreme JavaScript Performance" @ JSConf.eu</h1>
<script>
var benchmark = function(m,i){
var d1 = new Date, d2, r;
while(i--) r = m();
d2 = new Date;
console.log(d2.getTime()-d1.getTime());
// if(r) console.log(r);
}