Skip to content

Instantly share code, notes, and snippets.

@resting
resting / gist:716214
Created November 26, 2010 02:50
Drupal page template on nodetype
/**
* Override or insert PHPTemplate variables into the templates.
*/
function _phptemplate_variables($hook, $vars) {
if ($hook == 'page') {
// Add page template suggestions based on node type, if we aren't editing the node.
if ($vars['node'] && arg(2) != 'edit') {
$vars['template_files'][] = 'page-nodetype-'. $vars['node']->type;
}
@resting
resting / thememe
Created January 16, 2012 23:58
Simple script that creates empty base files for Drupal 7 theme
touch thememe.info
touch style.css
touch page.tpl.php
touch region.tpl.php
touch block.tpl.php
touch node.tpl.php
touch comment-wrapper.tpl.php
touch comment.tpl.php
touch template.php
mkdir images
@resting
resting / gist:1632284
Created January 18, 2012 10:10
PHP Save array to file
<?php
$data=array(
"name"=>"beckham",
"address"=>"LA"
);
$filename = 'data.txt';
$string = '';
foreach($data as $key => $val) {
@resting
resting / dbb
Created June 3, 2012 06:07
backup mysql script
# replace [] with your own config
# replace own dir to save
# echo doesn't work. hmm...
mysql -u[uname] -p'[pwd]' -e "show databases" \
| grep -Ev 'Database|information_schema' \
| while read dbname; \
do \
echo 'Dumping $dbname' \
mysqldump -u[uanme] -p'[pwd]' $dbname > ~/db_backup/$dbname.sql;\
@resting
resting / markdown.xml
Created July 22, 2012 10:16 — forked from lg0/markdown.xml
Markdown Syntax Highlighting for Sublime text 2
<!-- copy this to YOUR_THEME.tmTheme-->
<dict>
<key>name</key>
<string>diff: deleted</string>
<key>scope</key>
<string>markup.deleted</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#EAE3CA</string>
@resting
resting / gist:3421760
Created August 22, 2012 02:41 — forked from RiANOl/gist:1077723
AES128 encrypt/decrypt in PHP with base64
<?
function aes128Encrypt($key, $data) {
if(16 !== strlen($key)) $key = hash('MD5', $key, true);
$padding = 16 - (strlen($data) % 16);
$data .= str_repeat(chr($padding), $padding);
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, str_repeat("\0", 16)));
}
function aes128Decrypt($key, $data) {
@resting
resting / Default (OSX).sublime-keymap
Last active October 9, 2015 02:08
Sublime Key Binding
[
{
"keys" : ["alt+shift+w"],
"command" : "insert_snippet",
"args": {
"contents": "<${1:p}>${0:$SELECTION}</${1}>"
}
},
{ "keys": ["j", "j"], "command": "exit_insert_mode",
"context":
@resting
resting / Preferences.sublime-settings
Last active October 11, 2015 03:48
Sublime User Settings
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"draw_centered": true,
"font_size": 10.0,
"gutter": true,
"ignored_packages":
[
"SyncedSideBar"
],
"indent_guide_options":
@resting
resting / gist:3869761
Created October 11, 2012 02:14
Chrome inspector theme
/**********************************************/
/*
/* Darker Skin by Darcy Clarke - 2011
/*
/* For how to install, or more themes, check out:
/* http://darcyclarke.me/design/skin-your-chrome-inspector/
/*
/* Color scheme is based on Joe Bergantine's Specials Board:
/* http://joebergantine.com/werkstatt/seestyle
/*
@resting
resting / gist:4134489
Created November 23, 2012 08:14
Sublime Monokai.tmTheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Monokai</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>