Skip to content

Instantly share code, notes, and snippets.

View coderaiser's full-sized avatar

coderaiser coderaiser

View GitHub Profile
@littledan
littledan / js-module-bundles.md
Last active March 3, 2021 04:17
JavaScript Module Bundles

Old draft below in case anyone is curious

JavaScript module bundles are a syntax for bundling multiple modules into a single JavaScript file.

A quick example:

// filename: app.jsb
module "./count.js" {

Try-catch oneliner

If you search npm with query try await you will find a big modules list (you can find it in the boottom).

What all this developers want is just more clear way to use try catch. All of them suggest to use:

const tryCatch = require('try-catch');
const [error, data] = tryCatch(JSON.parse, 'hello');
@sebmarkbage
sebmarkbage / WhyReact.md
Created September 4, 2019 20:33
Why is React doing this?

I heard some points of criticism to how React deals with reactivity and it's focus on "purity". It's interesting because there are really two approaches evolving. There's a mutable + change tracking approach and there's an immutability + referential equality testing approach. It's difficult to mix and match them when you build new features on top. So that's why React has been pushing a bit harder on immutability lately to be able to build on top of it. Both have various tradeoffs but others are doing good research in other areas, so we've decided to focus on this direction and see where it leads us.

I did want to address a few points that I didn't see get enough consideration around the tradeoffs. So here's a small brain dump.

"Compiled output results in smaller apps" - E.g. Svelte apps start smaller but the compiler output is 3-4x larger per component than the equivalent VDOM approach. This is mostly due to the code that is usually shared in the VDOM "VM" needs to be inlined into each component. The tr

alert('Hej. Napisz tu litere polskiego alfabetu i zobacz, jak ta litera sie pisze w jezyku ukrainskim')
function isRussian(a) {
return /[А-Яа-я]/.test(a)
};
const data = {
'a' : 'а',
@darrentorpey
darrentorpey / README.md
Last active November 11, 2022 12:46
jscodeshift codemod for Emotion CSS code that converts `styled('p')` expression to `styled.p` expressions etc.
@dmvaldman
dmvaldman / promisesEM.md
Last active November 3, 2021 08:54
Promises as EventEmitters

Promises as EventEmitters

I was trying to understand JavaScript Promises by using various libraries (bluebird, when, Q) and other async approaches.

I read the spec, some blog posts, and looked through some code. I learned how to

@shreyaskarnik
shreyaskarnik / Instructions.md
Last active March 24, 2023 15:35
Route Docker Logs to ELK Stack
  • With Docker 1.8.0 shipped new log-driver for GELF via UDP, this means that the logs from Docker Container(s) can be shipped directly to the ELK stack for further analysis.
  • This tutorial will illustrate how to use the GELF log-driver with Docker engine.
  • Step 1: Setup ELK Stack:
    • docker run -d --name es elasticsearch
    • docker run -d --name logstash --link es:elasticsearch logstash -v /tmp/logstash.conf:/config-dir/logstash.conf logstash logstash -f /config-dir/logstash.conf
    • Note the config for Logstash can be found at this link
    • docker run --link es:elasticsearch -d kibana
  • Once the ELK stack is up now let's fire up our nginx container which ships its logs to ELK stack.
  • LOGSTASH_ADDRESS=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' logstash)
  • `docker run -d --net=host --log-driver=gelf --log-opt gelf-address=u
@PurpleBooth
PurpleBooth / README-Template.md
Last active April 26, 2024 01:29
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@klappradla
klappradla / lame.sh
Last active December 10, 2022 20:02
Using lame command line tool (e.g. convert flac to mp3
# Convert .flac to .mp3 (lossless)
for f in *.flac; do ffmpeg -i "$f" -aq 1 "${f%flac}mp3"; done
# Convert .flac to .mp3, compress to ~ 120k
for f in *.flac; do ffmpeg -i "$f" -aq 5 "${f%flac}mp3"; done
# Convert .flac to mp3, compress to ~ 128k
for f in *.flac; do ffmpeg -i "$f" -b:a 128k "${f%flac}mp3"; done
# Convert .flac to mp3, compress to variable 190k
@gregsh
gregsh / - IDE Scripting.md
Last active March 13, 2024 03:29
IDE Scripting

Here are my attempts to script an IntelliJ-based IDE using javax.script.* API (ex-JSR-223).

The list of available scripting languages and engines:

  1. Groovy - built-in, via Groovy jars and <app>/lib/groovy-jsr223-xxx.jar
  2. JavaScript (Nashorn) - built-in, via Java Runtime <app>/jbr/... (deprecated and will be removed soon)
  3. JavaScript (GraalJS) - https://plugins.jetbrains.com/plugin/12548-intellij-scripting-javascript
  4. JPython - https://plugins.jetbrains.com/plugin/12471-intellij-scripting-python
  5. JRuby - https://plugins.jetbrains.com/plugin/12549-intellij-scripting-ruby
  6. Clojure - https://plugins.jetbrains.com/plugin/12469-intellij-scripting-clojure