Skip to content

Instantly share code, notes, and snippets.

View dimorphic's full-sized avatar
🤖
*void 0*

Sabin Tudor dimorphic

🤖
*void 0*
View GitHub Profile
@dimorphic
dimorphic / 0_reuse_code.js
Created December 13, 2013 09:03
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
app.directive('infiniteScroll', [
'$rootScope', '$window', '$timeout', function($rootScope, $window, $timeout) {
return {
link: function(scope, elem, attrs) {
var checkWhenEnabled, handler, scrollDistance, scrollEnabled;
$window = angular.element($window);
elem.css('overflow-y', 'scroll');
elem.css('overflow-x', 'hidden');
elem.css('height', 'inherit');
scrollDistance = 0;

Install needed node packages:

npm install -g cylon-ble
npm install cylon cylon-ollie

First scan for your BB8 (the device name should contain BB in it):

> sudo cylon-ble-scan
[...]
@dimorphic
dimorphic / Readme.md
Last active May 18, 2016 09:08 — forked from timoxley/Readme.md
JS Pop Quiz: How well do you know your functions?

JS Pop Quiz: How well do you know your functions?

Given an Array of Functions fns, what argument(s) can you pass to fns.forEach such that each function in fns will execute, in order, without creating any anonymous (or named) functions or invoking the Function constructor?

Conditions

  • Do not use the function keyword, or arrow functions () => .
  • Do not invoke the Function constructor.
  • Function#bind & friends on the Function.prototype are ok.
  • Answer should be a single line.
@dimorphic
dimorphic / ngrxintro.md
Created July 25, 2016 08:00 — forked from btroncone/ngrxintro.md
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

#Comprehensive Introduction to @ngrx/store By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@dimorphic
dimorphic / better-nodejs-require-paths.md
Created September 3, 2016 17:03 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@dimorphic
dimorphic / core.js
Created September 19, 2016 10:03 — forked from RobK/core.js
Generating AWS HMAC in Nodejs (RFC 2104 compliant HMAC)
var crypto = require("crypto");
/**
* Get the signature/digest of a supplied input string
* @param data [Required] The String to encode
* @param awsSecretKey [Required] Secret key shared with Amazon
* @param algorithm [Optional] Encryption algorithm, defaults to sha256
* @param encoding [Optional] The output encoding. Default to base64
* @returns Str with encoded digest of the input string
*/
function generateHmac (data, awsSecretKey, algorithm, encoding) {
@dimorphic
dimorphic / blob-filereader-localStorage.js
Created December 28, 2016 16:05 — forked from robnyman/blob-filereader-localStorage.js
Get file as a blob, read through FileReader and save in localStorage
// Getting a file through XMLHttpRequest as an arraybuffer and creating a Blob
var rhinoStorage = localStorage.getItem("rhino"),
rhino = document.getElementById("rhino");
if (rhinoStorage) {
// Reuse existing Data URL from localStorage
rhino.setAttribute("src", rhinoStorage);
}
else {
// Create XHR and FileReader objects
var xhr = new XMLHttpRequest(),
@dimorphic
dimorphic / index.html
Created August 30, 2017 21:21 — forked from stesie/index.html
AWS IoT-based serverless JS-Webapp Pub/Sub demo
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>AWS IoT Pub/Sub Demo</title>
</head>
<body>
<h1>AWS IoT Pub/Sub Demo</h1>
<form>
<button type="button" id="connect">connect!</button>
@dimorphic
dimorphic / ultimate-ut-cheat-sheet.md
Created March 22, 2021 14:37 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest