Skip to content

Instantly share code, notes, and snippets.



View GitHub Profile
Luke-SNAW / next.config.js
Last active Feb 8, 2022
[next.js .env for client] #nextjs
View next.config.js
// Next.js comes with built-in support for environment variables.
module.exports = {
env: {
Luke-SNAW / google-translate-element.vue
Last active Jan 27, 2022
[google translate element] #google #plugin
View google-translate-element.vue
<div id="google_translate_element" />
import { Policy } from 'cockatiel'
import { includeJsOnce, injectStyles } from '@/utils'
export function initTranslate() {

The N+1 query problem is a common performance antipattern. It looks like this:

$cats = load_cats();
foreach ($cats as $cat) {
  $cats_hats = load_hats_for_cat($cat);
  // ...
Luke-SNAW /
Last active Feb 10, 2022
[Javascript as language] #collections #javascript


  • Closures: A closure is a function having access to the parent scope, even after the parent function has closed.
  • Closures: A function bundled together with its lexical environment forms a closure.

Advantages and Disadvantages of Closures


  • Closures help in data encapsulation, i.e, with closures, you can store data in a separate scope and share it only where necessary.
  • Modern JavaScript libraries (like React) heavily rely on closures for rendering components on state or prop change.
Luke-SNAW /
Created Dec 23, 2021
[You Can't Buy Integration - Hacker News] #SE

Business logic happens line by line between interfaces. Coding may be all ifs and for loops, but when it comes to implementing a new feature, having chosen carefully where to draw the line between, say, your model and your view can be the difference between a 10 line patch and a complete rewrite.

If you don’t have a culture of code review then maybe the rewrite will fly, bugs and all, through to production. If however you have the ability to reason logically about the salient changes diff by prescient diff — where by definition each prescient diff represents nothing but the salient changes — then you at least stand a fighting chance of version N+1 having fewer bugs than version N while also moving your business forwards.