Skip to content

Instantly share code, notes, and snippets.

<?php
function modify_url($mod, $url = FALSE){
// If $url wasn't passed in, use the current url
if($url == FALSE){
$scheme = $_SERVER['SERVER_PORT'] == 80 ? 'http' : 'https';
$url = $scheme.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
// Parse the url into pieces
$url_array = parse_url($url);
<?php
$url = modify_url(array('p' => 4, 'show' => 'column'), 'http://www.example.com/page.php?p=5&show=list&style=2');
?>
#!/bin/sh
for FILE in `git diff --name-only`; do
grep 'MYTODO' $FILE 2>&1 >/dev/null
if [ $? -eq 0 ]; then
echo $FILE ' contains MYTODO'
exit 1
fi
done
exit
// Remove links I never use
var remove = [
'nav-home-link',
'nav-resourceGroupsMenu'
];
for (var i = 0; i < remove.length; i++) {
var elem = document.querySelector('#' + remove[i]);
elem.parentNode.removeChild(elem);
}
@bradym
bradym / README.md
Last active February 13, 2018 23:02
JSON encode question

Most modern languages include a library for dealing with json, including converting a native object to a json string.

In the language of your choice, write a function to convert a native object to a json string.

A python example is provided below.

@bradym
bradym / staticgen-archive.json
Created June 23, 2018 18:25
STATICGEN.COM DATA ARCHIVE
{"timestamp":1529778230155,"data":{"ace":[{"timestamp":1529778230155,"stars":36,"forks":6,"issues":0}],"acrylamid":[{"timestamp":1529778230155,"stars":295,"forks":41,"issues":44}],"adm-dev-kit":[{"timestamp":1529778230155,"stars":30,"forks":5,"issues":11}],"amsf":[{"timestamp":1529778230155,"stars":156,"forks":80,"issues":6}],"anodize":[{"timestamp":1529778230155,"stars":2,"forks":0,"issues":0}],"antwar":[{"timestamp":1529778230155,"stars":391,"forks":27,"issues":7}],"asimov-static":[{"timestamp":1529778230155,"stars":4,"forks":4,"issues":0}],"assemble":[{"timestamp":1529778230155,"stars":3563,"forks":247,"issues":25}],"awestruct":[{"timestamp":1529778230155,"stars":257,"forks":73,"issues":57}],"bake":[{"timestamp":1529778230155,"stars":18,"forks":3,"issues":0}],"baker":[{"timestamp":1529778230155,"stars":38,"forks":7,"issues":1}],"bang":[{"timestamp":1529778230155,"stars":8,"forks":1,"issues":0}],"bashblog":[{"timestamp":1529778230155,"stars":671,"forks":112,"issues":20}],"blackhole":[{"timestamp":1529778230
@bradym
bradym / install.sh
Last active September 23, 2018 17:21
Macbook air ubuntu 18.04
apt update
# Install driver for wireless card
apt install bcmwl-kernel-source
# Make function keys work correctly
echo 2 > /sys/module/hid_apple/parameters/fnmode
# Map caps lock to escape
setxkbmap -option caps:escape
// Find duplicate ids
var allElements = document.getElementsByTagName("*"), allIds = {}, dupIDs = [];
for (var i = 0, n = allElements.length; i < n; ++i) {
var el = allElements[i];
if (el.id) {
if (allIds[el.id] !== undefined) {
dupIDs.push(el.id);
}
allIds[el.id] = el.name || el.id;
}
@bradym
bradym / README.md
Created July 18, 2019 02:00
INSECURE Working config for rundeck + oauth2_proxy

Using these settings, I was able to get logged in to rundeck using oauth2 with google as the provider. More specifically, it's using gsuite and only works for users belonging to a specified group (ops@example.com).

You'll need to follow the setup steps here to get your gsuite setup ready for use: https://pusher.github.io/oauth2_proxy/auth-configuration#google-auth-provider

Known Issues

  • This setup is insecure as there is no SSL setup. I've only used it locally for testing.
  • oauth2_proxy does not support returning the groups a user is a memer of, so they cannot be passed to rundeck. This is why the group name is currently hardcoded. Not a good solution for most situations.