Skip to content

Instantly share code, notes, and snippets.

View andrewp-as-is's full-sized avatar
🔍

Andrew P andrewp-as-is

🔍
View GitHub Profile
@andrewp-as-is
andrewp-as-is / settings.py
Last active July 19, 2021 08:10
Django settings SSL HTTPS
"""
https://docs.djangoproject.com/en/dev/topics/security/#ssl-https
"""
if '1' in str(os.getenv('SECURE_SSL')):
SECURE_SSL_REDIRECT = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
"""".env file:
SECURE_SSL=1
@andrewp-as-is
andrewp-as-is / python remove emoji.py
Last active September 21, 2023 05:28
emoji remove
#!/usr/bin/env python
import re
s = 'word1 :blush: word2'
print(re.sub(':[^:]+:', '', s).strip())
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>URL</key>
<string>https://discordapp.com/developers/docs/resources/webhook#execute-webhook</string>
</dict>
</plist>
@andrewp-as-is
andrewp-as-is / register app.sh
Last active January 25, 2022 07:28
macOS lsregister app
#!/usr/bin/env bash
{ set +x; } 2>/dev/null
set ~/Applications/name.app
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -f "$@"
@andrewp-as-is
andrewp-as-is / perl.sh
Last active July 19, 2021 08:10
macOS default browser
#!/usr/bin/env bash
VERSIONER_PERL_PREFER_32_BIT=1 perl -MMac::InternetConfig -le 'print +(GetICHelper "http")[1]'
@andrewp-as-is
andrewp-as-is / Makefile
Last active July 20, 2019 15:08
node-sass
NODE_PATH:=~/node_modules
sass:
node-sass --include-path $(NODE_PATH) ./static/src/index.scss ./static/src/index.css
@andrewp-as-is
andrewp-as-is / copy table.sql
Last active July 19, 2021 08:10
postgres copy table
CREATE TABLE IF NOT EXISTS t(
id serial PRIMARY KEY,
value text
);
INSERT INTO t(id,value) VALUES (1,'value1'), (2,'value2');
CREATE TABLE t_with_data AS TABLE t;
CREATE TABLE t_without_data AS TABLE t WITH NO DATA;
select COUNT(*) from t_without_data;
@andrewp-as-is
andrewp-as-is / data.csv
Last active July 19, 2021 08:10
postgres csv import
1 new_value1
2 new_value2
@andrewp-as-is
andrewp-as-is / _invalid.csv
Last active July 19, 2021 08:10
postgres cvs ERROR: unterminated CSV quoted field
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 1.
1,val"ue
@andrewp-as-is
andrewp-as-is / FUNCTION basename.sql
Last active July 19, 2021 08:10
postgres select basename
CREATE OR REPLACE FUNCTION basename(path text) RETURNS text AS $$
SELECT reverse((regexp_split_to_array(reverse($1), '/'))[1])
$$
LANGUAGE SQL IMMUTABLE;
SELECT basename('/Users/username/git/owner/repo');