Skip to content

Instantly share code, notes, and snippets.

i
me
my
myself
we
our
ours
ourselves
you
your
@CarlosDomingues
CarlosDomingues / python-poetry-cheatsheet.md
Last active April 22, 2024 09:28
Python Poetry Cheatsheet

Create a new project

poetry new <project-name>

Add a new lib

poetry add <library>

Remove a lib

@ankjevel
ankjevel / clear-cache.sh
Last active April 18, 2024 08:31
clear npm cache (when using nvm); run with `nvm list | clear-cache`
#!/usr/bin/env bash
function clear-cache {
versions=()
while read -r line; do
clean="$(echo ${line} | sed "s,$(printf '\033')\\[[0-9;]*[a-zA-Z],,g")"
valid=$(echo "${clean}" | grep '^[^a-zA-Z]' | grep -v 'system' | sed 's/->//' | sed 's/\s.*v//')
if [[ ! -z $valid ]]; then
versions+=(${valid})
@coryodaniel
coryodaniel / list.txt
Created May 13, 2020 22:04
GCP List of API Services
NAME TITLE
abusiveexperiencereport.googleapis.com Abusive Experience Report API
acceleratedmobilepageurl.googleapis.com Accelerated Mobile Pages (AMP) URL API
accessapproval.googleapis.com Access Approval API
accesscontextmanager.googleapis.com Access Context Manager API
actions.googleapis.com Actions API
adexchangebuyer-json.googleapis.com Ad Exchange Buyer API
adexchangebuyer.googleapis.com Ad Exchange Buyer API II
adexchangeseller.googleapis.com Ad Exchange Seller API
adexperiencereport.googleapis.com Ad Experience Report API
@tracker1
tracker1 / 01-directory-structure.md
Last active April 15, 2024 13:58
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

Directories

  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used

bazel query cheatsheet

which packages depend on qtdb lib?

bazel query 'rdeps(..., //vistar/geo/qtdb:go_default_library)' --output package 

which packages does qtdb depend on?

@soulmachine
soulmachine / jwt-expiration.md
Last active April 9, 2024 04:12
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

@yurydelendik
yurydelendik / gist:f2b846dae7cb29c86d23
Last active April 4, 2024 06:38
PDF.js get/show hightlight
function getHightlightCoords() {
var pageIndex = PDFViewerApplication.pdfViewer.currentPageNumber - 1;
var page = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
var pageRect = page.canvas.getClientRects()[0];
var selectionRects = window.getSelection().getRangeAt(0).getClientRects();
var viewport = page.viewport;
var selected = selectionRects.map(function (r) {
return viewport.convertToPdfPoint(r.left - pageRect.x, r.top - pageRect.y).concat(
viewport.convertToPdfPoint(r.right - pageRect.x, r.bottom - pageRect.y));
});
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@laobubu
laobubu / ABOUT.md
Last active March 23, 2024 05:28
A very simple HTTP server in C, for Unix, using fork()

Pico HTTP Server in C

This is a very simple HTTP server for Unix, using fork(). It's very easy to use

How to use

  1. include header httpd.h
  2. write your route method, handling requests.
  3. call serve_forever("12913") to start serving on port 12913