Skip to content

Instantly share code, notes, and snippets.

@Phize
Phize / gist:1268489
Created October 6, 2011 20:02
An emulation of Adobe Photoshop's layer blend mode on RSL(Renderman Shading Language).
# Renderman Shading Language
# http://twitter.com/Phize/status/122033158265901056
float pblend(float c1; float c2; string mode) {
float result = 0.0;
float d = 0.0;
if (mode == "normal") {
result = c2;
}
@Phize
Phize / .vimrc
Created December 28, 2011 12:57
Vim: CSS tag list with Ctags (patched) + Tagbar plugin.
" Ctags (patch): http://designtomarkup.com/vim/taglist-ctags-css-patch
" Tagbar : https://github.com/majutsushi/tagbar
" Screenshot : http://twitpic.com/7zq4d7
"Tagbar
noremap <silent> <Leader>t :<C-u>TagbarToggle<CR>
let g:tagbar_type_css = {
\ 'ctagstype' : 'Css',
\ 'kinds' : [
@Phize
Phize / get_template_part.php
Last active December 27, 2015 13:39
WordPress: passing arguments to get_template_part() #wp
<?php
function my_get_template_part( $slug, $name = null, $vars = [] ) {
do_action( 'get_template_part_' . $slug, $slug, $name );
$templates = [];
$name = (string) $name;
if ( $name !== '' ) {
$templates[] = $slug . '-' . $name . '.php';
}
@Phize
Phize / feednews.php
Created April 29, 2012 12:56
PHPTAL: a PHPTALES to check if a value exists and is not empty string.
function phptal_tales_notEmpty($src, $nothrow) {
$src = trim($src);
if (ctype_alnum($src)) return 'isset($ctx->' . $src . ') && "" !=== $ctx->' . $src;
return '(null !== ($path = $ctx->path($ctx,' . PHPTAL_Php_TalesInternal::string($src) . ', true)) && "" !== $path)';
}
@Phize
Phize / gist:2218076
Created March 27, 2012 17:13
Bash function to get Git repository' basename.
function git_repository_basename() {
local _repository_basename
if [ $(git rev-parse --is-bare-repository) = 'true' ]; then
_repository_basename=$(basename $(git rev-parse --show-toplevel))
_repository_basename=${_repository_basename%.git}
else
_repository_basename=$(basename $(readlink -nf $(git rev-parse --show-toplevel)))
fi
@Phize
Phize / .vimrc_local
Created February 2, 2012 09:05
Vim: switching github accounts for Gist.vim
" **************************************************
" Gist {{{
" **************************************************
" dictionary of Gist accounts.
let g:gist_accounts = {
\ 'user1': {
\ 'password': 'password'
\ },
\ 'user2': {
\ 'password': 'password'
@Phize
Phize / .vimrc
Created February 1, 2012 08:25
align comment(s) with Align Them All! plugin on Vim.
" return regexp pattern that matches a comment based on commentstring.
function! s:getCommentStringPattern()
let pattern = escape(&commentstring, '^$[].*\~ ')
let pattern = substitute(pattern, '%s', '.*', 'g')
return pattern
endfunction
" align comment(s) based on commentstring.
autocmd vimrc-autocmd BufEnter *
@Phize
Phize / .vimrc
Created January 15, 2012 11:15
Vim plugins which I used (a part of my .vimrc)
My Vim files have moved to https://github.com/Phize/vim
@Phize
Phize / 50-ref.vim
Created January 14, 2012 10:32
Vim statusline for ref.vim with vim-powerline.
autocmd BufFilePost \[ref-*:*\] call Pl#UpdateStatusline(1)
call Pl#Statusline(
\ Pl#Match('bufname("%")', '^\[ref-(.+):(.*)\]$'),
\
\ Pl#Segment(' %{"Ref"} ',
\ Pl#HiCurrent( Pl#FG(231), Pl#BG(240), Pl#Attr('bold')),
\ Pl#HiInsert( Pl#FG(231), Pl#BG( 31), Pl#Attr('bold')),
\ Pl#HiNonCurrent(Pl#FG(244), Pl#BG(234), Pl#Attr('bold'))
\ ),
@Phize
Phize / 50-unite.vim
Created January 14, 2012 07:48
Vim statusline for Unite.vim with vim-powerline.
call Pl#Statusline(
\ Pl#Match('bufname("%")', '^\*unite\* - .*\@\d+$'),
\
\ Pl#Segment(' %{"Unite"} ',
\ Pl#HiCurrent( Pl#FG(231), Pl#BG(240), Pl#Attr('bold')),
\ Pl#HiInsert( Pl#FG(231), Pl#BG( 31), Pl#Attr('bold')),
\ Pl#HiNonCurrent(Pl#FG(244), Pl#BG(234), Pl#Attr('bold'))
\ ),
\
\ Pl#Segment('%< %{substitute(bufname("%"), "\^\\v\\*unite\\* - \(\.\+\)\\@\\d\+\$", "\\u\\1", "")} list',