Skip to content

Instantly share code, notes, and snippets.

View shishironline's full-sized avatar

Prof. Dr. Shishir Urdhwareshe shishironline

View GitHub Profile
@rmbl
rmbl / backtrace.php
Created June 14, 2013 10:53
Backtrace on fatal_error in PHP
<?php
function shutdown() {
$error = error_get_last();
if ($error['type'] === E_ERROR) {
// fatal error has occured
$trace = array_reverse($GLOBALS['dbg_stack']);
array_pop($trace);
if(php_sapi_name() == 'cli') {
echo 'Backtrace for: \'' . $error['message'] . '\' at ' . $error['file'] . ':' . $error['line'] . ':' . "\n";
foreach($trace as $item)
@bollig
bollig / _.md
Created June 14, 2013 10:34
scaler ascii
@monkstone
monkstone / Rakefile
Created March 21, 2013 14:34
Alternative rakfile for Windows?
require 'rake/clean'
JRUBY_VERSION = "1.7.3"
PROCESSING_VERSION = "2.0b8"
CLOBBER.include("processing-#{PROCESSING_VERSION}-windows32.zip", "jruby-complete-#{JRUBY_VERSION}.jar")
desc "download, and copy to ruby-processing"
task :default => [:download, :copy]
package bcomposes.twitter
import twitter4j._
object StatusStreamer {
def main(args: Array[String]) {
val twitterStream = new TwitterStreamFactory(Util.config).getInstance
twitterStream.addListener(Util.simpleStatusListener)
twitterStream.sample
Thread.sleep(2000)
@getify
getify / 1.js
Created November 13, 2012 14:04
more "mental tax": interpreting code that uses `let` in many nested blocks
/*
not terribly difficult to predict which statements print what.
*/
function foo() {
var a, b, c, d;
if (true) {
if (true) {
a = 1;
@getify
getify / 1.js
Created November 13, 2012 00:19
illustrating some potential issues with adding `let` to code which already has `var` used in it...
// var: poor stylistic form, but no leakage
function foo() {
bar = 3;
if (true) {
var bar = 5;
}
}
// let: will leak an auto-global
function foo() {
@akisaarinen
akisaarinen / FunctionalPong.scala
Created September 22, 2012 14:29
Functional Pong
package pong.functional
sealed trait Event
sealed trait Action
object Action {
case object MoveUp extends Action
case object MoveDown extends Action
case object ShootMissile extends Action
}
@akisaarinen
akisaarinen / ImperativePong.scala
Created September 22, 2012 14:27
Imperative Pong
package pong.imperative
sealed trait Event
class PongConnection {
def isConnected(): Boolean = sys.error("not implemented")
def readEvent(): Event = sys.error("not implemented")
def moveUp(): Unit = sys.error("not implemented")
def moveDown(): Unit = sys.error("not implemented")
def shootMissile(): Unit = sys.error("not implemented")
@WayneHaworth
WayneHaworth / grok_vi.mdown
Created August 14, 2012 14:43 — forked from nifl/grok_vi.mdown
Grok Vim - an excellent summary of a few Vim features, which also exposes elegant uses of the commands

###Answer by Jim Dennis on Stack Overflow

#Your problem with Vim is that you don't grok vi.

You mention cutting with yy and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However, yy is only one of many way to yank text into the anonymous copy buffer (or "register" as it's called in vi).

The "Zen" of vi is that you're speaking a language. The initial y is a verb. The statement yy is a simple statement which is, essentially, an abbreviation for 0 y$:

0 go to the beginning of this line. y yank from here (up to where?)

@moraes
moraes / AnideaforblocksemanticsinGostexttemplate.rst
Created July 9, 2012 14:08
An idea for {{block}} semantics in Go's text/template

{{block}} in text/template

We can achieve what is known as "template inheritance" in other template engines using the {{block}} tag. A {{block}} is a replaceable fragment inside a template. Here's an example:

{{define "Base"}}

<p>A header</p>

{{block body}}