Skip to content

Instantly share code, notes, and snippets.

View man27382210's full-sized avatar
๐Ÿ˜—
Meh

Davis Tseng man27382210

๐Ÿ˜—
Meh
View GitHub Profile
@man27382210
man27382210 / diveTo.js
Last active December 17, 2020 03:02 — forked from bregenspan/diveTo.js
Recursively dive() to deeply-wrapped components via Enzyme
import merge from 'lodash/merge';
/**
* Given an Enzyme ShallowWrapper and component identifier, dives() down until the
* specified component is the root component.
*
* @param { Enzyme.ShallowWrapper } shallowWrapper - wrapper to dive into
* @param { string } name of component to dive for (should match constructor name).
* @param { object= } options to pass to dive()
*/

Step 1 Normal recompose usage

const { withStateHandlers } = Recompose;

const Counter = ({ count, increment, decrement }) =>
  <div>
    Count: {count} <br />
    <div>
      <button onClick={increment}>+</button>
      <button onClick={decrement}>-</button>
@man27382210
man27382210 / animatedScrollTo.js
Created November 16, 2017 04:01 — forked from joshbeckman/animatedScrollTo.js
ScrollTo animation using pure javascript and no jquery
document.getElementsByTagName('button')[0].onclick = function () {
scrollTo(document.body, 0, 1250);
}
function scrollTo(element, to, duration) {
var start = element.scrollTop,
change = to - start,
currentTime = 0,
increment = 20;
/*
* The following code snippet runs in an angular controller body.
* It tries to convert a blob object "data" into data URL and bind the result to the scope.
* Fix it so that $scope.data will make UI change as expected.
*/
/* global angular, data, FileReader */
angular.module('xxx').controller('Ctrl', ['$scope', function ($scope) {
var reader = new FileReader();
reader.onload = function (event) {
$scope.data = event.target.result;
sudo cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage.original
# for Mountain Lion 10.8.3 - 10.8.4
sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x54)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
# for Mountain Lion 10.8.1-10.8.2 and Lion 10.7.5
#sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x4D)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
# for Mountain Lion 10.8.0 and Lion 10.7.4 BELOW
#sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x51)|