Skip to content

Instantly share code, notes, and snippets.

View ngpestelos's full-sized avatar

Nestor G Pestelos Jr ngpestelos

View GitHub Profile
@ngpestelos
ngpestelos / remove-docker-containers.md
Last active March 5, 2024 20:45
How to remove unused Docker containers and images

May 8, 2018

I wrote this four years ago, so instead use this command:

$ docker rmi $(docker images -q -f dangling=true)
@ngpestelos
ngpestelos / postgresql-osx.md
Last active July 11, 2023 18:55
How to compile and run PostgreSQL on Mac OS X
@ngpestelos
ngpestelos / create-postgres-account-terminal.md
Created February 21, 2014 01:36
How to create a postgres account from terminal

Note: Based on this tutorial.

Why

There exists a _postgres account, but I could not switch to it. My solution so far is to create a postgres account to run the PostgreSQL process.

Steps

sudo dscl . -create /Groups/postgres

sudo dscl . -create /Groups/postgres PrimaryGroupID 1000

@ngpestelos
ngpestelos / compile-install-postgresql-osx.md
Created February 21, 2014 01:03
Compile and Install PostgreSQL on OS X

Requirements

  • PostgreSQL source

Steps

Create a destination directory:

sudo mkdir -p /opt/local/pgsql
@ngpestelos
ngpestelos / paren_balance.scala
Last active January 23, 2020 15:01
Parentheses Balancing in Scala
def balance(chars: List[Char], open: Int): Boolean = {
if (chars.isEmpty)
open == 0
else if (chars.head == '(')
balance(chars.tail, open + 1)
else if (chars.head == ')' && open > 0)
// found an unmatched '(' earlier
balance(chars.tail, open - 1)
else
balance(chars.tail, open)
version: '2'
services:
redis:
restart: always
image: sameersbn/redis:latest
command:
- --loglevel warning
volumes:
- redis_data:/var/lib/redis
#cloud-config
write_files:
- path: /opt/bin/install_docker_compose.sh
permissions: 0700
owner: root
content: |
#!/bin/bash
set -e
set -u
variable "do_token" {}
provider "digitalocean" {
token = "${var.do_token}"
}
resource "digitalocean_droplet" "gitlab-selfhosted" {
image="coreos-stable"
name="gitlab"
region="sfo2"
@ngpestelos
ngpestelos / .vimrc.after
Created October 8, 2013 03:38
Ramon's vimrc.after
" Many stuff from http://www.drbunsen.org/text-triumvirate.html
" Visual mode unmap
" Bring back the functionality to press shift+e, shift+w, shift+b
" while in visual mode to go to the character right before the next
" whitespace
vunmap E
vunmap W
vunmap B
@ngpestelos
ngpestelos / object_extensions.rb
Created October 1, 2013 20:49
object extensions
# see Metaprogramming Ruby, p. 118
module MyModule
def my_method; 'hello'; end
end
obj = Object.new
class << obj
include MyModule
end