Skip to content

Instantly share code, notes, and snippets.

@rudylee
rudylee / show-database.rb
Created February 4, 2020 01:55
Show SQL queries
ActiveRecord::Base.logger = Logger.new(STDOUT)
@rudylee
rudylee / psql-find-duplicate.sql
Created January 15, 2020 04:51
PostgreSQL find duplicate rows
SELECT column1, count(*)
FROM table
GROUP BY column1
HAVING count(*) > 1;
@rudylee
rudylee / typescript.md
Last active January 22, 2019 00:37
Typescript Cheatsheet

Create a new react app with typescript

npx create-react-app <project name> --typescript
cd <project name>
yarn add tslint tslint-react tslint-config-prettier --save-dev
@rudylee
rudylee / redshift-cheatsheet.sql
Last active April 14, 2019 11:59
Redshift Cheatsheet
## General Stuff
### List all tables
SELECT * FROM pg_catalog.pg_tables
### Create a new user and give it superuser access
CREATE USER adminuser createuser password '1234Admin';
ALTER USER adminuser createuser;
### Create a user without superuser privilege
@rudylee
rudylee / Docker.md
Created August 28, 2015 06:34
How to attach new volume to an EC2 instance and move /var/lib/docker to that volume

Find the device name

fdisk -l

Format the drive

sudo mkfs -t ext4 /dev/xvdf

Mount and specify file system type

sudo mount /dev/xvdf /mnt/docker/ -t ext4

Verify it

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

private bool ValidRequisitieMeet(int userId, int subjectId)
{
// Fetch the enrollment passed status from configuration file
var passed = TryToParse(ConfigurationManager.AppSettings.Get("EnrollmentStatusPassed"));
var requisites = (from r in _context.Requisites
where r.SubjectId == subjectId
select r);
// For the sake of readability, use traditional way
@rudylee
rudylee / gist:5640463
Created May 24, 2013 00:12
Registry file to make Putty use Ubuntu's Font
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\Default%20Settings]
"Font"="Ubuntu Mono"
"FontIsBold"=dword:00000000
"FontCharSet"=dword:00000000
"FontHeight"=dword:0000000c
"FontVTMode"=dword:00000004
"UseSystemColours"=dword:00000000
"TryPalette"=dword:00000000
@rudylee
rudylee / gist:5298822
Created April 3, 2013 06:10
Fix rb-readline problem in Ubuntu 12.04
rvm uninstall ${YOURUBYVERSION}
sudo apt-get install libreadline-dev
rvm install ${YOURUBYVERSION} --with-readline-dir=/usr/include/readline
@rudylee
rudylee / gist:5297862
Last active December 15, 2015 17:39
Console command to fix unknown monitor resolution in Ubuntu 12.04
xrandr --newmode $(cvt 1920 1200 60 | grep Mode | sed -e 's/.*"/1920x1200/')
xrandr --addmode VGA1 1920x1200