Skip to content

Instantly share code, notes, and snippets.

Registered Name: https://zhile.io
License Key: 48891cf209c6d32bf4
@cola-sk
cola-sk / dabblet.css
Created November 7, 2018 06:34
How to make 3-corner-rounded triangle in CSS (SO)
/**
* How to make 3-corner-rounded triangle in CSS (SO)
* http://stackoverflow.com/q/14446677/1397351
*/
.triangle, .triangle:before, .triangle:after { width: 4em; height: 4em; }
.triangle {
overflow: hidden;
position: relative;
margin: 7em auto 0;
border-radius: 20%;
@cola-sk
cola-sk / asyncRoute.js
Created September 3, 2018 13:54 — forked from velopert/asyncRoute.js
Server Side Rendering & Async Route (Code Splitting) for React-Router v4
import React from 'react';
export default function asyncComponent(getComponent) {
class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
@cola-sk
cola-sk / copyToClipboard.js
Last active May 31, 2018 10:44 — forked from Chalarangelo/copyToClipboard.js
复制文本到剪切板
export const copyToClipboard = text => {
let textArea;
let copy;
let isError = false;
function isOS() {
return navigator.userAgent.match(/ipad|iphone/i);
}
function createTextArea(text) {
@cola-sk
cola-sk / .bashrc
Created March 26, 2018 06:35 — forked from mathiasverraes/.bashrc
Git shortcuts
#! /bin/sh
alias gs="git status"
alias gc="git commit"
alias gr="git checkout"
alias ga="git add"
alias gl="git lola"
@cola-sk
cola-sk / high-dpi-media.css
Last active October 25, 2017 09:13 — forked from marcedwards/high-dpi-media.css
A CSS media query that captures almost all high DPI aware devices.
/* ---------------------------------------------------------- */
/* */
/* A media query that captures: */
/* */
/* - Retina iOS devices */
/* - Retina Macs running Safari */
/* - High DPI Windows PCs running IE 8 and above */
/* - Low DPI Windows PCs running IE, zoomed in */
/* - Low DPI Windows PCs and Macs running Firefox, zoomed in */
/* - Android hdpi devices and above */
@cola-sk
cola-sk / connect.js
Created October 11, 2017 09:58 — forked from gaearon/connect.js
simple connect
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@cola-sk
cola-sk / js-exif-rotate.html
Created November 10, 2016 03:39 — forked from runeb/js-exif-rotate.html
Auto-rotate images locally in the browser by parsing exif data
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input id="file" type="file" accept="image/*" />
<br/>
<h2>As read:</h2>
<img id="placeholder1" width=300/><br/>
<h2>Rotated by exif data:</h2>
<img id="placeholder2" width=300/>
<script>
@cola-sk
cola-sk / multi-line-ellipsis
Last active March 15, 2017 08:49 — forked from depoulo/gist:5832073
CSS-only multi-line ellipsis with generated content.License: http://www.wtfpl.net/txt/copying/
if (typeof window.document.createElement('div').style.webkitLineClamp !== 'undefined') {
document.querySelector('html').classList.add('webkit-line-clamp');
}
@cola-sk
cola-sk / what-forces-layout.md
Last active September 22, 2015 02:57 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()