Skip to content

Instantly share code, notes, and snippets.

View pedrospdc's full-sized avatar

Pedro Palhares pedrospdc

  • Source.ag
  • Amsterdam
View GitHub Profile
@pedrospdc
pedrospdc / pc
Created May 15, 2019 11:51
/usr/share/X11/xkb/symbols/pc
default partial alphanumeric_keys modifier_keys
xkb_symbols "pc105" {
key <ESC> { [ Escape ] };
// The extra key on many European keyboards:
key <LSGT> { [ less, greater, bar, brokenbar ] };
// The following keys are common to all layouts.
key <BKSL> { [ backslash, bar ] };
@pedrospdc
pedrospdc / gist:e003c846cc2e2903ab85212be9b6eb41
Created March 26, 2019 16:08
Show all queries in a PostgreSQL container
db:
ports:
- 5432:5432
entrypoint:
- docker-entrypoint.sh
- -c
- log_statement=all
- -c
- log_destination=stderr
- -c
@pedrospdc
pedrospdc / psql.sql
Last active March 20, 2019 09:01
PSQL
-- Find views that depend on something
select schemaname, viewname, viewowner from pg_views where viewowner != ‘rdsadmin’ and definition ilike ‘%pg_stat_activity%‘;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start ASC;
-- kill running query
{
"title": "Change Option + Up / Down to Page Up / Down P",
"rules": [
{
"description": "Change Option + Up / Down to Page Up / Down",
"manipulators": [
{
"from": {
"key_code": "down_arrow",
"modifiers": {
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
def watcher(url, expected_content, expected_status_code, interval, timeout, queue):
response = Response(multiprocessing.current_process().name)
try:
request_response = requests.get(url, timeout=timeout)
except requests.exceptions.ReadTimeout:
error = Timeout('Open page', 'Timed out after {} seconds'.format(timeout))
response.add_error(error)
else:
response.set_elapsed_time(request_response.elapsed)
@pedrospdc
pedrospdc / gist:8850294
Created February 6, 2014 18:51
IPython config
$ ipython profile create
$ vim ~/.config/ipython/profile_default/ipython_config.py
# Configuration file for ipython.
c = get_config()
#------------------------------------------------------------------------------
# InteractiveShellApp configuration
#------------------------------------------------------------------------------
@pedrospdc
pedrospdc / gist:8824935
Last active August 29, 2015 13:56
Proxy pass nginx
proxy_pass http://localhost:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-for $remote_addr;
proxy_connect_timeout 300;
port_in_redirect off;
@pedrospdc
pedrospdc / filter-flow-hotfix-start-version
Created January 21, 2014 20:16
Git flow hook to fetch/merge/name a hotfix/release. Requires Git Flow AVH edition (https://github.com/petervanderdoes/gitflow)
#!/usr/bin/env ruby
#
# Runs during git flow hotfix start
#
# Positional arguments:
# $1 Version
#
# Return VERSION - When VERSION is returned empty, git-flow will stop as the
# version is necessary
#
@pedrospdc
pedrospdc / song_of_time.py
Last active April 3, 2023 14:09
Python Song of Time
import platform
try:
import winsound
beep = winsound.Beep
except ImportError:
def beep(f, d):
s = 8000
hp = int(s/f/2)
b = chr(255)*hp+chr(0)*hp