Skip to content

Instantly share code, notes, and snippets.

@xiconet
xiconet / jinja2_file_less.py
Last active August 29, 2015 13:56 — forked from wrunk/jinja2_file_less.py
Python Jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#
@xiconet
xiconet / chpy.py
Created June 21, 2014 04:27
Change the .py file association on Windows
#*******************************************************************************
# chpy.py
# Zac Hester <[email protected]>
# 2012-08-07
#
# Change the Windows file association for .py to a given Python interpretor.
#
# For usage examples, type:
# chpy.py help
#
@xiconet
xiconet / gdsort.sh
Created July 3, 2014 05:22
gdsort: sort the output of gdrive list
#!/bin/sh
# sort the output of gdrive list
# takes a folder_id as argument, returns a sorted list of items in the corresponding folder
# TODO: sort by item title while keeping the id in the output
#
if [ $# = 0 ]; then
echo -e "you must provide a folder_id\nType -h or --help for details"
exit 0
fi
if [ $1 = "-h" ] || [ $1 = "--help" ]
@xiconet
xiconet / box_folders.rb
Last active August 29, 2015 14:08 — forked from cburnette/Iterate Box folders in Ruby
Iterate Box folders in Ruby
require 'ruby-box' #gem install ruby-box
require 'term/ansicolor' #gem install term-ansicolor
include Term::ANSIColor
MODIFIED_AT_CUTOFF = Time.new(2013,7,1)
session = RubyBox::Session.new({
client_id: "YOUR_CLIENT_ID",
client_secret: "YOUR_CLIENT_SECRET",
@xiconet
xiconet / imap_attachments.py
Last active August 29, 2015 14:21 — forked from baali/dlAttachments.py
Download all attachments from a gmail "All Mail" mailbox with python imap
# Something in lines of http://stackoverflow.com/questions/348630/how-can-i-download-all-emails-with-attachments-from-gmail
# Make sure you have IMAP enabled in your gmail settings.
# Right now it won't download same file name twice even if their contents are different.
import email
import getpass, imaplib
import os
import sys
detach_dir = '.'
@xiconet
xiconet / scala
Last active October 19, 2015 11:29 — forked from kirillkh/scala
#!/usr/bin/env bash
#
##############################################################################
# Copyright 2002-2013 LAMP/EPFL
#
# This is free software; see the distribution for copying conditions.
# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
##############################################################################
@xiconet
xiconet / piped_upload.go
Last active October 25, 2015 03:43 — forked from cryptix/client.go
multipart upload with io.Pipe
package main
import (
"io"
"log"
"mime/multipart"
"net/http"
"os"
"path/filepath"
"runtime"
@xiconet
xiconet / web-servers.md
Created January 5, 2017 10:32 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@xiconet
xiconet / chksums.sh
Created January 9, 2017 19:03
Checksum one-liners.
# bourne shell functions below take 1 argument, the file_to_hash.
# prints hex digest on stdout
md5() {
perl -MDigest::MD5=md5_hex -le'print md5_hex(<> or die)' "$1"
# ruby -rdigest/md5 -e"puts Digest::MD5.file'/dev/null'"
# python -sBc "import hashlib;print hashlib.md5(open('$1','rb').read()).hexdigest()"
# md5 "$1"|cut -d' ' -f4 # mac
# md5sum "$1"|cut -d' ' -f1 # linux
# openssl md5 "$1" | grep -o '[[:xdigit:]][[:xdigit:]]*$' | cat
@xiconet
xiconet / utils.py
Last active May 8, 2017 15:44
Collected python utilities
#!/usr/bin/env python
"""Collect utilities here
__VERSION: 0.1
__AUTHOR: xiconet
"""
MAXLEN = 60
START_AT = 2