Skip to content

Instantly share code, notes, and snippets.

View paulschreiber's full-sized avatar

Paul Schreiber paulschreiber

View GitHub Profile
#!/usr/bin/env ruby
require 'watir-webdriver'
require 'webrick/httpproxy'
# USAGE: ./proxied_browser.rb server (port) [json]
# ./proxied_browser.rb browser (port)
class ProxiedBrowser < Watir::Browser
def initialize(port)
proxy = ['localhost',port].join(?:)
@omercs
omercs / Oauth2AzureActiveDirectoryRuby
Last active March 2, 2021 12:21
Oauth2 token from Azure Active Directory in Ruby on Rails project
require 'oauth2'
class WelcomeController < ApplicationController
# You need to configure a tenant at Azure Active Directory(AAD) to register web app and web service app
# You will need two entries for these app at the AAD portal
# You will put clientid and clientsecret for your web app here
# ResourceId is the webservice that you registered
# RedirectUri is registered for your web app
CLIENT_ID = 'b6a42...'
CLIENT_SECRET = 'TSbx..'
@bergantine
bergantine / genpass.py
Last active May 18, 2021 07:13
Safari-style #python #password Generator
from random import choice
def genCode(len):
return ''.join([choice('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') for i in range(len)])
print '%s-%s-%s-%s' % (genCode(3), genCode(3), genCode(3), genCode(3))
@mattattui
mattattui / gist:879249
Created March 21, 2011 10:08
Convert named HTML entities to numeric for XML compatibility
<?php
/* html_convert_entities($string) -- convert named HTML entities to
* XML-compatible numeric entities.
*/
function html_convert_entities($string) {
return preg_replace_callback('/&([a-zA-Z][a-zA-Z0-9]+);/S',
'convert_entity', $string);
}
@mattattui
mattattui / gist:879252
Created March 21, 2011 10:12
Convert HTML entities to XML
<?php
$out = htmlspecialchars(
html_entity_decode($in, ENT_QUOTES, 'UTF-8'),
ENT_QUOTES, 'UTF-8'
);
?>
😒🙅🙄
$thing for fun and profit
all your $thing are belong to $shutup
honey I $verbed the $thing
$thing demystified
$thing: a deep dive
$verb all the things
make $thing great again
$x and $y and $z, oh my!

Proposal for Improving Mass Assignment

For a while, I have felt that the following is the correct way to improve the mass assignment problem without increasing the burden on new users. Now that the problem with the Rails default has been brought up again, it's a good time to revisit it.

Sign Allowed Fields

When creating a form with form_for, include a signed token including all of the fields that were created at form creation time. Only these fields are allowed.

To allow new known fields to be added via JS, we could add:

@geoff-nixon
geoff-nixon / osx-software-update-urls.txt
Created September 23, 2015 08:04 — forked from stefanschmidt/osx-software-update-urls.txt
URLs of the index files used by the software update client on OS X
10.3 (Panther):
https://swscan.apple.com/scanningpoints/scanningpointX.xml
10.4 (Tiger):
https://swscan.apple.com/content/catalogs/index.sucatalog
https://swscan.apple.com/content/catalogs/index-1.sucatalog
10.5 (Leopard):
https://swscan.apple.com/content/catalogs/others/index-leopard.merged-1.sucatalog

local installation of Elasticsearch for WordPress VIP Go infrastructure

Update, 11/2022:

Apparently none of this will work with Elasticsearch versions greater than 8.0. See elastic/homebrew-tap#126 (comment). The alternative seems to be to use Docker, or since it's a big system either way might as well switch to VVV.

Previous instructions

These are basic instructions, and I'm sure could be tightened up.

@drewreece
drewreece / AHT-my-disk.sh
Last active May 15, 2023 09:22
Install Apple Hardware Test to a volume and bless the AHT
#!/bin/sh
#
# AHT My Disk
#
# Copy Apple Hardware Test to a volume and bless the hardware test to be bootable
#
# Useful list of AHT & models from upekkha - https://github.com/upekkha/AppleHardwareTest thx u :)
# find your model details & get the AHT disk image
## sysctl hw.model | awk '{ print $2 }'
## ioreg -l | grep board-id | awk -F\" '{ print $4 }'