Skip to content

Instantly share code, notes, and snippets.

View kcjpop's full-sized avatar
🕳️

An Cao kcjpop

🕳️
View GitHub Profile
@sogaiu
sogaiu / gist:94a09e941dab2878827daea7236343db
Last active May 17, 2024 12:44
various repositories of janet code
https://codeberg.org/amano.kenji/j3blocks
https://codeberg.org/amano.kenji/j3blocks-extra
https://git.envs.net/iacore/janet-sibilant-web
https://git.envs.net/iacore/janet-signal
https://git.sr.ht/~alect/fantasy-console-carts
https://git.sr.ht/~alect/jaydate
https://git.sr.ht/~alect/junk-drawer
https://git.sr.ht/~alect/secret-santa-jam-2022
https://git.sr.ht/~bakpakin/bee-server
https://git.sr.ht/~bakpakin/jvk
@mcrumm
mcrumm / phx_sqlite_fly_launch.md
Last active May 3, 2024 09:38
Phoenix + SQLite Deployment tips

Deploying to Fly.io with SQLite

Deploying a Phoenix app to Fly.io is a breeze...is what everyone kept telling me. In fairness, I imagine the process would have been breezier had I just used postgres, but all the sqlite and litestream talk has been far too intriguing to ignore. "Wait", you say. "It is just a flat file. How much harder can it be?"

It is easy to make something harder than it should be. It is hard to take something complex and make it truly simple. flyctl launch does an amazing job at providing a simple interface to the utterly complex task of generating deployment resources, especially now that we are living in a containerd (erm, firecracker) world.

This gist is for anyone who, like me, thinks they know better than to read all of the documentation and therefore necessari

@evaera
evaera / Clean Code.md
Last active July 16, 2024 04:30
Best Practices for Clean Code
  1. Use descriptive and obvious names.
    • Don't use abbreviations, use full English words. player is better than plr.
    • Name things as directly as possible. wasCalled is better than hasBeenCalled. notify is better than doNotification.
    • Name booleans as if they are yes or no questions. isFirstRun is better than firstRun.
    • Name functions using verb forms: increment is better than plusOne. unzip is better than filesFromZip.
    • Name event handlers to express when they run. onClick is better than click.
    • Put statements and expressions in positive form.
      • isFlying instead of isNotFlying. late intead of notOnTime.
      • Lead with positive conditionals. Avoid if not something then ... else ... end.
  • If we only care about the inverse of a variable, turn it into a positive name. missingValue instead of not hasValue.
;; PDF
(pdf-tools-install)
(add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode))
(setq pdf-annot-activate-created-annotations t)
(add-hook 'pdf-view-mode-hook (lambda()
(linum-mode -1)
(pdf-view-midnight-minor-mode 1)
(evil-local-mode -1)
(setq bookmark-default-file (concat (file-name-directory (directory-file-name (file-name-directory (buffer-file-name)))) "bookmark"))
))
const React = require("react");
const Lifecycles = React.createLifecycleEvents({
didMount({ setState }) {
setState({
disabled: false,
});
},
didUpdate({ inputRef }) {
if (document.activeElement !== inputRef.value) {

Language basics

let is just an expression and akin to a function!

let greeting = hello
let greeting = "hi"; /* shadowed */
let scoped = {
@thaod
thaod / ke-chuyen-ve-react-redux.md
Last active January 9, 2018 12:13
Kể chuyện về React/Redux

Hỏi: Ae nghĩ gì về chuyện force immutability của React/Redux? Nguyên nhân? Hiệu quả? Có làm khác đi đc ko?

TL;DR: Tính chính xác trong kiến thức công nghệ của comment này không cao để trả lời rõ ràng câu hỏi trên, nên chủ yếu mình chỉ là kể lại những gì đã xảy ra để có thêm góc nhìn thôi :).

Dựa vào trải nghiệm đầu năm 2017 khi build dự án React/Redux làm về Fintech, gắn bó chừng 4 tháng:

Nguyên nhân: Đa số là nguyên nhân chủ quan.

Vì ngày đó Redux là “the one” trong giải pháp về states manament. Nên concept của nó như rứa thì phải theo.

@JamieMason
JamieMason / es6-partial-application.md
Last active September 19, 2020 20:41
ES6 Partial Application in 3 Lines

ES6 Partial Application in 3 Lines

const pApply = (fn, ...cache) => (...args) => {
  const all = cache.concat(args);
  return all.length >= fn.length ? fn(...all) : pApply(fn, ...all);
};

Example

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@paulirish
paulirish / what-forces-layout.md
Last active July 27, 2024 23:38
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.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent