Skip to content

Instantly share code, notes, and snippets.

View avalanche123's full-sized avatar

Bulat Shakirzyanov avalanche123

View GitHub Profile
@avalanche123
avalanche123 / server.js
Created September 3, 2011 08:05 — forked from mixonic/server.js
Node.js + Socket.io + Bash. A collaborative terminal for your browser.
//
// This server will start a bash shell and expose it
// over socket.io to a browser. See ./term.html for the
// client side.
//
// You should probably:
//
// npm install socket.io
// curl -O https://github.com/LearnBoost/Socket.IO/raw/master/socket.io.min.js
//
@avalanche123
avalanche123 / gist:1189560
Created September 2, 2011 19:14 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
Day job:
Favorite Python project:
Favorite Conference:
Python Experience Level:
@avalanche123
avalanche123 / gist:1158382
Created August 20, 2011 00:22
RDoc format example
# :title:A Shell Script
# = Name
#
# = Synopsis
#
# = Description
#
# = Todo
# == Upcoming Features
# 0. Nothing yet.
@avalanche123
avalanche123 / README.md
Created July 27, 2011 05:57 — forked from luciferous/README.md
A very small HTTP Client with Rack/WSGI style interfaces

Tiny HTTP

A very small HTTP client with Rack/WSGI style interfaces.

The setup

$sid = 'ACxxxxxxxxxxxx';
$token = '12345678';
$http = new TinyHttp("https://$sid:$token@api.twilio.com");
@avalanche123
avalanche123 / user_controller.rb
Created May 20, 2011 23:47
Dependency Injection in Ruby
# not di
class UserController
def create(data)
User.new(data).save!
end
end
# usage
controller = UserController.new
controller.create :name => 'Bulat', :username => 'avalanche123'
:+1:
:-1:
:airplane:
:art:
:bear:
:beer:
:bike:
:bomb:
:book:
:bulb:
<?php
$this->user2->expects($this->once())
->method('getSalt')
->will($this->returnValue(true))
;
$this->assertTrue($this->user2->getSalt());
@avalanche123
avalanche123 / test.php
Created May 16, 2011 15:57
killer testing
<?php
class TestTest extends PHPUnit_Framework_TestCase
{
public function testMock()
{
$user2 = $this->getMock('UserInterface');
$user2->expects($this->any())
->method('getSalt')
@avalanche123
avalanche123 / test.php
Created May 16, 2011 15:35
brain fuck
<?php
$user2->expects($this->once())
->method('getSalt')
->will(
$this->returnCallback(function() use (&$user2) {
return $user2->getSalt();
})
);
<?php
class UserController
{
public function createUser(\Model\UserTable $users)
{
$user = $users->create();
// continue with auto-completion...
}
}