Skip to content

Instantly share code, notes, and snippets.

View moimikey's full-sized avatar
:shipit:
ship it

Michael Scott Hertzberg moimikey

:shipit:
ship it
View GitHub Profile
@moimikey
moimikey / gist:d3421d389dbb4db38faf
Last active June 15, 2016 13:54
npm search /\^is-
is-4byte-char Check if a given value is a character that costs 4 bytes in… =shinnn
is-4byte-code-point Check if a given number is a code point of UTF-8 4-byte… =shinnn
is-7z Check if a Buffer/Uint8Array is a 7Z archive =t1st3
is-7zip Check if a Buffer/Uint8Array is a 7ZIP file =kevva
is-a type checking "micro library" =dtudury
is-a-ray is it a Ray? Is it? IS IT? =gypsydave5
is-absolute Polyfill for node.js `path.isAbolute`. Returns true if a… =jonschlinkert…
is-absolute-url Check if an URL is absolute =sindresorhus
is-accessor-descriptor Returns true if a value has the characteristics of a valid… =jonschlinkert
is-admin
@moimikey
moimikey / whatis.js
Last active March 18, 2016 14:55
really simple javascript type detection
const assert = function (condition) {
if (condition !== true && condition !== false) {
throw new TypeError("Assertions should be only of booleans; you're writing your spec wrong.");
}
if (!condition) {
throw new Error("Specification-level assertion failure");
}
};
function whatIs(this$) {
@moimikey
moimikey / babel.md
Last active January 24, 2016 02:00
babel notes of wisdom
lib notes
babel-cli basically what you need always
babel-register this is only for dev or local use and not production or browser
babel-core only necessary if using babel programatically
babel-polyfill shims inconsistent browser functions like Array.from, etc.
babel-runtime only helps at a code level by optimizing babel helpers into a single runtime

use presets

@moimikey
moimikey / upgrade.sh
Created December 24, 2013 05:23
my ever growing update bash function
function update() {
echo — Updating Homebrew...
brew update
echo — Upgrading Homebrew packages...
brew upgrade
echo — Cleaning up...
brew cleanup
echo - Pruning...
brew prune
echo — Updating MacPorts...
@moimikey
moimikey / custom.php
Created December 30, 2015 18:22
thermal, pull custom & acf fields
<?php
function north_cast_api_data($content) {
if (is_numeric($content)) $content = intval($content);
else {
$unserialized_content = @unserialize($content);
// we got serialized content
if ($unserialized_content !== false) {
// make sure that integers are represented as such, instead of str
foreach ($unserialized_content as $fn => &$c) {
if (is_numeric($c)) $c = intval($c);
<script src="components/get-style-property/get-style-property.js"></script>
<script src="components/get-size/get-size.js"></script>
<script src="components/matches-selector/matches-selector.js"></script>
<script src="components/eventEmitter/EventEmitter.js"></script>
<script src="components/eventie/eventie.js"></script>
<script src="components/doc-ready/doc-ready.js"></script>
<script src="components/classie/classie.js"></script>
<script src="components/jquery-bridget/jquery.bridget.js"></script>
<script src="components/outlayer/item.js"></script>
<script src="components/outlayer/outlayer.js"></script>
@moimikey
moimikey / konami.coffee
Last active December 29, 2015 03:19
KONAMIIIIIIIIIIII KYYYYAHHHHHHHHHHHHH!!!!
@MM.module 'EasterEggApp', (EE, App, Backbone, Marionette, $, _) ->
# up, up, down, down, left, left, right, right, a, enter
EE.sequence = [38, 38, 40, 40, 37, 37, 39, 39, 65, 13]
EE.pressed = []
EE.on
'start': ->
$(window).on 'keyup.konami', EE.pressedKey
'stop': ->
$(window).off '.konami'
@moimikey
moimikey / gist:7310211
Last active December 27, 2015 10:19
calculate data transfer bits
# Convert bit rate from and to another rate
#
# amount: data being converted
# unitFrom: `from` unit. bps|kbps|mbps|gbps
# unitTo: `to` unit. bps|kbps|mbps|gbps
#
# uses double bitwise not `~~` as `Math.floor`
# uses `+` as type coercion to `int`
Util.bitCalculate = (amount, unitFrom, unitTo, maxDecimals=2) ->
base = 1000
([0...1000].filter (m) -> m % 3 is 0 or m % 5 is 0).reduce (s,h) -> s + h
@moimikey
moimikey / gist:5042795
Created February 26, 2013 22:15
latest pinterest feed using their simple rss feed transcoded to json.
<?php
class XmlToJson {
public function Parse( $url ) {
$fileContents = file_get_contents( $url );
$fileContents = str_replace( array(
"\n",
"\r",
"\t"
), '', $fileContents );
$fileContents = trim( str_replace( '"', "'", $fileContents ) );