Skip to content

Instantly share code, notes, and snippets.

View mapkyca's full-sized avatar
💭
Always out numbered, Never out gunned

Marcus Povey mapkyca

💭
Always out numbered, Never out gunned
View GitHub Profile
@mapkyca
mapkyca / handy_shell.md
Last active December 14, 2015 18:38
Useful commands, so I don't have to keep looking

Useful shell commands

Shell

  • Find which directories are the disk hogs

    du --max-depth=1 -h | sort -h

@mapkyca
mapkyca / gist:5091326
Created March 5, 2013 15:58
Add auto setting created and modified timestamps to a database table.
-- The table
CREATE TABLE `my_table` (
field1 varchar(50),
....
createdTime datetime NOT NULL, -- NOT NULL is important to trigger the trigger
modifiedTime TIMESTAMP -- Timestamps automatically update on insert
);
@mapkyca
mapkyca / jquery_gotchas.md
Created November 8, 2012 14:18
Some JQuery gotchas

JQuery Gotchas

Here are some notes when hacking on jquery, compiled over time.

JQuery Dialogs

  • If your browser scrolls to the top of the screen when the dialog opens and you're opening it from an onclick event on an Anchor tag, make sure you return false in the click event.
@mapkyca
mapkyca / gist:3142991
Created July 19, 2012 10:50
Paypal IPN Example Response
Some example paypal response for reference:
array (
'test_ipn' => '1',
'payment_type' => 'instant',
'payment_date' => '03:46:59 Jul 19, 2012 PDT',
'payment_status' => 'Completed',
'address_status' => 'confirmed',
'payer_status' => 'unverified',
'first_name' => 'John',
@mapkyca
mapkyca / gist:2909223
Created June 11, 2012 09:15
Strip ANSI escape codes from text strings
sed -r "s/\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g"
@mapkyca
mapkyca / gist:2420796
Created April 19, 2012 12:52
Quickly remove non-alpha chars from a string
// Quick regexp to remove non-alpha chars from a string. Very handy
$string = preg_replace("/[^a-zA-Z0-9\s]/", "", $string);
@mapkyca
mapkyca / gist:2420795
Created April 19, 2012 12:52
Quickly remove non-alpha chars from a string
// Quick regexp to remove non-alpha chars from a string. Very handy
$string = preg_replace("/[^a-zA-Z0-9\s]/", "", $string);
@mapkyca
mapkyca / gist:2299663
Created April 4, 2012 08:16
Note To Self: Change the OSX dock title within Java
/*
* To correctly set the doc name of a java App in OSX, use....
*/
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Foo");
@mapkyca
mapkyca / gist:2008119
Created March 9, 2012 19:04
Excel / Open Office timestamp conversions.
DATE -> SECONDS
---------------
(CELL - DATE (1970,1,1))*86400
TIME -> SECONDS
---------------
@mapkyca
mapkyca / gist:1922850
Created February 27, 2012 09:50
Lenny -> Squeeze
Prep:
- apt-get update && apt-get upgrade && apt-get dist-upgrade
- Check for holds
dpkg --audit
dpkg --get-selections | grep hold
aptitude & press "g"
- Edit sources.list s/lenny/squeeze
- apt-get update NOTE: Debian docs say don't use aptitude to upgrade.
- apt-get upgrade to to a safe-upgrade