Skip to content

Instantly share code, notes, and snippets.

View thapakazi's full-sized avatar
💭
🐧 🗡️ 💻

Milan Thapa thapakazi

💭
🐧 🗡️ 💻
View GitHub Profile
@Kartones
Kartones / postgres-cheatsheet.md
Last active May 27, 2024 08:12
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)
@ttscoff
ttscoff / gen_random_filename.bash
Last active August 29, 2015 14:02
Bash function to generate random 2-word underscore strings for filenames. Uses aspell and shuf (gnu coreutils).
# Bash function gen_random_filename
# Description: Generates random two-word names
# Requires a dictionary file, easily generated with `aspell dump master > dictionary.txt`
# or grab it from https://gist.githubusercontent.com/ttscoff/55493fe89c35ec1588ba/raw/
# Requires shuf (brew install coreutils)
#
# Example results:
# darkest_pickpockets
# besets_struts
# unzip_Malone
@tristanfisher
tristanfisher / Ansible-Vault how-to.md
Last active April 3, 2024 13:55
A short tutorial on how to use Vault in your Ansible workflow. Ansible-vault allows you to more safely store sensitive information in a source code repository or on disk.

Working with ansible-vault


I've been using a lot of Ansible lately and while almost everything has been great, finding a clean way to implement ansible-vault wasn't immediately apparent.

What I decided on was the following: put your secret information into a vars file, reference that vars file from your task, and encrypt the whole vars file using ansible-vault encrypt.

Let's use an example: You're writing an Ansible role and want to encrypt the spoiler for the movie Aliens.

@niccottrell
niccottrell / mongodb-arbiter.conf
Created August 14, 2014 09:22
mongodb arbiter configuration file (shard)
systemLog:
destination: file
path: "/var/log/mongo/mongo-arb.log"
logAppend: true
storage:
dbPath: "/var/lib/mongo-arb"
processManagement:
fork: true
pidFilePath: "/var/run/mongo/mongod-arb.pid"
net:
@tdooner
tdooner / sidekiq.rb
Last active October 14, 2022 12:12
Sidekiq Redis Sentinel configuration
# config/initializers/sidekiq.rb
Sidekiq.configure_client do |config| # and repeat this inside a Sidekiq.configure_server
config.redis = {
master_name: 'your-master-name',
sentinels: [
"sentinel://sentinel01.example.com:26379",
"sentinel://sentinel02.example.com:26379",
"sentinel://sentinel03.example.com:26379",
],
failover_reconnect_timeout: 20, # roughly 3-5 seconds longer than the sentinel failover-timeout
@gregrickaby
gregrickaby / example-nginx.conf
Last active November 22, 2020 20:24 — forked from pmgarman/gist:8fba357c97193633a66d
Defer the loading of images to the production server. Use either Apache or NGINX depending on your local server setup.
################################################################
# Example configuration file for nginx
#
# To add a new local WordPress domain to your environment, copy
# this file using a filename that matches the domain you wish to
# setup. For example - mylocaldomain.com.conf would be an ideal
# filename for http://mylocaldomain.com
#
# Once copied, you will need to modify two settings in the server
# configuration provided:
@obfusk
obfusk / break.py
Last active May 1, 2024 20:32
python "breakpoint" (more or less equivalent to ruby's binding.pry); for a proper debugger, use https://docs.python.org/3/library/pdb.html
import code; code.interact(local=dict(globals(), **locals()))
@ostinelli
ostinelli / ecdsa_example.rb
Last active April 14, 2024 17:32
ECDSA usage from Ruby.
require 'openssl'
require 'base64'
# ===== \/ sign =====
# generate keys
key = OpenSSL::PKey::EC.new("secp256k1")
key.generate_key
public_key = key.public_key
public_key_hex = public_key.to_bn.to_s(16).downcase # public key in hex format