Skip to content

Instantly share code, notes, and snippets.

:shipit:
ship it

Michael Scott Hertzberg moimikey

:shipit:
ship it
Block or report user

Report or block moimikey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@moimikey
moimikey / gist:1389985
Created Nov 23, 2011
a more proper way to display posts from a specific category
View gist:1389985
<?php
add_filter( 'parse_query', 'hertzberg_filter_posts' );
/**
* Hook into parse_query to only return display posts from category id #1 in search & blog/index
*
* @access public
* @return void
*/
function hertzberg_filter_posts( $query ) {
@moimikey
moimikey / gist:1441514
Created Dec 7, 2011
Creating a temporary chroot jail to successfully install APC via pecl on a Media Temple (ve) server running Plesk Parallels
View gist:1441514
[root@hertzberg ~]# pecl install apc
downloading APC-3.1.9.tgz ...
Starting to download APC-3.1.9.tgz (155,540 bytes)
.................................done: 155,540 bytes
54 source files, building
running: phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
@moimikey
moimikey / gist:1450332
Created Dec 9, 2011
An alternative to glob() using SPL
View gist:1450332
<?php
/**
* Some words of wisdom:
* http://php.net/manual/en/class.directoryiterator.php
*/
class HertzbergFilterDots extends FilterIterator {
public function __construct( $path ) {
parent::__construct( new DirectoryIterator( $path ) );
}
@moimikey
moimikey / gist:1487428
Created Dec 16, 2011
Filtering WordPress output
View gist:1487428
<?php
/**
* Filter get_post() array with only the relative information that we need
*
* @access public
* @param integer $post_id
* @return array
* @author moimikey
*/
function hertzberg_filter_post_data( $post_id ) {
@moimikey
moimikey / gist:1860519
Created Feb 18, 2012
my own relative time converter
View gist:1860519
<?php
class Time {
/**
* Seconds
*/
const SECOND = 1;
/**
* Minutes
@moimikey
moimikey / gist:2313104
Created Apr 5, 2012
Check if you're infected with Flashback
View gist:2313104
cat ~/Library/LaunchAgents/* > /tmp/.hi && cat /Library/LaunchAgents/* >> /tmp/.hi && cat /tmp/.hi | grep -E 'zeo|mkeeper' | wc -l && rm -rf /tmp/.hi
@moimikey
moimikey / gist:3704281
Created Sep 12, 2012
super fast random WordPress tag
View gist:3704281
<?php
/**
* Return a random post tag from the wp_terms table
*
* average 0.4ms on a 3K table
*
* @author Michael Scott Hertzberg
* @return mixed|string
*/
function m_random_tag() {
@moimikey
moimikey / gist:5042795
Created Feb 26, 2013
latest pinterest feed using their simple rss feed transcoded to json.
View gist:5042795
<?php
class XmlToJson {
public function Parse( $url ) {
$fileContents = file_get_contents( $url );
$fileContents = str_replace( array(
"\n",
"\r",
"\t"
), '', $fileContents );
$fileContents = trim( str_replace( '"', "'", $fileContents ) );
View project-euler-1.coffee
([0...1000].filter (m) -> m % 3 is 0 or m % 5 is 0).reduce (s,h) -> s + h
@moimikey
moimikey / gist:7310211
Last active Dec 27, 2015
calculate data transfer bits
View gist:7310211
# Convert bit rate from and to another rate
#
# amount: data being converted
# unitFrom: `from` unit. bps|kbps|mbps|gbps
# unitTo: `to` unit. bps|kbps|mbps|gbps
#
# uses double bitwise not `~~` as `Math.floor`
# uses `+` as type coercion to `int`
Util.bitCalculate = (amount, unitFrom, unitTo, maxDecimals=2) ->
base = 1000
You can’t perform that action at this time.