Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard George parsingphase

View GitHub Profile
@parsingphase
parsingphase / sum-sigs.py
Last active Jun 25, 2020
Petitions.parliament.uk counter script
View sum-sigs.py
#!/usr/bin/env python3
import json
file_path = '241584.json'
with open(file_path, 'r') as f:
data = json.loads(''.join(f.readlines()))
sbyc = data['data']['attributes']['signatures_by_country']
@parsingphase
parsingphase / script-tags.js
Last active Jul 22, 2016
List script tags bookmarklet
View script-tags.js
javascript:(function () { var ss = [], sc = {}, dc = 0, hs = false; $("script[src]").each(function (i, tag) { var s = $(tag).attr('src'); if (!sc.hasOwnProperty(s)) { sc[s] = 0; } sc[s]++; ss.push(s); }); console.log(ss.length + ' script tags present on ' + document.URL + " \n\n" + ss.sort().join("\n")); for (var i in sc) { if (sc.hasOwnProperty(i)) { if (sc[i] > 1) { if (!hs) { console.log('** Duplicates: **'); hs = true; } dc++; console.log(i + ' seen ' + sc[i] + ' times'); } } } window.alert(ss.length + ' script URLs listed in console including ' + dc + ' duplicates');})();
@parsingphase
parsingphase / bountyHunterName.php
Last active Feb 18, 2016
Accidental Star Wars Name Generator
View bountyHunterName.php
<?php
function generateJediName($words = 2)
{
$vowels = ['a', 'e', 'i', 'o', 'u'];
$parts = [];
for ($i = 0; $i < $words; $i++) {
$parts[$i] = chr(rand(65, 90)); // upper case
$wordLength = rand(4, 7);
for ($j = 0; $j < ($wordLength - 1); $j++) {
@parsingphase
parsingphase / .bash_profile
Created Feb 2, 2016
Bash profile with switching functions to use multiple homebrew versions of PHP.
View .bash_profile
export PS1="\u@rgmac:\w $ "
export PATH=/Users/richardg/Library/Python/2.7/bin/:$PATH
export PATH_DIST_PHP=$PATH
function setPhp56 {
export PATH=/usr/local/Cellar/php56/5.6.17/bin:$PATH_DIST_PHP
php --version
}
function setPhp7 {
@parsingphase
parsingphase / ElCapitanPeclInstallMongo.txt
Created Nov 10, 2015
Install mongo pecl extension on OSX. Pointer rather than step-by-step
View ElCapitanPeclInstallMongo.txt
Help from:
http://toodlepip.co.uk/2014/installing-mongo-mongo-php-mac-osx-mavericks-mamp/
https://jellystyle.com/2012/12/installing-php-extensions-with-mamp
Install MAMP: https://www.mamp.info/en/downloads/
export PATH=/Applications/MAMP/bin/php/php5.6.10/bin:$PATH
PHP src from http://php.net/downloads.php - get same version as MAMP uses!
@parsingphase
parsingphase / heartbreaker.css
Last active Nov 4, 2015
Custom CSS (user stylesheet) to set your own emoji for twitter's "like" icon. Replace "content" emoji with your own choice.
View heartbreaker.css
/* Developed from http://www.shortlist.com/tech/gadgets/heres-how-to-replace-twitters-heart-with-your-own-emoji
Copy / paste your own emojis into the content: lines below
Safari: Preferences -> advanced -> Style Sheet
Other browsers: https://userstyles.org/
*/
.HeartAnimationContainer {
visibility: hidden;
}
.HeartAnimationContainer:after {
@parsingphase
parsingphase / dockbounce
Created Oct 13, 2015
Turn OSX dock bouncing on or off
View dockbounce
#!/bin/bash
param=$1
param=$(echo "$param" | tr '[:lower:]' '[:upper:]')
case $param in
"ON")
state=TRUE
;;
"TRUE")
state=TRUE
@parsingphase
parsingphase / sshd_config
Last active Aug 29, 2015
Fix key negotiation issue from PHPStorm on mac
View sshd_config
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
# http://stackoverflow.com/questions/26424621/algorithm-negotiation-fail-ssh-in-jenkins
@parsingphase
parsingphase / screencheck.sh
Created May 20, 2015
Check for screen on login (call in .bashrc)
View screencheck.sh
#!/bin/bash
echo
if [ ${TERM^^} = 'SCREEN' ]; then
echo 'Running under screen. CTRL-A ? for help'
else
echo 'Not in a screen; the following are available:'
screen -ls
fi;
View clusterTests.js
console.log('Start...');
var cluster = require('cluster');
console.log('required');
var isMaster = cluster.isMaster;
console.log('isMaster? ' + isMaster);
if (isMaster) {
// Listen for dying workers
You can’t perform that action at this time.