Skip to content

Instantly share code, notes, and snippets.

View loisaidasam's full-sized avatar
🙌
🙌

Loisaida Sam loisaidasam

🙌
🙌
View GitHub Profile
@loisaidasam
loisaidasam / fix.txt
Created July 16, 2018 17:27
Bash $PS1 dynamic hostname fix
# Question:
# https://twitter.com/LoisaidaSam/status/1018897916293984256
# Answer:
# https://apple.stackexchange.com/questions/40734/why-is-my-host-name-wrong-at-the-terminal-prompt-when-connected-to-a-public-wifi/127405#127405
:) Michaels-iPhone:~$ scutil --get HostName
HostName: not set
:( 1 Michaels-iPhone:~$ sudo scutil --set HostName 'chewbacca'
Password:
@loisaidasam
loisaidasam / util_db.py
Created May 4, 2018 17:55
Neat Django admin html decorators
def admin_html_link(short_description=None):
"""Neat Django admin html link decorator
Example model usage:
@util_db.admin_html_link("URL playlist")
def url_playlist_html(self):
return self.url_playlist
@loisaidasam
loisaidasam / eastern_time.py
Created April 25, 2018 20:34
Python: Eastern Standard Time vs. Eastern Daylight Time
"""
https://en.wikipedia.org/wiki/Eastern_Time_Zone
"""
>>> import datetime, pytz
# 5 hour difference during Eastern Standard Time
>>> datetime.datetime(2018, 1, 25, 16, 26, tzinfo=pytz.timezone('US/Eastern')).hour
>>> 16
@loisaidasam
loisaidasam / postactivate_template
Created April 24, 2018 14:56
setupvirtualenv - move user into project directory upon virtualenv activation
#!/bin/bash
# This hook is sourced after this virtualenv is activated.
cd "{project_dir}"
# Helpful django aliases
alias djr='./manage.py runserver {djr_port}'
alias djt='./manage.py test'
@loisaidasam
loisaidasam / Default (OSX).sublime-keymap
Last active March 5, 2018 19:08
My `Key Bindings` for the `Macally MKEYE` keyboard
// ~/Library/Application Support/Sublime Text 3/Packages/User/Default (OSX).sublime-keymap
[
// Some specific shit for Macally MKEYE keyboard
// http://macally-europe.com/mkeye-0
// Command logging via:
// https://forum.sublimetext.com/t/shortcuts-not-working-ctrl-u-ctrl-etc/5929/2
// Regular find-context shift + enter:
// {
@loisaidasam
loisaidasam / USAGE.txt
Last active February 15, 2018 20:37
Get a dose of what those silly folks at asciiartfarts.com are up to ...
$ ./ascii-art-farts.sh
# 2204 : DON'T FORGET AHMET AND DIVA
_ ____ ____ ___ ___ _ _ _____ _
/ \ / ___| / ___|_ _|_ _| / \ _ __| |_ | ___|_ _ _ __| |_ ___
/ _ \ \___ \| | | | | | / _ \ | '__| __| | |_ / _` | '__| __/ __|
/ ___ \ ___) | |___ | | | | / ___ \| | | |_ | _| (_| | | | |_\__ \
/_/ \_\____/ \____|___|___| /_/ \_\_| \__| |_| \__,_|_| \__|___/
,@@@@@@@@@, REPEAT:
@@@@@@@@@@@@@@@ WHAT KIND OF ASSHOLE NAMES
@loisaidasam
loisaidasam / postgres_queries_and_commands.sql
Last active February 15, 2019 22:19 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (9.2+)
SELECT pid, age(clock_timestamp(), query_start), usename, state, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start asc;
-- or if your query is very long/verbose
SELECT pid, age(clock_timestamp(), query_start), usename, state, substring(query, 1, 100)
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
#!/bin/bash
# Solver for https://permanent-redirect.xyz
# Saves HTML pages to `pages/` dir
page="$1";
if [ -z "$page" ]
then
echo "Pass a starting page!";
exit 1;
@loisaidasam
loisaidasam / signal_catcher.py
Last active December 8, 2017 18:03
Gracefully handling SIGTERM
"""Gracefully handling SIGTERM
References:
- https://stackoverflow.com/questions/18499497/how-to-process-sigterm-signal-gracefully/31464349#31464349
- https://devcenter.heroku.com/articles/dynos#shutdown
"""
import logging
import signal
@loisaidasam
loisaidasam / README.md
Last active August 20, 2023 15:39
Image EXIF Distance Tools

Image EXIF Distance Tools

Some scripts for finding the distance between the location of an image and the Bank of America Building in Atlanta (or maybe you have a better use-case).

Usage

$ ./image-distance.sh <filename.jpg>