Skip to content

Instantly share code, notes, and snippets.

@malachany
malachany / Ssl.php
Created May 13, 2011 05:42
SSL Redirect Custom Zend Framework Plugin
<?
/**
* SSL Redirect Custom Controller Plugin
*
* This plugin will allow you to redirect your users between https:// and
* http:// and vice versa. All you have to do is add the plugin to your
* stack and add what modules, controllers, and actions you want to have
* SSL and thats it.
*
*
# These are my notes from the PragProg book on CoffeeScript of things that either
# aren't in the main CS language reference or I didn't pick them up there. I wrote
# them down before I forgot, and put it here for others but mainly as a reference for
# myself.
# assign arguments in constructor to properties of the same name:
class Thingie
constructor: (@name, @url) ->
# is the same as:
@siwadon
siwadon / test-memcached.php
Created August 3, 2011 03:29
simple memcached test
<html>
<body>
<?php
ini_set('display_errors', 1);
//memcache
echo "memcache " . extension_loaded("memcache") . "<br/>";
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
$key = md5('test-memcache'); //something unique
@terrancesnyder
terrancesnyder / regex-japanese.txt
Created November 7, 2011 14:05
Regex for Japanese
Regex for matching ALL Japanese common & uncommon Kanji (4e00 – 9fcf) ~ The Big Kahuna!
([一-龯])
Regex for matching Hirgana or Katakana
([ぁ-んァ-ン])
Regex for matching Non-Hirgana or Non-Katakana
([^ぁ-んァ-ン])
Regex for matching Hirgana or Katakana or basic punctuation (、。’)
@jdanbrown
jdanbrown / log-color
Created November 21, 2011 04:51
log4j logs in color!
#!/bin/bash -eu
#
# Color log4j-style logs for easier visual parsing.
#
# Usage:
# tail foo.log | log-color
# run-service | log-color
black="` tput setaf 0; tput bold`"
red="` tput setaf 1; tput bold`"
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@hakre
hakre / nested-tree-and-iterator.php
Created February 28, 2012 17:35
Getting nested set model into a <ul> but hiding “closed” subtrees
<?php
/**
* Getting nested set model into a <ul> but hiding “closed” subtrees
*
* @link http://stackoverflow.com/a/7786733/367456
*/
// $categories = get_categories();
$categories = get_categories_large();
$current = array('lft' => '14', 'rgt' => '13');
@nrk
nrk / command.txt
Created April 2, 2012 19:19
Using ffprobe to get info from a file in a nice JSON format
ffprobe -v quiet -print_format json -show_format -show_streams "lolwut.mp4" > "lolwut.mp4.json"
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter