Skip to content

Instantly share code, notes, and snippets.

View fatelei's full-sized avatar
:octocat:
Focusing

wangxiaolei fatelei

:octocat:
Focusing
View GitHub Profile
@fatelei
fatelei / linkify.js
Last active June 11, 2019 01:32
Using linkify-it to auto link content.
import * as LinkifyIt from 'linkify-it';
import * as React from 'react';
import * as tlds from 'tlds';
/* Pass tests
describe('linkify work as expected', () => {
let rst: React.ReactNode[] = [];
it('linkify empty content', () => {
rst = linkify('');
expect(rst[0]).toBe('');
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active February 24, 2026 14:08
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@bvaughn
bvaughn / index.md
Last active September 4, 2025 07:11
Interaction tracing with React

This API was removed in React 17


Interaction tracing with React

React recently introduced an experimental profiler API. After discussing this API with several teams at Facebook, one common piece of feedback was that the performance information would be more useful if it could be associated with the events that caused the application to render (e.g. button click, XHR response). Tracing these events (or "interactions") would enable more powerful tooling to be built around the timing information, capable of answering questions like "What caused this really slow commit?" or "How long does it typically take for this interaction to update the DOM?".

With version 16.4.3, React added experimental support for this tracing by way of a new NPM package, scheduler. However the public API for this package is not yet finalized and will likely change with upcoming minor releases, so it should be used with caution.

@VojtechVitek
VojtechVitek / slice-batch-in-parallel.go
Last active December 17, 2024 21:46
Golang - Loop over slice in batches (run something in parallel on a sub-slice)
package main
import "fmt"
func main() {
slice := make([]int, 159)
// Split the slice into batches of 20 items.
batch := 20
@heiswayi
heiswayi / repo-reset.md
Created February 5, 2017 01:32
GitHub - Delete commits history with git commands

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A
@velizarn
velizarn / ip6tables_setup.bash
Last active December 22, 2025 18:51
Basic setup for ip6tables - drop all traffic except local, ICMP and DHCPv6 traffic.
#!/bin/bash
# http://serverfault.com/questions/410321/debian-ip6tables-rules-setup-for-ipv6/410327#410327
# http://ipset.netfilter.org/iptables.man.html
# https://www.sixxs.net/wiki/IPv6_Firewalling
# https://www.cyberciti.biz/faq/ip6tables-ipv6-firewall-for-linux/
# https://gist.github.com/thomasfr/9712418
# https://gist.github.com/SnakeDrak/f4150f6e517e5a1d525f
# http://www.thegeekstuff.com/2011/06/iptables-rules-examples
# http://www.thegeekstuff.com/scripts/iptables-rules
@fatelei
fatelei / tmux.conf
Created January 31, 2016 04:53
Tmux config
set-option -g default-shell "/usr/local/bin/fish"
set -g default-terminal "xterm-256color"
# -*- coding: utf8 -*-
"""
ip_location
~~~~~~~~~~~
Using ip138.com to lookup location via ip.
"""
import requests
from bs4 import BeautifulSoup
/**
* Wechat token validation scripts.
* required node >= 4.2.1
* You need change the `token` if need.
*/
'use strict';
const crypto = require('crypto');
const http = require('http');
const querystring = require('querystring');
@fatelei
fatelei / to_localtime.py
Last active September 10, 2015 08:05
Python convert utc timestamp to local timestamp.
# -*-coding: utf8-*-
import datetime
def to_localtime(utc_timestamp):
"""Convert utc timestamp to local timestamp.
:param datetime utc_timestamp: Timestamp from utc
:return: Local timestamp.
"""