Skip to content

Instantly share code, notes, and snippets.

View beatak's full-sized avatar
🍄
Mushroom

Takashi M beatak

🍄
Mushroom
  • San Francisco, CA
View GitHub Profile
jQuery.fn.noisy = function(opacity) {
opacity = opacity || 0.1;
var wrapper = jQuery(this).wrapInner('<div />').children();
var canvas = document.createElement("canvas");
var w = canvas.width = 100;
var h = canvas.height = 100;
var ctx = canvas.getContext("2d");
var x, y, r, g, b;
for (x=0; x < w; ++x) {
for (y=0; y< h ; ++y) {
@beatak
beatak / fix.patch
Created March 9, 2011 02:22
nit-picky: avoiding error on dev with exclude_pages.php
diff -c exclude-pages/exclude_pages.php trunk/exclude_pages.php
*** exclude-pages/exclude_pages.php 2010-06-18 09:09:20.000000000 -0400
--- trunk/exclude_pages.php 2011-03-08 21:11:55.000000000 -0500
***************
*** 172,184 ****
// one row seems more sensible.
function ep_update_exclusions( $post_ID ) {
// Bang (!) to reverse the polarity of the boolean, turning include into exclude
! $exclude_this_page = ! (bool) $_POST['ep_this_page_included'];
// SWTODO: Also check for a hidden var, which confirms that this checkbox was present
@beatak
beatak / private.xml
Created April 4, 2011 14:33
Swap keys on Command (L) and Option (L) by KeyRemap4MacBook
<?xml version="1.0"?>
<root>
<list>
<item>
<name>Swap Command_L and Option_L on Terminal</name>
<identifier>local.terminalComL_OptLSwap</identifier>
<only>TERMINAL</only>
<block>
<autogen>--KeyToKey-- KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen>
<autogen>--KeyToKey-- KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen>
@beatak
beatak / gist:905211
Created April 6, 2011 05:57
Disable admin bar
<?php
add_filter( 'wp_loaded', 'whatever_yours');
function whatever_yours() {
wp_deregister_script('admin-bar');
wp_deregister_style('admin-bar');
remove_action('wp_head', 'wp_admin_bar_header');
remove_action('wp_head', 'wp_admin_bar_render', 1000);
remove_action('wp_head', '_admin_bar_bump_cb');
@beatak
beatak / gist:1001472
Created May 31, 2011 23:11
this would make me feel better when I type it wrong
diff --git a/build.xml b/build.xml
--- a/build.xml
+++ b/build.xml
@@ -XXXX,6 +XXXX,18 @@
+ <!-- joke -->
+ <condition property="japanese_people">
+ <equals arg1="takashi" arg2="${user.name}" />
+ </condition>
<html><head></head><body><img src="failsnail.jpg"><p>
</p><pre>lb1 (10.1.0.20)</pre><a href="http://www.flickr.com/photos/ronin691/2634356788/">failsnail</a>
</body></html>
@beatak
beatak / gist:1104355
Created July 25, 2011 15:12
[SCAM] Database System Verification
Delivered-To: ***@gmail.com
Received: by 10.42.241.138 with SMTP id le10cs107555icb;
Mon, 25 Jul 2011 07:49:08 -0700 (PDT)
Received: by 10.236.192.132 with SMTP id i4mr5945974yhn.107.1311605346815;
Mon, 25 Jul 2011 07:49:06 -0700 (PDT)
Return-Path: <[email protected]>
Received: from p3plwbeout17-03.prod.phx3.secureserver.net (p3plsmtp17-03-2.prod.phx3.secureserver.net [173.201.193.166])
by mx.google.com with SMTP id r8si2075773ibr.81.2011.07.25.07.49.05;
Mon, 25 Jul 2011 07:49:05 -0700 (PDT)
Received-SPF: neutral (google.com: 173.201.193.166 is neither permitted nor denied by best guess record for domain of [email protected]) client-ip=173.201.193.166;
var multiplyString = function (char, len) {
return (new Array(len + 1)).join(char);
};
var print_r = function (target, depth) {
depth = (depth ? depth : 0);
if (depth > 5) {
throw new Error('too deep recurrsion');
}
var result, i, len, _result,
@beatak
beatak / gist:1157884
Created August 19, 2011 20:12
Force break line with using &shy;
var shyizeElements = function ($elms, limit) {
$elms.each(
function (n, elm) {
var $elm = $(elm),
str = shyize($elm.text(), limit);
str = str.replace('<', '&lt;', 'g').replace('>', '&gt;', 'g');
$elm.html(str);
}
);
};
@beatak
beatak / gist:1187550
Created September 1, 2011 23:17
Uniquify array
/**
* @param arr {Array}
* @returns {Array} a new array of sorted, unique elements of give array.
*/
var uniquify = function (arr) {
arr.sort();
var result = [];
for (var i = 0, len = arr.length; i < len; ++i) {
if (i === 0) {
result[result.length] = arr[i];