Skip to content

Instantly share code, notes, and snippets.

Avatar
🖤
Black Lives Matter

Ricky rickhanlonii

🖤
Black Lives Matter
View GitHub Profile
@rickhanlonii
rickhanlonii / aamnotifs_ex.py
Last active Dec 20, 2015
As posted on HN. Example of adding more queues/consumers to andreimarcu/aamnoifs.
View aamnotifs_ex.py
import notifs
def print_notification(title, message):
print "Notification received: {0}: {1}".format(title, message)
def web_app_notify(title, message):
print "Webapp notification received: {0}: {1}".format(title, message)
def iphone_app_notify(title, message):
print "iPhone App notification received: {0}: {1}".format(title, message)
@rickhanlonii
rickhanlonii / keen.io.issue.html
Created Mar 15, 2016
Keen.io Invalid JSON string error
View keen.io.issue.html
<!DOCTYPE html>
<html>
<head>
<!-- This policy is broken -->
<meta http-equiv="Content-Security-Policy" content="script-src * 'unsafe-inline'">
<!-- This policy works -->
<!--<meta http-equiv="Content-Security-Policy" content="script-src * 'unsafe-inline' 'unsafe-eval">-->
<script src="https://code.jquery.com/jquery-2.2.1.min.js" integrity="sha256-gvQgAFzTH6trSrAWoH1iPo9Xc96QxSZ3feW6kem+O00=" crossorigin="anonymous"></script>
View keybase.md

Keybase proof

I hereby claim:

  • I am rickhanlonii on github.
  • I am rickhanlonii (https://keybase.io/rickhanlonii) on keybase.
  • I have a public key ASChr2UUJm_gA-01WTq5vrL2tZQS8MJD6C1VKGtLke8kJAo

To claim this, I am signing this object:

View coverage.json
{
"/Users/rph/dev/oss/jest-coverage-leak/module.js": {
"path": "/Users/rph/dev/oss/jest-coverage-leak/module.js",
"statementMap": {
"0": {
"start": {
"line": 1,
"column": 13
},
"end": {
View mock_project.md
├ example/
| └── app.js
| └── app.test.js
| └── math.js
View math.js
export const add = (a, b) => a + b;
export const subtract = (a, b) => b - a;
export const multiply = (a, b) => a * b;
export const divide = (a, b) => b / a;
View app.js
import * as math from './math.js';
export const doAdd = (a, b) => math.add(a, b);
export const doSubtract = (a, b) => math.subtract(a, b);
export const doMultiply = (a, b) => math.multiply(a, b);
export const doDivide = (a, b) => math.divide(a, b);
@rickhanlonii
rickhanlonii / math.eg.js
Created Mar 4, 2018
Mock jest.fn example
View math.eg.js
export const add = jest.fn();
export const subtract = jest.fn();
export const multiply = jest.fn();
export const divide = jest.fn();
@rickhanlonii
rickhanlonii / mock_dep_injection.js
Last active Mar 4, 2018
Mock Dependency Injection
View mock_dep_injection.js
const doAdd = (a, b, callback) => {
callback(a + b);
};
test("calls callback with arguments added", () => {
const mockCallback = jest.fn();
doAdd(1, 2, mockCallback);
expect(mockCallback).toHaveBeenCalledWith(3);
});