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 / compile.py
Created May 20, 2012 23:15
Compile JS using Google Closure Compiler
#!/usr/bin/python
import httplib, urllib, sys, os, json
# Define the parameters for the POST request and encode them in
# a URL-safe format.
if len(sys.argv) <= 1:
print 'Usage: ' + sys.argv[0] + ' FILES...'
sys.exit();
@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 / test.php.php
Created November 6, 2012 02:02
MongoDB debug for AppFog
<html>
<head>
<title>Demo</title>
</head>
<body>
<h1>PHP Mongo Test</h1>
<?php
$services = getenv("VCAP_SERVICES");
echo "<h2>VCAP_SERVICES</h2>";
echo "<p>" . $services . "</p>";
@lyoshenka
lyoshenka / youtube_favs.js
Last active December 10, 2015 08:28
Collect list of YouTube favorites as a JSON string. Run this code in your Javascript console while at https://www.youtube.com/my_favorites
all = {}; $('#vm-playlist-video-list-ol li').each(function(){
var self = $(this),
id = self.attr('id').substring(9),
title = self.find('a.vm-video-title-content').text(),
url = self.find('a.vm-video-title-content').attr('href').split('&',1),
user = self.find('a.yt-user-name').text(),
time = self.find('.video-time').text();
all[id] = {
id: id,
user: user,
@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.