Skip to content

Instantly share code, notes, and snippets.

View vinnymac's full-sized avatar
🤓

Vincent Taverna vinnymac

🤓
View GitHub Profile
@vinnymac
vinnymac / some.js
Created January 12, 2015 22:34
Just some JS about destroying and stuff
// somewhere else in time and space
SomeView = new Backbone.Marionette.View.extend({
onDestroy: function(){
App.vent.trigger('define:var:to:block:callback');
}
});
// some other view
@vinnymac
vinnymac / Users-test.coffee
Last active August 29, 2015 14:17
Example of testing children that use react router
React = require "react/addons"
{
TestUtils
} = React.addons
Users = require "../Users.coffee"
stubRouterContext = require "utils/stubRouterContext"
@vinnymac
vinnymac / WhyDidYouUpdateMixin.coffee
Last active March 3, 2016 02:39 — forked from joshma/WhyDidYouUpdateMixin.js
Performance Engineering with React (Part 2)
_ = require "underscore"
###
Drop this mixin into a component that wastes time according to Perf.getWastedTime() to find
out what state/props should be preserved. Once it says "Update avoidable!" for {state, props},
you should be able to drop in React.addons.PureRenderMixin
React.createClass
mixins: [WhyDidYouUpdateMixin]
###
@vinnymac
vinnymac / arePermutations.coffee
Last active March 17, 2016 14:55
Test whether or not two strings are permutations of each other.
arePermutations = (str1, str2) ->
return false unless str1.length is str2.length
occurrences = {}
for i in [0...str1.length]
char = str1.charAt(i)
occurrences[char] = (occurrences[char] or 0) + 1
for i in [0...str2.length]
@vinnymac
vinnymac / benchmark-atob.md
Last active December 17, 2016 02:48
Benchmark atob

Benchmark results

Chrome Native atob

Large String - 3,665 ops/sec

Small String - 1,162,858 ops/sec

window.atob(base64EncodedString)

@vinnymac
vinnymac / mount_ntfs.sh
Created January 3, 2017 19:17 — forked from tt6746690/mount_ntfs.sh
mount ntfs
#!/bin/bash
# enable writing to NTFS drives
function mount {
diskutil list
echo “please enter the ntfs disk to be mounted:”
read inp
#### http://mywiki.wooledge.org/BashFAQ/031#np2
if [[ $inp =~ ^.*(disk0).*$ || $inp =~ ^.*(disk1).*$ ]]; then
echo dangerous input!
@vinnymac
vinnymac / reclaimWindows10.ps1
Created January 8, 2017 04:39 — forked from alirobe/reclaimWindows10.ps1
"Reclaim Windows 10" turns off a bunch of unnecessary Windows 10 telemetery, removes bloatware, and privacy invasions. Review and tweak before running. Scripts for reversing are included and commented. Fork via https://github.com/Disassembler0 (different defaults)
##########
# Win10 Initial Setup Script
# Author: Disassembler <disassembler@dasm.cz>
# Version: 1.7, 2016-08-15
# dasm's script: https://github.com/Disassembler0/Win10-Initial-Setup-Script/
# THIS IS A PERSONALIZED VERSION
# This script leaves more MS defaults on, including MS security features.
# Tweaked based on personal preferences for @alirobe 2016-11-16 - v1.7.1
import ReactDOM from 'react-dom/server'
import React from 'react'
import Typography from '../../src/'
import GoogleFont from '../../src/components/GoogleFont'
import theme from '../../src/themes/us-web-design-standard'
const typography = new Typography(theme)
// Hot reload typography in development.
@vinnymac
vinnymac / useEventListener.js
Created October 29, 2018 16:44
Use an event listener on a specific element with React Hooks
import { useEffect, useRef } from "react";
export default function useEventListener(event, callback) {
const element = useRef(null);
useEffect(() => {
element.current.addEventListener(event, callback);
return () => element.current.removeEventListener(event, callback);
}, []);
@vinnymac
vinnymac / sniff-linux.sh
Last active February 12, 2019 17:04
Sniff machine names from a local or remotely connected network without additional installs
#!/bin/bash
for a in $(arp -n | tail -n+2 | cut -d' ' -f1);
do
nmblookup -A $a;
done