Skip to content

Instantly share code, notes, and snippets.

@RobertAudi
RobertAudi / markdown.template
Created August 19, 2010 15:35
Markdown template for the InfoLister Firefox add-on.
text/plain;Markdown;[[***Last updated:** %lastupd%*
]][[**User Agent:** %useragent%
]][[## Extensions ##
*(enabled: %enabled_extensions_count%, disabled: %disabled_extensions_count%; total: %extensions_count%)*
{{extension:* **%name%** *%version%* %disabled-text%
}}
@RobertAudi
RobertAudi / README.markdown
Created July 25, 2010 12:32
End of file comment Textmate command

I just created this little textmate command that acts like a snippet and inserts an End of file command a la CodeIgniter. Example:

/* End of file eof.tmsnippet.php */
/* Location: ./Sandbox/php/Textmate_Commands/eof.tmsnippet.php */

If you want to start using it right away, I uploaded the .tmCommand file in CloudApp. I also created a gist with the code of the command so that you can easily modify it if you want to. The links is at the bottom of the post.

Alternatively, you can create the command manually. Here are its attributes:

  • Save: Nothing
@RobertAudi
RobertAudi / gist:487657
Created July 23, 2010 16:26
Replace first occurrence of the search string with the replacement string.
<?php
/**
* Replace first occurrence of the search string with the replacement string.
*
* @param string $needle : The value being searched for.
* @param string $replace : The replacement value that replaces found search values.
* @param string $haystack : The string being searched and replaced on.
* @return string : The (modified) haystack.
* @author tapken at engter dot de
@RobertAudi
RobertAudi / gist:487163
Created July 23, 2010 08:04
Recent Items Stack
defaults write com.apple.dock persistent-others -array-add '{ "tile-data" = { "list-type" = 1; }; "tile-type" = "recents-tile"; }'
@RobertAudi
RobertAudi / insert_char_in_string.php
Created July 22, 2010 10:22
Insert a character at a certain position in a string.
<?php
/**
* Insert a character at a certain position in a string
*
* @param string $char : The character to insert.
* @param string $string : The input string.
* @param int|string $position : The position of the insertion; if the position is set to 'random', than the position will be ... random ...
* @return string
* @author Aziz Light
@RobertAudi
RobertAudi / preg_grep_keys.php
Created July 21, 2010 15:14
Return array keys that match the pattern.
<?php
function preg_grep_keys( $pattern, $input, $flags = 0 )
{
$keys = preg_grep( $pattern, array_keys( $input ), $flags );
$vals = array();
foreach ( $keys as $key )
{
$vals[$key] = $input[$key];
}
@RobertAudi
RobertAudi / gist:465247
Created July 6, 2010 10:56
moc aliases
alias mg="mi-growl.sh &> /dev/null &" # launch growl support
alias mof="mocp -f" # next
alias mor="mocp -r" # prev
alias mop="mocp -G" # play/pause
alias mos="mocp -s" # stop
alias mox="mocp -x" # exit
@RobertAudi
RobertAudi / moc-growl.sh
Last active September 5, 2015 08:45
Growl notifications for moc
#!/bin/bash
while out=$(/usr/local/Cellar/moc/2.5.0-beta1/bin/mocp -i); do
# Parse mocp output.
while IFS=: read -r field value; do
case $field in
Artist) artist=$value;;
Album) album=$value;;
SongTitle) title=$value;;
@RobertAudi
RobertAudi / moc-geetktool.sh
Created July 5, 2010 18:50
Script used to show info about the song playing in moc using GeekTool on OS X
#!/bin/bash
# First let's check if moc is running...
if [[ $(ps aux | grep mocp | grep -v grep | wc -l) -gt 0 ]];
then
out=$(/opt/local/bin/mocp -i)
# Parse mocp output.
while IFS=: read -r field value; do
@RobertAudi
RobertAudi / config
Created July 5, 2010 18:48
Copy this config file in ~/.moc
# /!\ WARNING /!\
# ---------------
# YOU NEED TO INSERT AT LEAST ONE BLANK LINE
# AT THE BOTTOM OF THE FILE OTHERWIZE YOU WILL
# GET A FATAL ERROR AND WON'T BE ABLE TO LAUNCH MOC!
# Default theme.
Theme = moc-orpheus
# Turn on repeat by default.