Skip to content

Instantly share code, notes, and snippets.

@eethann
eethann / gist:3343372
Created August 13, 2012 19:14
emacs init.el for a Node.js REPL via js-comint
(require 'js-comint)
(setq inferior-js-program-command "node") ;; not "node-repl"
;; Use your favorited js mode here:
(add-hook 'js3-mode-hook '(lambda ()
(local-set-key "\C-x\C-e"
'js-send-last-sexp)
(local-set-key "\C-\M-x"
'js-send-last-sexp-and-go)
(local-set-key "\C-cb"
'js-send-buffer)
@eethann
eethann / gist:3160925
Created July 22, 2012 20:12
phptemplate to twig conversion
{% if main_menu %}
<div id="main-menu" class="navigation">
{{ theme('links__system_main_menu', {
links: main_menu,
attributes: {
id: 'main-menu-links',
class: [ links, clearfix ]
},
heading: {
text: t('Main menu'),
@eethann
eethann / init.el
Created June 4, 2012 21:26
el-git drupal init.el
(add-to-list 'load-path "~/.emacs.d/elisp")
(add-to-list 'load-path "~/.emacs.d/elisp/php-mode")
(add-to-list 'load-path "~/.emacs.d/elisp/deft")
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/") t)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)
(add-to-list 'load-path "~/.emacs.d/el-get/el-get")
@eethann
eethann / drupal-async-example.test.js
Created March 6, 2012 05:41
Drupal QUnit Async Testing Example
// Using a jQuery queue is a bit more complicated, but worth it.
(function($) {
Drupal.tests.myBackboneApp = {
getInfo: function() {
return {
name: 'Backbone App Example',
description: 'Example of a Backbone test in Drupal QUnit',
group: 'BackboneApp'
};
},
@eethann
eethann / .vimrc-statusline.vim
Created December 15, 2011 17:14
vimrc segment for syntastic- and fugitive-enabled statusline.
" from https://github.com/spf13/spf13-vim/blob/master/.vimrc
if has('statusline')
set laststatus=2
" Broken down into easily includeable segments
set statusline=%<%f\ " Filename
set statusline+=%w%h%m%r " Options
set statusline+=%{fugitive#statusline()} " Git Hotness
set statusline+=\ [%{&ff}/%Y] " filetype
set statusline+=\ [%{getcwd()}] " current dir
set statusline+=%#warningmsg#
@eethann
eethann / drupalcs_fix.sed
Created December 15, 2011 16:41
Simple sed script to resolve common Drupal.org coding standards violations.
#!/usr/bin/env sed -f
# whitespace at end of lines
s/\s\+$//
# fix comma followed by non-space character
# don't be picky, this is correct even for text!
/function/!s/\(,\)\(\S\)/\1 \2/g
# fix comments may not appear after statements
<?php
/**
* when twitpic URL is found in filtered $text, download the image file
* - use curl to get info from API on actual URL (w/ temporary auth key)
* - then use that URL to download the file to local $dl_dir
* @return downloaded file path or FALSE
*/
function _twitpic_filter_download_twitpic($pic_code) {
$pic_url = 'http://twitpic.com/show/full/' . $pic_code;