Skip to content

Instantly share code, notes, and snippets.

@arthuralvim
arthuralvim / monthyearfield.py
Last active December 16, 2015 23:59 — forked from yashh/monthyearfield.py
A MonthYearWidget forked from yashh/monthyearfield.py .
from django import forms
import datetime
class MonthYearWidget(forms.MultiWidget):
"""
A widget that splits a date into Month/Year with selects.
"""
@arthuralvim
arthuralvim / s3cmd_sync.sh
Last active September 1, 2015 20:44 — forked from niraj-shah/s3cmd_sync.sh
Downloading files from S3.
# Installation
wget -O- -q http://s3tools.org/repo/deb-all/stable/s3tools.key | sudo apt-key add -
sudo wget -O/etc/apt/sources.list.d/s3tools.list http://s3tools.org/repo/deb-all/stable/s3tools.list
sudo apt-get update && sudo apt-get install s3cmd
# Configuration
s3cmd --configure
@arthuralvim
arthuralvim / md5deep.sh
Created October 22, 2016 21:28 — forked from deltheil/md5deep.sh
Files and directory comparison with md5deep matching mode (see http://md5deep.sourceforge.net/start-md5deep.html#match).
# Create a reference folder with some data
mkdir foo
echo "hey" > foo/A.txt
echo "scm" > foo/B.txt
echo "git" > foo/C.txt
# Generate the list of hashes for each file
# -b = bare mode (strips any leading directory
# information from displayed filenames)
md5deep -b foo/* > hashes.txt
# Inside the directory that needs to be hashed
# recursive, show estimated time, relative paths
md5deep -rle -W /path/to/result.md5 *
# List files with the same hash, printing the hash-path of each file (remember to keep at least one of them)
sort result.md5 | uniq -D -w 32
# Count the number of duplicate files, path to first encountered file with that hash is shown only | sort by frequency
sort result.md5 | uniq -cd -w 32 | sort -nr
@arthuralvim
arthuralvim / 00-detect-virtualenv-sitepackages.py
Created January 13, 2017 18:49 — forked from henriquebastos/00-detect-virtualenv-sitepackages.py
IPython startup script to detect and inject VIRTUAL_ENV's site-packages dirs.
"""IPython startup script to detect and inject VIRTUAL_ENV's site-packages dirs.
IPython can detect virtualenv's path and injects it's site-packages dirs into sys.path.
But it can go wrong if IPython's python version differs from VIRTUAL_ENV's.
This module fixes it looking for the actual directories. We use only old stdlib
resources so it can work with as many Python versions as possible.
References:
http://stackoverflow.com/a/30650831/443564
@arthuralvim
arthuralvim / instafeedjsaccess.md
Created January 18, 2017 15:49 — forked from mojaray2k/instafeedjsaccess.md
Getting Instagram Access Token for http://intafeedjs.com

#Use this URL to get your client authorized for Instafeed.JS plugin for Instagram.

  1. First login into your Instargam account
  2. Then go to https://www.instagram.com/developer/
  3. At the top click on the Button that says "Manage Clients".
  4. If you have not Register a new client.
  5. Fill out everything and where it says redirect url put this url: http://instafeedjs.com
  6. Then on the security tab make sure you uncheck "Disable implicit OAuth"
  7. Finally use this link to authoruize Instafeed. Where it says "[Client ID]" replace that including the brackets with your clientID from instagram:
  8. https://instagram.com/oauth/authorize/?client_id=[Client ID]&redirect_uri=http://instafeedjs.com&response_type=token
@arthuralvim
arthuralvim / slackpost
Created February 7, 2017 14:04 — forked from dopiaza/slackpost
Post a message to a Slack channel
#!/bin/bash
# Usage: slackpost <token> <channel> <message>
# Enter the name of your slack host here - the thing that appears in your URL:
# https://slackhost.slack.com/
slackhost=PUT_YOUR_HOST_HERE
token=$1
@arthuralvim
arthuralvim / mongodb-s3-backup.sh
Created June 9, 2017 11:40 — forked from eladnava/mongodb-s3-backup.sh
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
@arthuralvim
arthuralvim / awscli.md
Last active October 30, 2018 19:03 — forked from victorfsf/awscli.md
Downloading and uploading from/to a S3 Bucket using AWS CLI

Installing & Configuring

$ sudo pip install awscli (or: sudo apt-get install awscli)
$ aws configure

You'll need to fill the following settings:

@arthuralvim
arthuralvim / jekyll-and-liquid.md
Created August 29, 2017 20:53 — forked from magicznyleszek/jekyll-and-liquid.md
Jekyll & Liquid Cheatsheet

Jekyll & Liquid Cheatsheet

A list of the most common functionalities in Jekyll (Liquid). You can use Jekyll with GitHub Pages, just make sure you are using the proper version.

Running

Running a local server for testing purposes: