Skip to content

Instantly share code, notes, and snippets.

@ceejbot
ceejbot / esm_in_node_proposal.md
Last active July 17, 2023 02:45
npm's proposal for supporting ES modules in node

ESM modules in node: npm edition

The proposal you’re about to read is not just a proposal. We have a working implementation of almost everything we discussed here. We encourage you to checkout and build our branch: our fork, with the relevant branch selected. Building and using the implementation will give you a better understanding of what using it as a developer is like.

Our implementation ended up differing from the proposal on some minor points. As our last action item before making a PR, we’re writing documentation on what we did. While I loathe pointing to tests in lieu of documentation, they will be helpful until we complete writing docs: the unit tests.

This repo also contains a bundled version of npm that has a new command, asset. You can read the documentation for and goals of that comma

@matthewzring
matthewzring / markdown-text-101.md
Last active May 4, 2024 12:26
A guide to Markdown on Discord.

Markdown Text 101

Want to inject some flavor into your everyday text chat? You're in luck! Discord uses Markdown, a simple plain text formatting system that'll help you make your sentences stand out. Here's how to do it! Just add a few characters before & after your desired text to change your text! I'll show you some examples...

What this guide covers:

@georgiana-b
georgiana-b / topojson.json
Created July 6, 2017 17:44
The self-contained version of the TopoJSON JSON schema here: https://github.com/nhuebel/TopoJSON_schema
{
"$schema":"http://json-schema.org/draft-04/schema#",
"title":"TopoJSON object",
"description":"Schema for a TopoJSON object",
"type":"object",
"required":[
"type"
],
"properties":{
"bbox":{
node_modules

Motivation

  • expression-oriented programming one of the great advances of FP
  • expressions plug together like legos, making more malleable programming experience in-the-small

Examples

Write in an expression-oriented style, scoping variables as locally as possible:

@bobzhang
bobzhang / Comparison of different langauges
Last active January 5, 2023 18:17
Type safe Alt-JS language comparison
A list of languages which compile to JS (Elm, Purescript, OCaml)
(Inspired by this thread: https://groups.google.com/forum/#!topic/elm-discuss/Um7WIBTq9xU)
They all support curry calling convention by default.
Some interesting results:
1. `min` is curried function, only OCaml(BuckleScript) managed to optimize this overhead.
2. All optimize the self tail call
3. Only BuckleScript and PureScript type-specialized comparison functoin (>=) and inlined
@obskyr
obskyr / stream_response.py
Last active April 2, 2024 09:53
How to stream a requests response as a file-like object.
# -*- coding: utf-8 -*-
import requests
from io import BytesIO, SEEK_SET, SEEK_END
class ResponseStream(object):
def __init__(self, request_iterator):
self._bytes = BytesIO()
self._iterator = request_iterator

Исходные данные: роутер имеет адрес 192.168.1.1, tor и i2pd подняты на 192.168.1.10 (если роутер достаточно мощный, можно поднять их прямо на нём, соответственно скорректировав адреса)

В LEDE для загрузки списка заблокированных доменов проще всего использовать поставляемую по умолчанию утилиту uclient-fetch. Необходимо лишь добавить ей поддержку SSL:

opkg update
opkg install libustream-mbedtls

Впрочем, вы можете использовать wget или curl, если предпочитаете. Особенности wget см. ниже.

@jcberthon
jcberthon / networkmanager-wifi-powersave.md
Last active April 22, 2024 14:33
NetworkManager Wi-Fi powersaving configuration

NetworkManager WiFi Power Saving

NetworkManager supports WiFi powersaving but the function is rather undocumented.

From the source code: wifi.powersave can have the following value:

  • NM_SETTING_WIRELESS_POWERSAVE_DEFAULT (0): use the default value
  • NM_SETTING_WIRELESS_POWERSAVE_IGNORE (1): don't touch existing setting
  • NM_SETTING_WIRELESS_POWERSAVE_DISABLE (2): disable powersave
@bancek
bancek / zipstream.py
Created July 29, 2016 09:49
Python ZIP streaming
import struct
import zipfile
import time
import os
from binascii import crc32
def commonprefix(m):
"Given a list of pathnames, returns the longest common leading component"
if not m: return ''
s1 = min(m)