Skip to content

Instantly share code, notes, and snippets.

💻
Busy
Coding

流浪大法师 liuliangsir

View GitHub Profile
View vsc_js_snippets.json
{
"Console Log": {
"prefix": "cl",
"body": "console.log($1);",
"description": "Console Log"
},
"Named Function": {
"prefix": "nfn",
"body": ["function ${1:functionName}($2) {", " $3", "}"],
"description": "Named Function"
@liuliangsir
liuliangsir / git-aliases.md
Created Feb 13, 2019 — forked from mwhite/git-aliases.md
The Ultimate Git Alias Setup
View git-aliases.md

The Ultimate Git Alias Setup

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bashrc
@liuliangsir
liuliangsir / sw.js
Created Dec 24, 2018 — forked from ireade/sw.js
Handle broken images with the service worker
View sw.js
self.addEventListener('install', (e) => {
e.waitUntil(
caches.open("precache").then((cache) => cache.add("/broken.png"))
);
});
function isImage(fetchRequest) {
return fetchRequest.method === "GET" && fetchRequest.destination === "image";
}
@liuliangsir
liuliangsir / how-to-batch-convert-jpg-images-to-progressive-jpg-images.md How to batch convert JPG images to progressive JPG images? — First published in fullweb.io issue #82
View how-to-batch-convert-jpg-images-to-progressive-jpg-images.md

How to batch convert JPG images to progressive JPG images?

Progressive JPG images, as opposed to baseline JPG, will display right away in the browser, and will load bits of it in cycle, rendering it from blur to clear.

Progressive is known to provide a better user experience, preventing the ”fax loading” effect. Where the image is displayed in full, but sequentially from top to bottom.

The imagemagick package will install the convert command that you can run to convert JPG to progressive:

convert -strip -interlace Plane -quality 80 input-file.jpg output-file.jpg
@liuliangsir
liuliangsir / ssl-redirect.html
Created Dec 15, 2018 — forked from konklone/ssl-redirect.html
Force a quick redirect to HTTPS on Github Pages for your domain (and only your domain)
View ssl-redirect.html
<script>
var host = "YOURDOMAIN.github.io";
if ((host == window.location.host) && (window.location.protocol != "https:"))
window.location.protocol = "https";
</script>
@liuliangsir
liuliangsir / README.md
Created Dec 12, 2018 — forked from lopspower/README.md
Hexadecimal color code for transparency
View README.md

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

All hex value from 100% to 0% alpha:

View debugger.js
{
dotenv: '/Users/liuliang/Desktop/project/after-effects/.env',
appPath: '/Users/liuliang/Desktop/project/after-effects',
appBuild: '/Users/liuliang/Desktop/project/after-effects/build',
appPublic: '/Users/liuliang/Desktop/project/after-effects/public',
appHtml: '/Users/liuliang/Desktop/project/after-effects/public/index.html',
appIndexJs: '/Users/liuliang/Desktop/project/after-effects/src/index.js',
appPackageJson: '/Users/liuliang/Desktop/project/after-effects/package.json',
appSrc: '/Users/liuliang/Desktop/project/after-effects/src',
testsSetup: '/Users/liuliang/Desktop/project/after-effects/src/setupTests.js',
@liuliangsir
liuliangsir / parseURLParameters.js
Created Nov 21, 2018 — forked from pirate/parseURLParameters.js
Parse URL query parameters in ES6
View parseURLParameters.js
function getUrlParams(search) {
let hashes = search.slice(search.indexOf('?') + 1).split('&')
let params = {}
hashes.map(hash => {
let [key, val] = hash.split('=')
params[key] = decodeURIComponent(val)
})
return params
}
View WAJavascriptBridge.js
(function () {
if (navigator.userAgent.match(/(iPad|iPhone|iPod).*?YY/g)) {
if (
(window.opener == null && window.YYApiCore == null) ||
(window.opener != null && window.opener.YYApiCore == null) ||
(window.YYApiCore && window.YYApiCore.invokeClientMethod && window.YYApiCore.invokeClientMethod.toString()
.length < 20)
) {
var i = document.createElement("iframe");
i.style.display = "none";
You can’t perform that action at this time.