Skip to content

Instantly share code, notes, and snippets.

View PHLAK's full-sized avatar
Coffee... always coffee...

Chris Kankiewicz PHLAK

Coffee... always coffee...
View GitHub Profile
@PHLAK
PHLAK / .Xmodmap
Created October 25, 2012 19:22
Xmodmod key map for fixing Mac Pro keyboard
! Set key codes
keycode 37 = Control_L
keycode 105 = Control_R
keycode 64 = Super_L
keycode 108 = Super_R
keycode 133 = Alt_L
keycode 134 = Alt_R
keycode 191 = Print
! Clear key modifier mappings
@PHLAK
PHLAK / archive-screenshots.sh
Created February 16, 2013 19:38
Screenshot archiving script.
#!/bin/bash
DAYS=5
# Calculate the threshold value
THRESHOLD=$(($DAYS * 24 * 60 * 60))
# Set current time
TIMESTAMP=$(date +%s)
@PHLAK
PHLAK / listRepos.php
Last active December 15, 2015 10:49
PHP-CLI script to output a list of repositories (one per line) belonging to the user(s) specified.
#!/usr/bin/php -q
<?php
// Disable errors
error_reporting(0);
foreach ($argv as $user) {
if ($user !== $argv[0]) {
@PHLAK
PHLAK / Singleton.php
Last active December 16, 2015 08:28
Example PHP singleton class for reference. For the record, singletons are evil: http://stackoverflow.com/a/138012/27025
<?php
/**
* Example PHP singleton class for reference.
* For the record, singletons are evil:
* http://stackoverflow.com/a/138012/27025
*/
class Singleton {
/**
@PHLAK
PHLAK / regex.php
Created April 19, 2013 19:37
Regex Testing
<?php
// Read file contents to string
$doc = file_get_contents('secret-doc.txt');
// Run the regex on the string
preg_match_all('/\(?[0-9]{3}\)?[- ]?[0-9]{3}[-\ ]?[0-9]{4}/', $doc, $matches);
// Print out an array of matches
print_r($matches); die();
@PHLAK
PHLAK / reflectionTesting.php
Created April 24, 2013 23:15
Testing out PHP's reflection functionality.
<?php
function doSomeShit($foo, $bar, $baz) {
// Do some shit...
}
$function = new ReflectionFunction('doSomeShit');
foreach ($function->getParameters() as $parameter) {
@PHLAK
PHLAK / example.conf
Last active December 25, 2015 19:19
UberGallery Nginx server config example
server {
root /var/www/example;
server_name example.com www.example.com;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php;
}
@PHLAK
PHLAK / jquery-cdn-test.sh
Created January 31, 2014 17:25
Test average response times for jQuery from Google and jQuery CDNs
#!/bin/bash
## Set the url
if [[ "$1" == "google" ]]; then
URL="ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"
elif [[ "$1" == "jquery" ]]; then
URL="code.jquery.com/jquery-2.0.3.min.js"
@PHLAK
PHLAK / ping-test.sh
Created February 11, 2014 18:11
24 hour while loop in bash
#!/bin/bash
## Script start time
START=$(date +%s)
## Total run time
DURRATION=$((60 * 60 * 24))
## Total running time
UPTIME=$(($(date +%s) - $START))
@PHLAK
PHLAK / keybase.md
Created March 25, 2014 16:50
keybase.md

Keybase proof

I hereby claim:

  • I am PHLAK on github.
  • I am ChrisKankiewicz (https://keybase.io/ChrisKankiewicz) on keybase.
  • I have a public key whose fingerprint is 7C25 1D83 939B 1898 6DD6 7F0A E008 E594 373D 7E9D

To claim this, I am signing this object: