Skip to content

Instantly share code, notes, and snippets.

View peterchaula's full-sized avatar

Peter Chaula peterchaula

  • Johannesburg, South Africa
View GitHub Profile
@frabert
frabert / COPYING
Last active December 21, 2023 13:35
Favicons for HN
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
from selenium import webdriver
from getpass import getpass
def login_twitter(username, password):
driver = webdriver.Firefox()
driver.get("https://twitter.com/login")
username_field = driver.find_element_by_class_name("js-username-field")
password_field = driver.find_element_by_class_name("js-password-field")
@nienkedekker
nienkedekker / phpstorm-cs-fixer.md
Last active February 2, 2024 03:09
Set up PHP-CS-Fixer in PHPStorm

Use PHP-CS-Fixer in PHPStorm

  • Install PHP-CS-Fixer on your local machine according to these instructions: https://github.com/FriendsOfPHP/PHP-CS-Fixer
  • Open PHPStorm, Preferences > Tools > External Tools and enter these values: img
  • Program, edit to match your path where PHP-CS-Fixer lives: /.composer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer
  • Parameters: --rules=@PSR2 --verbose fix $FileDir$/$FileName$. Note that previous verions of PHP-CS-Fixer used --levels instead of --rules.
  • Working directory: $ProjectFileDir$

Click OK and Apply. Now we'll set up a shortcut.

  • Go to Preferences > Keymap and search for "PHP Fixer" (or whatever name you gave it). Add whatever shortcut you like, I'm using ctrl + cmd + ]:
@peterchaula
peterchaula / clean-branches.sh
Created December 21, 2016 09:52
Leave master as the only branch
!#/bin/sh
git checkout master; \
git remote prune origin; \
for i in `git branch`; do
echo $i;
git branch -D $i;
done
#!/bin/bash
for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do [ -f $CPUFREQ ] || continue; echo -n $1 > $CPUFREQ; done
@fntlnz
fntlnz / self-signed-certificate-with-custom-ca.md
Last active June 25, 2024 12:19
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@matteblair
matteblair / TileGlob.py
Created June 27, 2016 16:59
Grab some mapzen vector tiles!
import os
import urllib2
# This is a library of tile tools from Mapbox. Install with 'pip install mercantile'.
import mercantile
# Set the bounds of the area you want to download. (West, South, East, North)
bounds = (-105, 39.99, -104.99, 40)
zooms = [14]
@josevalim
josevalim / phoenix showdown rackspace onmetal io.md
Last active October 31, 2022 13:59 — forked from omnibs/phoenix showdown rackspace onmetal io.md
Phoenix Showdown Comparative Benchmarks @ Rackspace

Comparative Benchmark Numbers @ Rackspace

I've taken the benchmarks from Matthew Rothenberg's phoenix-showdown, updated Phoenix to 0.13.1 and ran the tests on the most powerful machines available at Rackspace.

Results

Framework Throughput (req/s) Latency (ms) Consistency (σ ms)
@rippo
rippo / dropdown.change.jsx
Last active August 10, 2018 22:04
ReactJS dropdown list example that gets data from a AJAX call with an on change event
var MyParentChange = React.createClass({
getInitialState: function() {
return {
data: [], value: {}, showOutput: false
}
},
componentDidMount: function() {
$.get(this.props.source, function(result) {
@barbolani
barbolani / clean-names
Created February 18, 2015 18:45
Bash script to clean up file names
#!/bin/bash
#
# Often multimedia files downloaded from the internet contain
# as part of the filename things like the site from where they came
# the local language of the audio and such info that is not useful
# when you archive the file to your multimedia repository.
#
# This script renames a set of files, removing everything that does
# not look like part of the file name
#