Skip to content

Instantly share code, notes, and snippets.

@judaew
judaew / keychron_k2.adoc
Last active January 8, 2025 06:59
Keychron K2 Manual

Keychron K2 Manual

Connect Bluetooth

On the side of the keyboard, switch the toggle to Bluetooth. Press fn+1 3 seconds and pair with device named Keychron K2.

  • fn+1 connect to 1st device

  • fn+2 connect to 2nd device

  • fn+3 connect to 3rd device

Seven different types of CSS attribute selectors
// This attribute exists on the element
[value]
// This attribute has a specific value of cool
[value='cool']
// This attribute value contains the word cool somewhere in it
[value*='cool']
@gaearon
gaearon / prepack-gentle-intro-1.md
Last active May 3, 2024 12:56
A Gentle Introduction to Prepack, Part 1

Note:

When this guide is more complete, the plan is to move it into Prepack documentation.
For now I put it out as a gist to gather initial feedback.

A Gentle Introduction to Prepack (Part 1)

If you're building JavaScript apps, you might already be familiar with some tools that compile JavaScript code to equivalent JavaScript code:

  • Babel lets you use newer JavaScript language features, and outputs equivalent code that targets older JavaScript engines.

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).

@zthxxx
zthxxx / Activate Office 2019 for macOS VoL.md
Last active January 12, 2025 18:40
crack activate Office on mac with license file
@steveliles
steveliles / mentions-with-draft.js
Created September 20, 2017 12:47
Implementing @Mention's in Draft.js
const { Editor, EditorState, CompositeDecorator, Modifier, SelectionState } = Draft;
const getMentionPosition = () => {
const range = window.getSelection().getRangeAt(0).cloneRange();
const rect = range.getBoundingClientRect();
return { top: rect.bottom, left: rect.left }
}
const getCaretPosition = (editorState) => {
return editorState.getSelection().getAnchorOffset()
@crittermike
crittermike / wget.sh
Last active January 1, 2025 11:34
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
@acdlite
acdlite / app.js
Last active January 20, 2023 08:23
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
@akirattii
akirattii / webworker.example.js
Created June 29, 2016 22:57
WebWorker example using importScript
Webworker
// worker.js
var ju;
addEventListener('message', function(e) {
if (e.data == "dummy") {
importScripts('./JapaneseUtil.js');
console.log("this worker on message...", e);
@Yimiprod
Yimiprod / difference.js
Last active December 2, 2024 19:42
Deep diff between two object, using lodash
/**
* This code is licensed under the terms of the MIT license
*
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {