Skip to content

Instantly share code, notes, and snippets.

View 4nth0's full-sized avatar
🍗

Anthony Capirchio 4nth0

🍗
View GitHub Profile
@4nth0
4nth0 / delete-dynamo-entres.sh
Created August 17, 2021 09:51
Scan and delete entries from Dynamodb using aws cli
#!/bin/sh
table="<table-name>"
region="<table-region>"
primary_keys="first_key"
file_target="scan-results.log"
aws dynamodb scan \
--table-name $table \
@4nth0
4nth0 / switch_case.py
Created February 27, 2020 13:44
Using dictionary as Switch / Case statement in Python
statusMessages = {
0: "Status is pending",
1: "Status is active",
2: "Status is cancelled",
"default": "Status is unknown"
}
def print_status_message(status) :
if status in statusMessages:
print(statusMessages[status])
@4nth0
4nth0 / stream.sh
Created November 22, 2018 14:14
Play YT in VLC
#!/bin/bash
yt_link_to_media=`youtube-dl -g -f best $1`
/Applications/VLC.app/Contents/MacOS/VLC \
--no-video-title-show \
-I macosx \
--video-on-top \
$yt_link_to_media
@4nth0
4nth0 / stream-cli.sh
Created November 22, 2018 14:13
Play YT Playlist directly in terminal
#!/bin/bash
yt_link_to_media=`youtube-dl -g -f bestaudio $1`
/Applications/VLC.app/Contents/MacOS/VLC --intf ncurses $yt_link_to_media
# use: ./stream-cli.sh https://www.youtube.com/playlist?list=PLB40FF393ACBEA4A1
$("#hello").removeClass (function (index, css) {
return (css.match (/\bcolor-\S+/g) || []).join(' ');
});
@4nth0
4nth0 / main.yml
Created February 19, 2016 13:50 — forked from rothgar/main.yml
Generate /etc/hosts with Ansible
# Idempotent way to build a /etc/hosts file with Ansible using your Ansible hosts inventory for a source.
# Will include all hosts the playbook is run on.
# Inspired from http://xmeblog.blogspot.com/2013/06/ansible-dynamicaly-update-etchosts.html
- name: "Build hosts file"
lineinfile: dest=/etc/hosts regexp='.*{{ item }}$' line="{{ hostvars[item].ansible_default_ipv4.address }} {{item}}" state=present
when: hostvars[item].ansible_default_ipv4.address is defined
with_items: groups['all']
@4nth0
4nth0 / book.json
Created February 2, 2016 13:18
Book JSON sample
{
"title": "Bel Ami",
"author": "Guy de Maupassant",
"description": "La Belle Époque. Georges Duroy se retrouve à Paris sans argent en quête d'ascension sociale. Un soir, il rencontre Forestier un ancien camarade de régiment qui va lui proposer un poste de journaliste à la Vie Française. Il fait alors la connaissance de Clotilde de Marelle, la cousine de Madeleine Forestier, qui va lui faire découvrir une éducation sentimentale très libre. Sa beauté et son charme lui ouvrent le c ur des autres femmes qu'il côtoie et peu à peu il occupe des postes plus importants au journal. Tout le monde adopte le surnom \" Bel Ami \" donné par Laurine, la fille de Clotilde.À la mort de son ami Forestier, il épouse sa femme Madeleine et devient aussi l'amant de Madame Walter, l'épouse de son patron. Pour parfaire son ascension, il parvient à contraindre Madeleine au divorce après un constat d'adultère et épouse Suzanne, la fille de Madame Walter, enrichie par des spéculations boursières. Il finira riche, célèbre, député
@4nth0
4nth0 / video-to-gif.sh
Created January 11, 2016 14:24
FFMPEG - Convert movie to gif
# Convert .mov to .gif
ffmpeg -i movie.mov -pix_fmt rgb24 movie-export.gif
# Convert .mov to .gif with acceleration : 0.3 * PTS ( Presentation Time Stamp - https://ffmpeg.org/ffmpeg-filters.html#setpts_002c-asetpts)
# From: https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video
ffmpeg -i trello-use-template.mov -filter:v "setpts=0.3*PTS" -pix_fmt rgb24 trello-use-template.gif
@4nth0
4nth0 / cmd.sh
Created January 5, 2016 17:38 — forked from kelvinn/cmd.sh
Example of using Apache Bench (ab) to POST JSON to an API
# post_loc.txt contains the json you want to post
# -p means to POST it
# -H adds an Auth header (could be Basic or Token)
# -T sets the Content-Type
# -c is concurrent clients
# -n is the number of requests to run in the test
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/
@4nth0
4nth0 / slugify.js
Created December 12, 2015 21:40 — forked from mathewbyrne/slugify.js
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}