Skip to content

Instantly share code, notes, and snippets.

View ackintosh's full-sized avatar
🎯
Focusing

Akihito Nakano ackintosh

🎯
Focusing
View GitHub Profile
@ackintosh
ackintosh / gist:5869768
Created June 26, 2013 18:02
Permutation
<?php
class Permutation
{
public static function instance() { return new self(); }
public function run(Array $nums, $depth, Array $path = array())
{
if (count($nums) < $depth) throw new Exception();
if ($depth === 0) return array($path);
$ret = array();
for ($i = 0; $i < count($nums); $i++) {
require 'optparse'
class Diff
def initialize(new, old, delimiter = ' ')
@new = new
@old = old
@delimiter = delimiter
end
def file_each_line(file)
@ackintosh
ackintosh / get_checksum.rb
Created June 22, 2013 06:47
sample code to get md5 checksum.
require 'digest/md5'
require 'find'
Find.find(File.dirname($0)) do |path|
next if File.directory?(path)
puts Digest::MD5.hexdigest(File.read(path)) + ' ' + path
end
<?php
class Ball
{
public $dataSets = array();
public function run($input)
{
$this->set($input);
$results = array();
foreach ($this->dataSets as $d) {
<?php
class Node
{
public $linked = array();
public $name;
public function __construct($name)
{
$this->name = $name;
@ackintosh
ackintosh / gist:5791383
Created June 16, 2013 08:25
DFS Algorithm in PHP
<?php
class Node
{
public $name;
public $linked = array();
public function __construct($name)
{
$this->name = $name;
@ackintosh
ackintosh / gist:5791267
Created June 16, 2013 07:26
DFS Algorithm in PHP
<?php
class Node
{
public $name;
public $children;
public function __construct($name)
{
$this->name = $name;
<?php
var_dump(true + true); // int(2)
@ackintosh
ackintosh / AnotherExample.php
Last active December 18, 2015 08:48
Benchy
<?php
class AnotherExample extends AbstractMarker
{
// override
public function before()
{
// runs before benchmarking
}
}
@ackintosh
ackintosh / after.php
Last active December 18, 2015 07:49
test the time that book has been loaned.
<?php
class Loan
{
private $book;
private $time;
private static $faketime;
public function __construct(Book $book)
{
$this->book = $book;