Skip to content

Instantly share code, notes, and snippets.

View jahan-addison's full-sized avatar

Jahan Addison jahan-addison

View GitHub Profile
# How to consume Github Package private registry with yarn?
Create an .npmrc file in the same location as the package.json with this content.
```
registry=https://registry.yarnpkg.com/
@<username>:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=<your auth token>
always-auth=true
@jonathantneal
jonathantneal / defineProp.js
Last active January 11, 2023 05:16
defineProp: Like Object.defineProperty but with a bitmask number instead of a complex object
/*
| bitmask | enumerable | configurable | writable | accessor |
| ------- | ---------- | ------------ | -------- | -------- |
| 0 | | | | |
| 1 | YES | | | |
| 2 | | YES | | |
| 3 | YES | YES | | |
| 4 | | | YES | |
| 5 | YES | | YES | |
| 6 | | YES | YES | |
/*
<breakpoint-list> := <condition> <breakpoint-func> [ ',' <condition> <breakpoint-func> ]*
*/
function parseABreakpointList(string) {
return string.split(/,\s+/).reduce(
(acc, part) => {
const [full, condition, breakpoints] = part.trim().match(
/^([a-zA-Z-]+)\s*(--breakpoints\(.*\))$/
/*
Here's one way you might be able to use the concept of having a defined set
of named breakpoints in CSS for the purpose of preprocessing media queries.
Imagine you have a global configuration where your breakpoints are listed,
along with the associated names, then you are able to write other CSS targeting
those named breakpoints:
*/
function todoml(string) {
return string
.split('\n')
.reduce((html, line) => {
// prepare the line
line = line.trim()
// bold
.replace(
/(\*\*)([^\*]+)(\*\*)/g,
@fay59
fay59 / Quirks of C.md
Last active September 4, 2024 23:07
Quirks of C

Here's a list of mildly interesting things about the C language that I learned mostly by consuming Clang's ASTs. Although surprises are getting sparser, I might continue to update this document over time.

There are many more mildly interesting features of C++, but the language is literally known for being weird, whereas C is usually considered smaller and simpler, so this is (almost) only about C.

1. Combined type and variable/field declaration, inside a struct scope [https://godbolt.org/g/Rh94Go]

struct foo {
   struct bar {
 int x;
@tomhodgins
tomhodgins / config.fish
Last active February 11, 2023 14:13
This is a proof of concept, eventually I want a CLI I can use like `tasq add Buy groceries` or `tasq tag 15 work`, or `tasq check 24`; GIF: https://imgur.com/a/lkh5c9w
# tasq
function tasq
cd ~/Code/tasq/
node index.js (echo $argv)
end
@althonos
althonos / setup.cfg
Last active March 4, 2024 18:08
A `setup.cfg` template for my Python projects
# https://gist.github.com/althonos/6914b896789d3f2078d1e6237642c35c
[metadata]
name = {name}
version = file: {name}/_version.txt
author = Martin Larralde
author_email = [email protected]
url = https://github.com/althonos/{name}
description = {description}
long_description = file: README.md

Design Environment

Environment Principles

  • All documents are objects with a type (text, image, audio, video, hypertext)
  • You can extend the types of documents (think like making document templates)
  • You can nest, transclude, or link objects inside other objects
  • Your environment has a concept of a 'current selection' of 0-∞ objects
  • The context of your environment UI is always relative to the type(s) and number of objects held in the 'current selection' at all times
  • There are no 'programs' or applications, everything is system-wide. If you teach the system to read and record JPEG, every image-modifying method has the ability to make use of that.
@chrishalebarnes
chrishalebarnes / qs.js
Created September 7, 2017 19:13
Safer QuerySelector
function qs(selector, callback, context) {
if(callback === undefined) return;
context = context || document;
const result = context.querySelector(selector);
if(result) {
return callback(result);
}
}
qs('.some .selector', (safeElement) => {