Skip to content

Instantly share code, notes, and snippets.

@lyoshenka
lyoshenka / bookmarklet.html
Last active September 24, 2015 06:47 — forked from capndesign/bookmarklet.js
Use Gist or Github file as bookmarklet.
<a href="javascript:(function(){s=document.createElement('script');s.src='https://gist.github.com/raw/707529/bookmarklet.js?'+Math.random();document.body.appendChild(s);})();">Drag this to your bookmark bar</a>
@lyoshenka
lyoshenka / .bashrc
Created May 23, 2011 15:07 — forked from henrik/.bashrc
Git branch and dirty state in Bash prompt.
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
@lyoshenka
lyoshenka / code.coffee
Created March 19, 2012 23:19 — forked from tauren/gist:1045906
Make it safe to use console.log always. How to convert to coffeescript?
window.log = ->
log.history = log.history or []
log.history.push arguments
if @console
arguments.callee = arguments.callee.caller
console.log Array::slice.call(arguments)
((b) ->
c = ->
d = "assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(",")
<?php
function getExceptionTraceAsString(Exception $exception)
{
$rtn = '';
foreach ($exception->getTrace() as $count => $frame)
{
$args = '';
if (isset($frame['args']))
{
$args = array();
@lyoshenka
lyoshenka / drop
Created September 24, 2012 00:36
Simple shell script to copy a file to a Dropbox public folder and get its URL. Needs socat and xclip.
#!/bin/sh
#
# Simple shell script to copy a file to the Dropbox
# public folder and get its URL.
#
# The URL of the last file copied also stays on the
# X clipboard.
#
# Symlink the script as dropmv to move the file to the
# public folder instead of copying it.
@lyoshenka
lyoshenka / ls.php
Created December 30, 2012 16:58 — forked from se4c0met/ls.php
<?php
/*
due to the open_basedir restriction, $tgtPath must be something like the following path param:
http://<your domain>.aws.af.cm/ls.php?path=/var/vcap.local/dea/apps/f-0-21341234123412abcdefgc75cc0f96b9/app/
to discover what are the allowed paths, try supplying any path, e.g. '/' then view the error logs via:
af logs <your app name>
*/
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
(function() {
// Change `silent` to true to invoke the promptless, self-closing
// version of the bookmarklet.
var silent = false;
var url = location.href;
var title = document.title;
// Look for a single hAtom entry on the page, and iff one is found, extract
// the entry-title in place of the document title:
#!/bin/bash
####
# Split MySQL dump SQL file into one file per table
# based on http://blog.tty.nl/2011/12/28/splitting-a-database-dump
####
if [ $# -ne 1 ] ; then
echo "USAGE $0 DUMP_FILE"
fi
@lyoshenka
lyoshenka / example.rb
Created January 31, 2013 04:47 — forked from mislav/example.rb
Example of outputting YAML in Ruby using inline style (array is all on one line, not spread out with each element on its own line)
full_data = {
response: {body: StyledYAML.literal(DATA.read), status: 200},
person: StyledYAML.inline('name' => 'Steve', 'age' => 24),
array: StyledYAML.inline(%w[ apples bananas oranges ])
}
StyledYAML.dump full_data, $stdout
__END__
{