Skip to content

Instantly share code, notes, and snippets.

View amirci's full-sized avatar

Amir Barylko amirci

View GitHub Profile
@amirci
amirci / wpsh_review.rb
Created February 8, 2012 13:31
Review rspec
require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
require 'word_press_security_hardening'
describe WordPressSecurityHardening do
# when method is an instance method use "#"
# when is a class method use "."
describe '#harden' do
let(:db) { double(WordPressDatabase) }
let(:config) { double(WordPressConfigFile) }
@amirci
amirci / fluent_build.cs
Created March 19, 2012 16:10
Fluent build
Build.UsingCsc(config => config
.Target(Library)
.Sources(....)
.References(....)
.OutputTo(.....));
@amirci
amirci / demo.coffee
Created October 2, 2012 17:41
Demo for Coffeescript presentation
# String interpolation
result = "The result is #{3}"
console.log result
movieId = 452
url = "http://movies/#{movieId}"
console.log url
# Functions
square = (x) -> x * x
@amirci
amirci / line_spec.rb
Created April 24, 2013 04:30
Acceptance tests for bowling game
require_relative 'bowling'
describe Line do
def roll_balls(line, frames)
frames.each { |pins| line.knock pins }
end
def self.should_behave_like_a_bowling_game(result, frames, descr=nil)
context descr || "when doing a game with #{frames}" do
@amirci
amirci / viewmodel_spec.coffee
Created May 7, 2013 00:06
Spec using mock to call response method
describe "ChildrenCheckinViewModel", ->
beforeEach ->
spyOn(jQuery, 'getJSON')
@actualChildren = ko.observableArray()
@subject = new Childcarepro.ChildrenCheckinViewModel @actualChildren
@response = [
{FIRSTNAME:'John',LASTNAME:'Locke',BIRTHDATE:12312312312},
{FIRSTNAME:'Matt',LASTNAME:'Zandstra',BIRTHDATE:12312312312}
]
@amirci
amirci / Invert statement.cs
Created October 21, 2013 19:35
Nesting example
public double RefDoingCalculations()
{
if (!_firstGuard)
{
return 0;
}
if (!_secondGuard)
{
return FirstCalculation();
@amirci
amirci / Lunky's day 11.fs
Last active February 10, 2016 18:51
Lunky's day 11 modified
namespace adventofcode
open System.Text.RegularExpressions
module Day11 =
let abc = ['a'..'z']
let succ (c: char) = int c |> (+) 1 |> char
let incChar = function
 public static <A, B> Optional<Map<B, Set<A>>> tryReverse(final Map<A, Set<B>> maybeInput) {
    return Optional.ofNullable(maybeInput).map(ConfigUtil::reverse);
 }
private static <A, B> Map<B, Set<A>> reverse(final Map<A, Set<B>> input) {
    return filterNullValues(input)
             .flatMap(kvp -> filterNullValues(kvp).map(v -> mkEntry(v, kvp.getKey())))
             .collect(groupingBy(x -> x.getKey(), HashMap::new, mapping(y -> y.getValue(), toSet())));
}