Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Jeong Seong Dae jeongsd

🎯
Focusing
View GitHub Profile
@hsablonniere
hsablonniere / EXPLAINER.md
Last active Nov 15, 2021
Explainer for my rollup plugin idea about import.meta.url with assets
View EXPLAINER.md

Explainer for my rollup plugin idea

The "i-prefer-import-meta-url-over-using-esm-import-to-get-a-relative-file-url" plugin ;-)

Context

In my components library, I have SVG images. I used them with <img> tags in my components and to get the proper relative URL, I use new URL('../assets/image.svg', import.meta.url').href.

To make this work in a rollup build, you need to:

@mape
mape / apmPatchPrisma.ts
Last active Oct 20, 2021
Elastic APM node client instrumenting Prisma 2 queries
View apmPatchPrisma.ts
import { condensePrismaQuery } from './utils';
// Screenshot of a trace sample: https://i.imgur.com/XuhuQFq.png
// Service: https://www.elastic.co/apm
// Node module: https://github.com/elastic/apm-agent-nodejs
// Prisma: https://www.prisma.io/
// Using "@prisma/client": "dev"
// Thanks to https://github.com/prisma/prisma/pull/2902
@rstacruz
rstacruz / README.md
Last active Nov 8, 2021
Setting up Babel and TypeScript
View README.md

Install Babel 7 and TypeScript

yarn add --dev \
  @babel/core \
  @babel/cli \
  @babel/preset-env \
  @babel/preset-typescript \
  typescript
View authentication_middleware.js
import jwt from "jsonwebtoken";
import User from "@server/models/user_model";
const PRODUCTION = process.env.NODE_ENV === "production";
export default (options) => async (req, res, next) => {
const refreshToken = req.cookies["refresh_token"];
const accessToken = req.cookies["access_token"];
const csrfHeader = req.get("X-Csrf-Token");
@sturmenta
sturmenta / firestore2json.js
Last active Aug 7, 2021
firestore to json & json to firestore
View firestore2json.js
const admin = require('firebase-admin');
const fs = require('fs');
const serviceAccount = require('../../../../../../Private/myschool-data_transfer-key.json');
admin.initializeApp({ credential: admin.credential.cert(serviceAccount) });
const schema = require('./schema').schema;
const firestore2json = (db, schema, current) => {
@jacob-beltran
jacob-beltran / requestAnimationFrame.js
Last active Apr 17, 2020
React Performance: requestAnimationFrame Example
View requestAnimationFrame.js
// How to ensure that our animation loop ends on component unount
componentDidMount() {
this.startLoop();
}
componentWillUnmount() {
this.stopLoop();
}
View rethinkdb-failure-reasons-according-to-hn.md
- Inexplicable perversity of human nature.
- The clever machinations of MongoDB's marketing people.
- The AGPL license killed it.
- We spent too long development before monetizing.
- Bad performance.
- Numeric types limited to a 64-bit `float`.
- Great product, but didn't/couldn't translate to revenue.
- Bad business model.
- Failure in timezones/timestamp nuances.
View docker-cheat-sheat.md

Build docker image

$ cd /path/to/Dockerfile
$ sudo docker build .

View running processes

@chodorowicz
chodorowicz / toggle.js
Last active Feb 15, 2021
lodash toggle array element
View toggle.js
/**
* descructive
* https://github.com/lodash/lodash/issues/1677
*/
function toggle(collection, item) {
var idx = _.indexOf(collection, item);
if(idx !== -1) {
collection.splice(idx, 1);
} else {
collection.push(item);
@sloanwolf
sloanwolf / ReactNativeChatScreenExample.js
Last active Feb 8, 2019
React-Native Chat screen with bottom TextInput
View ReactNativeChatScreenExample.js
/*
* Below is a bare functioning example of how I made a React-Native Chat messaging component that shifts the input up when
* the keyboard is active, and scrolls back down when the keyboard is inactive from a TextInput blur.
*
* The only thing I haven't been able to figure out yet is getting the ListView to render from the bottom, not sure if it's
* possible yet via styles.
*
* NOTE: This uses from iOS-only properties
*/