Skip to content

Instantly share code, notes, and snippets.

@ssarangi
ssarangi / extract-attachments.py
Created February 6, 2016 20:41 — forked from stefansundin/extract-attachments.py
Extract attachments from emails that Gmail doesn't allow you to download. This is dumb. (Only tested with Python 3.4)
# Get your files that Gmail block. Warning message:
# "Anti-virus warning - 1 attachment contains a virus or blocked file. Downloading this attachment is disabled."
# Based on: http://spapas.github.io/2014/10/23/retrieve-gmail-blocked-attachments/
# Go to your emails, click the arrow button in the top right, "Show original", save to the same directory as this script.
import email
import sys
import os
if __name__ == '__main__':
@ssarangi
ssarangi / regex.py
Last active February 5, 2016 02:26
"""
The MIT License (MIT)
Copyright (c) <2015> <sarangis>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@ssarangi
ssarangi / capture.py
Last active November 26, 2022 09:32
Script for generating screenshots with PySide with area selection option
'''
capture.py
A simple screen capture app using PySide ( or PyQt4 )
#TODO: modifications required to run on Windows
Copyright Marc Robinson 2014
'''
@ssarangi
ssarangi / create_animated_gif.sh
Created January 11, 2016 06:19
Convert screenshots to animated gif
convert -delay 10 -loop 0 screenshot*.png animation.gif
from numba import double, jit
def top_level():
a = 10
a = a * 5
def inner():
nonlocal a
a = a * 5
print(a)
@ssarangi
ssarangi / genetic.py
Created September 4, 2015 21:20
image evolution using genetic algorithm
# draw about 50 polygons with varying transparencies to recreate an image
from PIL import Image, ImageDraw, ImageChops
from random import random, randint
import numpy as np
def clamp(minimum, x, maximum):
return max(minimum, min(x, maximum))
def pil2array(img):
return np.array(img.getdata(),
@ssarangi
ssarangi / llvmlite_fpm.py
Created August 23, 2015 08:26
LLVMLite Function Pass manager example
__author__ = 'sarangis'
from ctypes import CFUNCTYPE, c_int
import sys
import llvmlite.ir as ll
import llvmlite.binding as llvm
llvm.initialize()
llvm.initialize_native_target()
trait MatrixBinOps[T] {
def +(that: Matrix[T])(implicit ev: Vector[Numeric[T]]): Matrix[T]
def -(that: Matrix[T])(implicit ev: Vector[Numeric[T]]): Matrix[T]
def *(that: Matrix[T])(implicit ev: Vector[Numeric[T]]): Matrix[T]
}
trait Matrix[T] {
// def zeros(length: Int)(implicit ev: Numeric[T]): Vector[T]
// def toString(): String
}
#define TC_MALLOC 1
#define ELIBEN 0
#include "hr_timer.h"
#include "allocators.h"
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <thread>