Skip to content

Instantly share code, notes, and snippets.

View waltercool's full-sized avatar

WalterCool waltercool

View GitHub Profile
  1. Stopping a zombie machine: aws opsworks stop-instance --instance-id <opsworks ID>

  2. Resize root disk on AWS:
    z) partprobe /dev/xvdX
    a) parted /dev/xvdX print
    b) parted /dev/xvdX resizepart Y && resize2fs /dev/xvdXY # resize2fs needed to update the partition table

Update for xfs partitions:

a) growpart /dev/xvda 1

@waltercool
waltercool / postgres_queries_and_commands.sql
Created June 9, 2017 16:28 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), 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(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@waltercool
waltercool / enum.py
Created May 17, 2018 15:13 — forked from b1naryth1ef/enum.py
PeeWee Postgres Enum Field
from peewee import *
class BModel(Model):
class Meta:
database = db
@classmethod
def create_table(cls, *args, **kwargs):
for field in cls._meta.get_fields():
if hasattr(field, "pre_field_create"):
@waltercool
waltercool / gist:07b66e42f9e66fafaa9945e2a2b88206
Last active February 26, 2019 15:10
Postgresql Backup&Restore
Backup: pg_dump -Fc -f /path/to/backup.dump
Restore: pg_restore -U <USER> -h <HOST> -d <DATABASE> -Fc -Oxc backup.dump
@waltercool
waltercool / gist:b3247dfc562b6e29683295918d49f323
Last active October 12, 2018 14:51
Excluding ElasticSearch node and migrate all it data for shutdown or maintainance operations
curl -XPUT <hostname-or-IP>:9200/_cluster/settings -H 'Content-Type: application/json' -d '{
"transient" :{
"cluster.routing.allocation.exclude._ip" : "X.X.X.X"
}
}'
@waltercool
waltercool / varnish-purge-cache.sh
Created October 16, 2018 23:18 — forked from andrezrv/varnish-purge-cache.sh
Purge all Varnish cache.
# Purge all Varnish cache
varnishadm "ban req.url ~ /"
@waltercool
waltercool / vimdiff.md
Created January 18, 2019 19:50 — forked from mattratleph/vimdiff.md
vimdiff cheat sheet

vimdiff cheat sheet

##git mergetool

In the middle file (future merged file), you can navigate between conflicts with ]c and [c.

Choose which version you want to keep with :diffget //2 or :diffget //3 (the //2 and //3 are unique identifiers for the target/master copy and the merge/branch copy file names).

:diffupdate (to remove leftover spacing issues)

:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)

@waltercool
waltercool / gist:dfe52ad1868939fd36825c565363e4a5
Last active February 15, 2019 22:56
Sidekiq Swiss Knife
# Clear all sidekiq scheduled
require 'sidekiq/api'
Sidekiq::ScheduledSet.new.clear
# Clear an specific queue by job name
jobs = Sidekiq::ScheduledSet.new.select {|retri| retri.klass == 'job_name' }
jobs.each(&:delete)
@waltercool
waltercool / gist:0723f53ed479c25061bcdb1178198c97
Last active August 24, 2020 09:44
ffmpeg personal swissknife
# Compress x265 with deinterlace using Cuda
ffmpeg -hwaccel cuvid -i <INPUT> -pix_fmt p010le -vf yadif -c:v hevc_nvenc -preset slow -acodec copy <OUTPUT> #NOT WORKING ANYMORE
ffmpeg -i <INPUT> -vf yadif=parity=auto -vcodec hevc_nvenc -acodec copy -preset slow <OUTPUT>
# Merge Video+Audio
ffmpeg -i <Video> -i <Audio> -codec copy -shortest <OUTPUT>
# Extract audio from Video under Mono
ffmpeg -i <VIDEO> -vn -ac 1 <Audio>
How to connect USB through debug console
device_add usb-host,vendorid=0xL33T,productid=0xDEMO,id=whatever
(Obtain values from L33T and DEMO with lsusb)
Make sure to provide QEMU access to /dev/bus/usb/X/Y, take X and Y from dmesg values