Skip to content

Instantly share code, notes, and snippets.

@lkorth
lkorth / generate_key.php
Last active February 20, 2016 22:02
PHP function for generating cryptography secure strings of a given length
<?php
/**
* PHP function for generating cryptography secure strings of a given length
*
* @param $length the length in bytes for the generated key
* @return the cryptography secure string of {$length} length
*/
function generate_key($length) {
$strong = FALSE;
@lkorth
lkorth / resolve_url.php
Last active February 20, 2016 22:02
PHP function to resolve a short URL in to its full redirected URL
<?php
function resolve_url($url) {
$headers = get_headers($url);
$headers = array_reverse($headers);
foreach($headers as $header) {
if (strpos($header, 'Location: ') === 0) {
$url = str_replace('Location: ', '', $header);
break;
}
@lkorth
lkorth / gist:3932557
Created October 22, 2012 16:58
Curl Speed Test
curl -o /dev/null http://speedtest.wdc01.softlayer.com/downloads/test500.zip
@lkorth
lkorth / gist:4061732
Created November 12, 2012 20:38
Understanding PHP AES Encryption
<?php
// This PHP code snippet provides a basic understanding of
// PHP's AES encryption. Mirrored from here: http://www.chilkatsoft.com/p/php_aes.asp
// The first thing to understand is the meaning of these constants:
// MCRYPT_RIJNDAEL_128
// MCRYPT_RIJNDAEL_192
// MCRYPT_RIJNDAEL_256
// You would think that MCRYPT_RIJNDAEL_256 specifies 256-bit encryption,
@lkorth
lkorth / AndroidManifest.xml
Last active December 12, 2023 15:52
Simple Android service that will turn the screen on when the proximity sensor reports a object is close to the device.
<uses-permission android:name="android.permission.WAKE_LOCK" />
<service android:name=".ProxService" />
@lkorth
lkorth / git stats
Created February 6, 2013 21:35
File and line changes for today
git diff --shortstat "@{8 hours ago}"
@lkorth
lkorth / keybase.md
Created March 12, 2014 15:29
Keybase proof

Keybase proof

I hereby claim:

  • I am lkorth on github.
  • I am lkorth (https://keybase.io/lkorth) on keybase.
  • I have a public key whose fingerprint is 0B8B 59CB C364 A838 EB1B ABBD BBF0 3918 CA74 82D0

To claim this, I am signing this object:

@lkorth
lkorth / gif-record.sh
Created November 14, 2014 20:16
Command line script to record a video of your screen on Android and convert it to a animated gif
function process_video {
# let Android finish the recording
sleep 5
# pull the video off the device
adb pull /sdcard/video-to-gif.mp4 .
adb shell rm /sdcard/video-to-gif.mp4
mkdir recorded-gifs
#!/usr/bin/python
import sys
import argparse
import os
import re
'''
A simple script to create lower-resolution Android drawables from higher-resolution ones.
@lkorth
lkorth / LICENSE
Created February 20, 2016 22:05
MIT License
The MIT License (MIT)
Copyright (c) 2015 Luke Korth
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: