Skip to content

Instantly share code, notes, and snippets.

View th3hunt's full-sized avatar
🎯
Focusing

Stratos Pavlakis th3hunt

🎯
Focusing
  • Blueground
  • Athens
View GitHub Profile
@th3hunt
th3hunt / postgres_queries_and_commands.sql
Created October 11, 2023 13:08 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@th3hunt
th3hunt / jupyterlab_shortcuts.md
Created June 18, 2023 08:06 — forked from discdiver/jupyterlab_shortcuts.md
Common Jupyter Lab Keyboard Shortcuts

If you are on a Mac, substitute command for control. Don't type the + (it means press both keys at once).

Shortcuts when in either command mode (outside the cells) or edit mode (inside a cell):

  • Shift + Enter run selected cell or cells - if no cells below, insert a code cell below

  • Ctrl + B toggle hide/show left sidebar

  • Ctrl + S save and checkpoint

  • Ctrl + Shift + S save as

@th3hunt
th3hunt / esm-cjs-modules.md
Created April 5, 2022 12:24 — forked from aelbore/esm-cjs-modules.md
Publish your npm package as ES Module, and backward compatibility CommonJS

Create your library

  • Initialize project npm init -y
  • Create esm module ./src/esm/my-lib.js
    function addNumber(value, value2) {
      return value + value2;
    }
    
    export { addNumber };
@th3hunt
th3hunt / http_streaming.md
Created February 27, 2022 10:46 — forked from CMCDragonkai/http_streaming.md
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

@th3hunt
th3hunt / loadScript.js
Last active May 18, 2021 12:53
Script & CSS load utils
export const status = {
TIMEOUT: 'timeout',
SUCCESS: 'success',
SKIPPED: 'skipped'
};
/**
* Load a JS script programmatically.
*
* The <script> element get inserted as the last child of <body> by default but can be customized
@th3hunt
th3hunt / nestedHistory.js
Created November 18, 2020 15:57
Nested History
/**
* NestedHistory
* -------------
*
* TODO: doc
*
*/
import _ from 'underscore';
import Marionette from 'backbone.marionette';
import Hammer from 'hammerjs';
import $ from 'jquery';
import _ from 'underscore';
export default Marionette.Behavior.extend({
defaults: {
threshold: 30
},
@th3hunt
th3hunt / .zshrc
Created June 11, 2020 10:31 — forked from callumlocke/.zshrc
ZSH function to auto-switch to correct Node version
####
# ZSH function to auto-switch to correct Node version
# https://gist.github.com/callumlocke/30990e247e52ab6ac1aa98e5f0e5bbf5
#
# - Searches up your directory tree for the closest .nvmrc, just like `nvm use` does.
#
# - If you are already on the right Node version, IT DOES NOTHING, AND PRINTS NOTHING.
#
# - Works correctly if your .nvmrc file contains something relaxed/generic,
# like "4" or "v12.0" or "stable".
@th3hunt
th3hunt / postgres-cheatsheet.md
Created January 3, 2019 13:52 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@th3hunt
th3hunt / Dockerfile
Last active October 31, 2018 08:37
Sample Dockerfile
FROM node:8-alpine
EXPOSE 3000
ARG NODE_ENV
ENV NODE_ENV $NODE_ENV
RUN apk add --update curl && rm -rf /var/cache/apk/*
RUN mkdir /app