This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sqlite3 | |
conn = sqlite3.connect('deleteme.sqlite') | |
# Create custom function in order to handle non-ASCII case-insensitive LIKE | |
conn.create_function('custom_upper', 1, lambda x: x.upper() if x else x) | |
### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" https://www.hackerrank.com/challenges/maximize-it/problem """ | |
import itertools | |
import sys | |
# TEST_INPUT = """3 1000 | |
# 2 5 4 | |
# 3 7 8 9 | |
# 5 5 7 8 9 10""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT UPPER('абв'); | |
SELECT UPPER('абв' COLLATE "C.UTF-8"); | |
SELECT * FROM pg_collation; | |
$ locale -a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"title": "Switch input source language", | |
"rules": [ | |
{ | |
"description": "left_command -> English, right_command -> Russian", | |
"manipulators": [ | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "left_command" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# search file names using the AWS CLI: | |
aws s3 ls s3://bucket --recursive | grep search | cut -c 32- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dump container logs to file | |
sudo docker logs -t CONTAINER > /tmp/logs/CONTAINER.log 2>&1 | |
# sudo docker logs -t 17039371835009_web_1 > /tmp/logs/web.log 2>&1 | |
# sudo docker logs -t 35061773604481_web_1 2>&1 | grep '547ec48a-661f-11e7-a810-5d79ffc97f4e' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove duplicate objects where there is more than one field to compare | |
https://stackoverflow.com/a/13700642 | |
# Simple one-liner | |
UserProfile.objects.values('fullname').order_by().annotate(max_id=models.Max('owner_id'), count_id=models.Count('owner_id')).filter(count_id__gt=1) | |
# Print all SQL to console | |
'loggers': { | |
'django.db.backends': { | |
'level': 'DEBUG', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
pp json.loads(json.dumps(resp.data)) | |
pp json.loads(json.dumps(obj)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 0. Shortcuts. | |
CTRL+A # move to beginning of line | |
CTRL+E # moves to end of line | |
CTRL+G # aborts the current editing command and ring the terminal bell | |
CTRL+K # deletes (kill) forward to end of line | |
CTRL+L # clears screen and redisplay the line | |
CTRL+R # searches backward |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Infinite Loop | |
while true; do echo 'Hit CTRL+C'; sleep 1; done | |
# Video to GIF | |
ffmpeg -i video.mov -ss 00:00:00.000 -pix_fmt rgb8 -r 10 -f gif - | gifsicle --optimize=3 > video.gif |