Skip to content

Instantly share code, notes, and snippets.

@minwe
minwe / objectdeepcopy.js
Created March 13, 2019 08:16 — forked from izy521/objectdeepcopy.js
`JSON.parse( JSON.stringify( obj) )` has been regarded as the fastest method for deep copying Objects, but is it? This is mainly just to test. Obviously Functions aren't allowed in JSON.
var Types = new Map();
Types.set(Array, function(v) {
var l = v.length; i = 0, a = Array(l);
for (i; i<l; i++) {
a[i] = v[i];
}
return a;
});
Types.set(Number, function(v) {
return v * 1;
@minwe
minwe / !react-enzyme-render-methods.md
Created March 20, 2018 13:18 — forked from borela/!react-enzyme-render-methods.md
react-enzyme - `shallow` vs `mount` vs `render` lifecycle methods

An exploration of the different render methods available in react-enzyme.

@minwe
minwe / subString.js
Created July 27, 2017 08:13 — forked from roshanca/subString.js
截取指定长度的中英文混合字符串
/**
* 截取指定长度的中英文混合字符串
* @param {String} str 待截取的字符串
* @param {Number} n 截取长度(中文字符为英文的 double)
* @return {String} 截取后的字符串
*/
function subString(str, n) {
var r = /[^\x00-\xff]/g;
var m;
@minwe
minwe / charles-map-remote.md
Created July 13, 2017 16:51 — forked from radum/charles-map-remote.md
Charles proxy Map Remote over HTTP or HTTPS

Charles Proxy Map Remote over HTTP or HTTPS

The Map Remote tool changes the request location, per the configured mappings, so that the response is transparently served from the new location as if that was the original request.

HTTP

Using this feature for http resources does't require anything else apart from just configuring your Map Remote entry.

Always make sure you are clearing your cache before you test. Even if Charles is configured properly you might not see the changes unless the browser gets the resource again from the server and not for its local cache.
@minwe
minwe / helpers.js
Created June 8, 2017 11:39 — forked from AlexPashley/helpers.js
JS: Handlebars - Block Helpers #1 nl2br - Replace returns with <br> #2 If Greater than comparison operator #3 Find and replace function
// {{#nl2br}} replace returns with <br>
Handlebars.registerHelper('nl2br', function(options) {
var nl2br = (options.fn(this) + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + '<br>' + '$2');
return new Handlebars.SafeString(nl2br);
});
/**
* {{#ifGt}} greater than helper
*
* @param1 int param1
<!-- Prevent FOUC (flash of unstyled content) - http://johnpolacek.com/2012/10/03/help-prevent-fouc/ -->
<style type="text/css">
.no-fouc {display: none;}
</style>
<script type="text/javascript">
document.documentElement.className = 'no-fouc';
// add to document ready: $('.no-fouc').removeClass('no-fouc');
</script>

Responsive Flexbox table with Fallback

This shows an example of a responsive table that utilizes flexbox for it's layout.

Moved from my old account to new: Forked from Ian Svoboda's Pen vIqnD.

A Pen by Ian Svoboda on CodePen.

License.

@minwe
minwe / osx-10.11-setup.md
Created November 21, 2015 13:50 — forked from kevinelliott/osx-10.11-setup.md
Mac OS X 10.11 El Capitan Setup

Mac OS X 10.11 El Capitan

Custom recipe to get OS X 10.11 El Capitan running from scratch, setup applications and developer environment. This is very similar (and currently mostly the same) as my 10.10 Yosemite setup recipe (as found on this gist https://gist.github.com/kevinelliott/0726211d17020a6abc1f). Note that I expect this to change significantly as I install El Capitan several times.

I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

@minwe
minwe / remove-rubber-band-web-apps-ios
Created November 11, 2015 08:35 — forked from amolk/remove-rubber-band-web-apps-ios
Remove rubberband scrolling from web apps on mobile safari (iOS)
<!DOCTYPE html>
<html>
<head>
<title>Remove rubberband scrolling from web apps on mobile safari (iOS)</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta id="extViewportMeta" name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<style>
html, body {margin: 0; padding: 0; overflow: hidden}