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 / 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 / Git Bash.vbs
Created May 19, 2017 18:34 — forked from ThatRendle/Git Bash.vbs
Modified Git Bash to use Console2
Set AppObj = CreateObject("Shell.Application")
If WScript.Arguments.Length=1 Then
AppObj.ShellExecute "C:\Console2\Console.exe", " -t ""Git Bash"" -d """ & WScript.Arguments(0) & """"
Else
AppObj.ShellExecute "C:\Console2\Console.exe", " -t ""Git Bash"""
End If