Skip to content

Instantly share code, notes, and snippets.

View gregdeane's full-sized avatar

Greg Deane gregdeane

  • Berlin, Germany
  • 00:52 (UTC +02:00)
View GitHub Profile
@gregdeane
gregdeane / postgres_queries_and_commands.sql
Created September 21, 2022 06:37 — 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%'

Squash your commits using git interactive rebase

The steps below assume that:

  • you use command-line for git and are using MacOS
  • you are working on a feature branch
  • vim is the default editor.

Notes

  • While in interactive rebase mode, the commits are in the opposite order of the way git log shows them.
  • When you see a command like SHIFT + :, the plus sign should not be pressed.
@gregdeane
gregdeane / git-autocompletion.bash
Created September 21, 2021 04:07
Git auto-completion
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
# *) local and remote tag names
@gregdeane
gregdeane / hide-all-config-except-physics.md
Created June 5, 2020 09:07
vis-network / physics demo
// https://visjs.github.io/vis-network/examples/network/other/configuration.html

// run this in the console
let nodesRaw = document.querySelectorAll('.vis-config-item');
let nodesArray = Array.from(nodesRaw);

let physics = nodesArray.slice(0, nodesArray.length - 16);

physics.forEach(item =&gt; {
@gregdeane
gregdeane / compression.md
Created May 8, 2017 05:35
Helpful Terminal Commands

Compression

  • tar cf file.tar files - create a tar named file.tar containing files
  • tar xf file.tar - extract the files from file.tar
  • tar czf file.tar.gz files - create a tar with Gzip compression
  • tar xzf file.tar.gz - extract a tar using Gzip
  • gzip file - compresses file and renames it to file.gz
  • gzip -d file.gz - decompresses file.gz back to file
@gregdeane
gregdeane / mac-erase-encrypt-external-drive.md
Created January 14, 2017 07:46
Mac / Erase and Encrypt External Drive

Mac / Erase and Encrypt External Drive

  1. Open Disk Utility and click on the drive (not the partition)
  2. Click Erase button
  3. Choose Name
  4. Choose Format: OS X Extended (Journaled)
  5. Choose Scheme: GUID Partition Map
  6. Click Erase button
  7. When complete, open Finder
  8. Right-click on the new drive partition
@gregdeane
gregdeane / snippets.md
Created January 4, 2017 11:34
Random code snippets

Snippets

Replace underscores with hyphens in file and directory names

# perform a dry run first
for i in *; do echo mv "$i" "`echo $i | sed -e 's,_,-,g'`"; done

# actually run the command
for i in *; do mv "$i" "`echo $i | sed -e 's,_,-,g'`"; done
@gregdeane
gregdeane / .zshrc
Last active March 26, 2022 20:47 — forked from cjhowald/.zshrc
Zsh + oh my zsh config
# Path to your oh-my-zsh installation.
export ZSH=/Users/chowald/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Uncomment the following line to use case-sensitive completion.
@gregdeane
gregdeane / seating-specs.md
Last active October 12, 2016 12:31
How to sit at your desk

How to Sit at Your Desk

Seating Specs

@gregdeane
gregdeane / parse.md
Last active October 7, 2016 09:57
Parse URL
/**
 * Return url split into its parts
 * If `key` is passed, return that part of the url
 * If `key` is passed but not found, return all of the parts
 *
 * Allowed keys: "url", "scheme", "host", "port", "path", "query", "hash"
 *
 * @param {string} url - Url to parse
 * @param {string} key - "url", "scheme", "host", "port", "path", "query", "hash"