Skip to content

Instantly share code, notes, and snippets.

View rickhanlonii's full-sized avatar
git push -f

Ricky rickhanlonii

git push -f
View GitHub Profile
@rickhanlonii
rickhanlonii / aamnotifs_ex.py
Last active December 20, 2015 07:09
As posted on HN. Example of adding more queues/consumers to andreimarcu/aamnoifs.
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 March 15, 2016 20:24
Keen.io Invalid JSON string error
<!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>
@rickhanlonii
rickhanlonii / keybase.md
Created September 13, 2016 17:09
Keybase Proof

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:

@rickhanlonii
rickhanlonii / selectors.md
Last active April 22, 2021 02:24
Selectors 201

Overview

There are three type of selectors:

  • basic
  • cached
  • cached factory
// Basic
const selectUsers = state => get(state, '_entites.users');
@rickhanlonii
rickhanlonii / coverage.json
Created January 12, 2018 00:07
Coverage Object
{
"/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": {
@rickhanlonii
rickhanlonii / mock_basic.js
Last active February 24, 2022 06:07
Mock Function Basic
test("returns undefined by default", () => {
const mock = jest.fn();
let result = mock("foo");
expect(result).toBeUndefined();
expect(mock).toHaveBeenCalled();
expect(mock).toHaveBeenCalledTimes(1);
expect(mock).toHaveBeenCalledWith("foo");
});
@rickhanlonii
rickhanlonii / mock_implementation.js
Last active November 4, 2019 22:20
Mock Implementation
test("mock implementation", () => {
const mock = jest.fn(() => "bar");
expect(mock("foo")).toBe("bar");
expect(mock).toHaveBeenCalledWith("foo");
});
test("also mock implementation", () => {
const mock = jest.fn().mockImplementation(() => "bar");
@rickhanlonii
rickhanlonii / mock_dep_injection.js
Last active March 4, 2018 19:29
Mock Dependency Injection
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);
});
@rickhanlonii
rickhanlonii / mock_project.md
Last active March 4, 2018 18:20
Mock Project
├ example/
| └── app.js
| └── app.test.js
| └── math.js