Skip to content

Instantly share code, notes, and snippets.

View lwxyfer's full-sized avatar
💭
I may be slow to respond.

LW lwxyfer

💭
I may be slow to respond.
View GitHub Profile
@lwxyfer
lwxyfer / Git Commands.md
Created February 13, 2019 03:09 — forked from abadongutierrez/Git Commands.md
Useful git commands

Getting logs

Branching

Checkout remote branch with the same name and tracking it

git checkout --track origin/<branc-name>
@lwxyfer
lwxyfer / crossed.css
Last active May 6, 2019 02:49
table crossed node
// 表格斜角线
table td.crossed
{
background-image: linear-gradient(to bottom right, transparent calc(50% - 1px), red, transparent calc(50% + 1px));
}
@lwxyfer
lwxyfer / cssom.js
Created March 17, 2018 12:57
Get element info, good compatibility
cssom = {
// 获取元素在页面的绝对位置
absPosition(node) {
return node.getBoundingClientRect().top < 0 ? window.pageYOffset - Math.abs(node.getBoundingClientRect().top) : window.pageYOffset + node.getBoundingClientRect().top
},
// 读取页面垂直方向已滚动距离
readScrollY() {
return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
},
// 设置页面垂直滚动位置
@lwxyfer
lwxyfer / scrollbar.scss
Created March 1, 2018 07:20
style for scroll bar
.container {
&::-webkit-scrollbar {
width: 8px;
cursor: grab;
}
&::-webkit-scrollbar-thumb {
border-radius: 0;
background: #2c2f4e;
cursor: grab;
const phone = '^1\d{10}$' // 11 phone number
const title = '^[\u4e00-\u9fa5_a-zA-Z0-9]+$' // chinese, English, number, _
const domain = '^[a-zA-Z0-9][a-zA-Z0-9\-\.]{0,61}[^\.\-]$' // domain
@lwxyfer
lwxyfer / Acceleration.js
Created August 30, 2017 14:29
simulate quick flick of touch gesture to
// Reference: https://github.com/souhe/reactScrollbar/blob/master/src/js/ScrollArea.jsx
// Always use this to implement elastic scroll animation
const test = document.getElementById('test');
let timeStamp = 0;
let eventPreviousValues = {};
test.addEventListener('touchstart', () => {
console.log('start');
})
@lwxyfer
lwxyfer / server.js
Created July 20, 2017 10:27
quickly start a static files server based on Node
const http = require('http');
const path = require('path');
const fs = require('fs');
const url = require('url');
const os = require('os');
const server = new http.Server();
const interfaces = os.networkInterfaces();
const addresses = [];
@lwxyfer
lwxyfer / addresses.js
Created July 20, 2017 09:57
get local IP addresses
const os = require('os');
const interfaces = os.networkInterfaces();
const addresses = [];
for (let k in interfaces) {
for (let k2 in interfaces[k]) {
let address = interfaces[k][k2];
if (address.family === 'IPv4' && !address.internal) {
addresses.push(address.address);
@lwxyfer
lwxyfer / page-archives.hbs
Created July 8, 2017 17:22
ghost theme archives page
{{!< default}}
<header class="main-header post-head {{#if image}}" style="background-image: url({{image}}){{else}}no-cover{{/if}}">
<nav class="main-nav {{#if image}}overlay{{/if}} clearfix">
{{#if @blog.logo}}<a class="blog-logo" href="{{@blog.url}}"><img src="{{@blog.logo}}" alt="{{@blog.title}}" /></a>{{/if}}
{{#if @blog.navigation}}
<a class="menu-button icon-menu" href="#"><span class="word">Menu</span></a>
{{/if}}
</nav>
</header>
@lwxyfer
lwxyfer / nginxproxy.md
Created September 11, 2016 08:09 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers