Skip to content

Instantly share code, notes, and snippets.

View mbijon's full-sized avatar
🎯
Focusing

Mike Bijon mbijon

🎯
Focusing
View GitHub Profile
#!/usr/bin/env ruby
require 'readline'
def prompt(prompt="> ")
input = nil
prompt += " " unless prompt =~ /\s$/
loop do
input = Readline.readline(prompt)
break if input.length > 0
end
'''
This is a module that defines some helper classes and functions for
expiring groups of related keys at the same time.
Written July 1-2, 2013 by Josiah Carlson
Released into the public domain
'''
import time
<?php
/*
Usage:
$frag = new CWS_Fragment_Cache( 'unique-key', 3600 ); // Second param is TTL
if ( !$frag->output() ) { // NOTE, testing for a return of false
functions_that_do_stuff_live();
these_should_echo();
// IMPORTANT
$frag->store();
// YOU CANNOT FORGET THIS. If you do, the site will break.
@mbijon
mbijon / yolo.php
Last active August 29, 2015 14:12 — forked from staylor/yolo.php
<?php
class React_YOLO {
public function __construct() {
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
}
public function admin_menu() {
add_menu_page( 'React', 'React', 'edit_posts', 'react', array( $this, 'page' ) );
}
@mbijon
mbijon / pivotal_export.php
Created May 25, 2011 23:37 — forked from anonymous/pivotal_export.php
Expose Mantis bugs for PivotalTracker-import
<?php
/*
Mantis -> PivotalTracker export script
Based on scripts from this support thread:
- http://community.pivotaltracker.com/pivotal/topics/synchronize_pivotal_tracker_with_mantis
To configure:
1.) Put this script in your Mantis root folder (one that contains 'core.php')
2.) Create an "Other" integration in Pivotal
3.) In the integration set a Mantis user/pass that has read rights on the project
@mbijon
mbijon / command.sh
Created October 29, 2011 18:30 — forked from felixge/command.sh
Bash stuff for fighting a weak DOS attack
# Here a few bash one-liners that helped me analyze / fight a weak DOS attack against debuggable.com. Mostly for future reference.
# The attacker was opening lots of tcp connections without sending data, I believe it's called a SYN flood, see: http://tools.ietf.org/html/rfc4987#section-3.2
# Step 0: Check what is going on at port 80
$ netstat -tan | grep ':80 ' | awk '{print $6}' | sort | uniq -c
# Step 1: Increase the number of available fds
$ ulimit -n 32000
# Step 2: Restart your webserver, for me:
@mbijon
mbijon / TCB_JSON_API.php
Created November 3, 2011 06:55 — forked from mikeschinkel/TCB_JSON_API.php
Creates JSON class for Tom C. Barret to load tickets via a RESTful API
<?php
/**
* Creates JSON class for Tom C. Barrett to load tickets via a RESTful API:
*
* @example:
*
* URL: http://example.com/api/ticket/12345
*
* @see:
*
@mbijon
mbijon / generate_update.sh
Created November 20, 2011 08:31 — forked from xentek/generate_update.sh
Generate the necessary sql statements to move a WordPress site from one environment to another
#!/usr/bin/env bash
echo "@@@ @@@ @@@@@@@@ @@@ @@@ @@@@@@@ @@@@@@@@ @@@ @@@ "
echo "@@@ @@@ @@@@@@@@ @@@@ @@@ @@@@@@@ @@@@@@@@ @@@ @@@ "
echo "@@! !@@ @@! @@!@!@@@ @@! @@! @@! !@@ "
echo "!@! @!! !@! !@!!@!@! !@! !@! !@! @!! "
echo " !@@!@! @!!!:! @!@ !!@! @!! @!!!:! @!@@!@! "
echo " @!!! !!!!!: !@! !!! !!! !!!!!: !!@!!! "
echo " !: :!! !!: !!: !!! !!: !!: !!: :!! "
echo ":!: !:! :!: :!: !:! :!: :!: :!: !:! "
@mbijon
mbijon / .gitignore
Created September 29, 2012 08:11 — forked from redoPop/.gitignore
Template .gitignore file for WordPress projects
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
Date: Thu, 20 Dec 2012 16:28:50 -0500
From: Daryl Koopersmith <koop@wordpress.org>
Subject: Re: [wp-hackers] Javascript bind event for 3.5's new
uploader?
To: wp-hackers@lists.automattic.com
Message-ID: <DB193711A3AC46F1AA76AAE5940586BA@gmail.com>
Content-Type: text/plain; charset="utf-8"
> I'm trying to add an action when the uploader is displayed, but I
> can't seem to call the .on or .bind from external code.