Calculator app, for freecodecamp.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Calls the render() method of the Extend view helper if needed | |
* | |
* @author Mon Zafra <monzee at gmail> | |
* @copyright (c)2009 Mon Zafra | |
* @category Mz | |
* @package | |
* @license http://mz-project.googlecode.com/svn/trunk/LICENSE MIT License |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* APPLICATION_PATH/Bootstrap.php */ | |
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap | |
{ | |
protected $_appNamespace = 'Application_'; | |
protected function _initFoo() | |
{ | |
throw new BadMethodCallException('foo!'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
from itertools import chain, combinations | |
data = [ | |
['A', 'B', 'C'], | |
['A', 'C', 'E'], | |
['E', 'F', 'D'], | |
['D', 'A', 'J'], | |
['E', 'D', 'J'], | |
] | |
pairs = map(sorted, chain(*[combinations(row, 2) for row in data])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kernel | |
SKIP_2357 = [2, 4, 2, 4, 6, 2, 6, 4, 2, 4, 6, 6, 2, 6, 4, 2, 6, 4, 6, 8, 4, | |
2, 4, 2, 4, 8, 6, 4, 6, 2, 4, 6, 2, 6, 6, 4, 2, 4, 6, 2, 6, 4, | |
2, 4, 2, 10, 2, 10] | |
def iterate(start, &f) | |
Enumerator.new do |y| | |
loop do | |
y << start | |
start = f.call start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Palindromes | |
attr_reader :largest, :smallest | |
PalindromicProduct = Struct.new(:value, :factors) do | |
def to_str | |
"#{value} -> #{factors}" | |
end | |
end | |
def initialize(opts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns sieve-comp) | |
(defmacro measure | |
[& body] | |
`(do | |
(System/gc) | |
(let [start# (System/nanoTime) | |
result# (do ~@body)] | |
[result# (- (System/nanoTime) start#)]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path := $(dir $(main)) | |
prefix := $(basename $(main)) | |
class_name := $(notdir $(prefix)) | |
COMPILE := javac | |
EXEC := java -cp .:$(path):$(cp) | |
.PHONY: run | |
run: $(prefix).class | |
$(EXEC) $(class_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Contact { | |
class Person { | |
public final String name; | |
public final int phone; | |
public Person(String name, int phone) { | |
this.name = name; | |
this.phone = phone; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package m; | |
import java.util.function.*; | |
public class Monads { | |
static <T, U> Function<Option<T>, Option<U>> | |
lift(Function<T, U> t2u) { | |
return ot -> pu -> ot.map(t2u).match(pu); | |
} |
OlderNewer