Skip to content

Instantly share code, notes, and snippets.

@tmkdam
tmkdam / gist:d3a7c6fb72e2922ca0298a55f5601b3b
Created January 17, 2022 15:08 — forked from mkocikowski/gist:aeca878d58d313e902bb
Setting up Redis to run as a daemon under systemd

This can be used to daemonize anything that would normally run in the foreground; I picked Redis. Put this in /etc/systemd/system/redis.service:

[Unit]
Description=Redis
After=syslog.target

[Service]
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
RestartSec=5s
@tmkdam
tmkdam / rbenv-ruby187-macos.sh
Created August 24, 2021 00:34 — forked from yatsu/rbenv-ruby187-macos.sh
Install ruby-1.8.7 with rbenv on macOS Catalina (10.15)
#!/bin/sh
# 1) Install Xcode 11
# 2) Install command line tools: `xcode-select --install`
# 3) Install HomeBrew
# 4) brew tap cartr/qt4 && brew install cartr/qt4/[email protected] subversion rbenv
# 5) Setup rbenv
# 6) Run this command
PKG_CONFIG_PATH="$(brew --prefix cartr/qt4/[email protected])/lib/pkgconfig" \
@tmkdam
tmkdam / postgres-cheatsheet.md
Created August 11, 2021 18:46 — 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)
@tmkdam
tmkdam / rails http status codes
Created August 24, 2020 19:48 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@tmkdam
tmkdam / encrypt_decrypt.rb
Created July 24, 2020 18:10 — forked from wteuber/encrypt_decrypt.rb
Simply encrypt and decrypt Strings in Ruby.
require 'openssl'
class String
def encrypt(key)
cipher = OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
cipher.key = Digest::SHA1.hexdigest key
s = cipher.update(self) + cipher.final
s.unpack('H*')[0].upcase
end

Reset mysql root password in Mac OS:

First Stop MySQL:

  1. Go to: 'System Preferences' >> 'MySQL' and stop MySQL

OR,

  1. sudo /usr/local/mysql/support-files/mysql.server start
  2. sudo /usr/local/mysql/support-files/mysql.server stop
@tmkdam
tmkdam / states_hash.json
Created April 13, 2020 17:51 — forked from mshafrir/states_hash.json
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@tmkdam
tmkdam / autofs.md
Created December 26, 2019 16:52 — forked from rudelm/autofs.md
Use autofs on Mac OS X to mount network shares automatically during access

Autofs on Mac OS X

With autofs you can easily mount network volumes upon first access to the folder where you want to mount the volume. Autofs is available for many OS and is preinstalled on Mac OS X so I show you how I mounted my iTunes library folder using this method.

Prepare autofs to use a separate configuration file

autofs needs to be configured so that it knows where to gets its configuration. Edit the file '/etc/auto_master' and add the last line:

#
# Automounter master map
#

+auto_master # Use directory service

@tmkdam
tmkdam / installing_opencv_from_source_in_Ubuntu_1804.sh
Created September 10, 2019 02:44 — forked from Mahedi-61/installing_opencv_from_source_in_Ubuntu_1804.sh
Installing OpenCV from source on Ubuntu 18.04 machine
#!/bin/bash
# This gist is a step by step instructions to build and install OpenCV from source on ubuntu 18.04 LTS
# note: The easy and quick way to install is
# sudo pip3 install opencv-python
# sudo pip3 install opencv-contrib-python
# But this easy pypi installation can’t open video files on GNU/Linux distribution or on mac OS X system.
# And on some system opencv binaries provided packages are not compiled.
# Therefor we have no way rather than build it from source.
@tmkdam
tmkdam / Install_OpenCV3_CUDA9.md
Created September 8, 2019 01:18 — forked from raulqf/Install_OpenCV3_CUDA9.md
Install OpenCV 3.4.1 with CUDA 9.0 support for an Ubuntu 18.04 distro.

How to install OpenCV 3.4.1 with CUDA on Ubuntu distro

First of all install update and upgrade your system:

    $ sudo apt-get update
    $ sudo apt-get upgrade

Then, install required libraries: