-
Open your project (if you're using WebPack, obviously)
-
npm install sinon --save-dev
-
You should now have Sinon in your node modules and listed in your
package.json
file -
In your tests, require Sinon:
var sinon = require('sinon');
This file contains hidden or 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
# ----- Common Linked List Methods ----- | |
def add_to_front(list, data) | |
build_list(data, list) | |
end | |
def add_to_back(list, data) | |
return build_list(data, empty_list) if empty?(list) | |
new_tail = add_to_back(tail(list), data) | |
build_list(head(list), new_tail) |
This file contains hidden or 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
_ \ | |
, __ , # (C) Josh Cheek | |
*,_ = # 2015 | |
def __ ___ , # Inspiration | |
*__, **_ # Is | |
putc ___ # Obviously | |
end, def _ *_, # Yusuke | |
**__ # Endoh | |
_. # | |
map {|_ ;__ # And |
This file contains hidden or 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 JavaScript | |
def initialize | |
@work = [] | |
@background_worker_count = 0 | |
end | |
def run(&code) | |
@work << code | |
while @work.any? || @background_worker_count > 0 | |
instance_eval &@work.shift if @work.any? |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Smiley Face</title> | |
</head> | |
<body> | |
<canvas id="a" width="800" height="800"> | |
This text is displayed if your browser does not support HTML5 Canvas. | |
</canvas> |
This file contains hidden or 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
# converts a png image to jpeg | |
# all transparent regions will be converted to white | |
convert -flatten source.png destination.jpg |
This file contains hidden or 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 AttachedValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
record.errors.add(attribute, :attached, options) unless value.attached? | |
end | |
end |