Skip to content

Instantly share code, notes, and snippets.

View jbrooksuk's full-sized avatar
🧑‍🚀

James Brooks jbrooksuk

🧑‍🚀
View GitHub Profile
@jbrooksuk
jbrooksuk / head.html
Created January 5, 2013 19:03
Open graph tags used in my Octopress blog.
<!-- Rich Object stuff -->
<meta property="og:url" value="{{ site.url }}{{ page.url }}">
<meta property="og:type" content="website" />
{% if page.title %}<meta property="og:title" value="{% if page.title %}{{ page.title }}{% endif %}">
<meta property="og:description" value="{% if page.description %}{{ page.description }}{% else %}{{site.description}}{% endif %}">
{% else %}<meta property="og:title" value="{{ site.title }}">
<meta property="og:description" value="{{ description }}">
{% endif %}{% if page.cover %}<meta property="og:image" value="{{ site.url }}{{ page.cover }}">{% endif %}
@jbrooksuk
jbrooksuk / pascal_r.php
Created January 24, 2013 09:22
Pascals triangle in PHP.
<?php
function pascal_r($n) {
$aLines = [[1]];
for ($i=1; $i <= $n; $i++) {
$lastItem = $aLines[$i-1];
$aLines[$i] = [];
for ($j=0; $j <= $i; $j++) {
$aLines[$i][$j] = (isset($lastItem[$j - 1]) ? $lastItem[$j - 1] : 0) + (isset($lastItem[$j]) ? $lastItem[$j] : 0);
}
}
@jbrooksuk
jbrooksuk / flush_buffers.php
Created February 3, 2013 11:42
Clear PHP buffers.
<?php
function flush_buffers() {
echo(str_pad("", 2048, " ")); // Fix Chrome buffers.
ob_end_flush();
@ob_flush(); // Suppress potential errors
flush();
ob_start();
}
@jbrooksuk
jbrooksuk / working_git_branch.php
Created February 12, 2013 09:47
PHP Working Git Branch
<?php
$_gitHead = file('.git/HEAD', FILE_USE_INCLUDE_PATH);
$_gitHead = $_gitHead[0];
$_gitString = explode("/", $_gitHead);
$_gitBranchName = trim($_gitString[2]);
printf("<h4>Working Git Branch:</h4> <strong>&raquo; %s</strong>", $_gitBranchName);
?>
@jbrooksuk
jbrooksuk / Default (Windows).sublime-keymap.json
Created February 12, 2013 10:22
Enables auto-completion of ` characters, useful for SQL queries.
[
{ "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`$0`"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|$)", "match_all": true },
{ "key": "preceding_text", "operator": "not_regex_contains", "operand": "[`a-zA-Z0-9_]$", "match_all": true },
{ "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.single", "match_all": true }
]
},
{
"folders":
[
{
"file_exclude_patterns": ["._*", "node_modules/*/*.*"],
"folder_exclude_patterns": ["node_modules/*/*"]
}
],
"settings":
{
@jbrooksuk
jbrooksuk / named_args.php
Created February 28, 2013 10:28
PHP named arguments hack
<?php
namedArgsTest(array(
'one' => 'test',
'two' => 1,
'three' => 2
));
namedArgsTest();

Twitter公式クライアントのコンシューマキー

Twitter for iPhone

Consumer key: IQKbtAYlXLripLGPWd0HUA
Consumer secret: GgDYlkSvaPxGxC4X8liwpUoqKwwr3lCADbz8A7ADU

Twitter for Android

Consumer key: 3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys

Twitter for iPad

Consumer key: CjulERsDeqhhjSme66ECg

@jbrooksuk
jbrooksuk / gist:5194990
Created March 19, 2013 10:11
Sublime Text 3 Crash
Process: Sublime Text [30380]
Path: /Applications/Sublime Text.app/Contents/MacOS/Sublime Text
Identifier: com.sublimetext.3
Version: Build 3022 (3022)
Code Type: X86-64 (Native)
Parent Process: launchd [135]
User ID: 501
Date/Time: 2013-03-19 10:10:38.446 +0000
OS Version: Mac OS X 10.8.2 (12C60)
<?php
ini_set('memory_limit', '-1');
set_time_limit(0);
class ArrayToXML {
public static $XML = NULL;
public static $ENCODING = 'UTF-8';
const XML_VERSION = '1.0';