Skip to content

Instantly share code, notes, and snippets.

@maurostorch
maurostorch / prime.py
Created June 6, 2013 22:43
My Windows Azure workload in Python! http://maurostorch.cloudapp.net/prime
import sys
from time import gmtime, strftime
from math import sqrt
def isprimo(p):
i=long(sqrt(p))
while True:
if p%i==0: return False
if i<=2: break
i = i - 1
@maurostorch
maurostorch / tomp3.sh
Last active May 27, 2016 18:25
Convert a set of wav file from a directory to MP3 with avconv
#/bin/bash
for i in *.wav; do avconv -i "$i" -c libmp3lame -ac 2 -b:a 192k "`echo $i|sed 's\wav\mp3\g'`" ; done
#!/bin/bash
# HotSpot creating script using hostapd, dnsmasq and iptables
# Following instructions from: http://code.google.com/p/quickanddirty/wiki/CreatingWirelessHotspotWithLinux
LAN=wlan2
WAN=eth2
startap(){
# Start
# Enable routing
@maurostorch
maurostorch / rsa.py
Last active December 22, 2015 22:59
RSA python code for data encryption.
import random
from os import urandom
from fractions import gcd
from gmpy2 import invert
from gmpy2 import mul
from gmpy2 import powmod
import sys
'''
Authors: Endrigo, Mauro
@maurostorch
maurostorch / s3client.py
Created October 25, 2013 13:21
upload files to S3-Amazon object storage system
import sys
from boto.s3.connection import S3Connection
from boto.s3.key import Key
conn = S3Connection('s3_access_key','s3_access_pwd')
#conn.create_bucket('first_20131025')
b = conn.get_bucket('first_20131025')
k = Key(b)
@maurostorch
maurostorch / server.py
Created January 31, 2014 19:33
Simple and light HTTP server in Python
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from httplib import HTTPResponse
from os import curdir,sep
#Create a index.html aside the code
#Run: python server.py
#After run, try http://localhost:8080/
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
@maurostorch
maurostorch / hashpass.html
Created April 28, 2016 18:35
hash you password e copy to clipboard
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript">
/**
Copyright (C) 2015 Tomáš Havlas <tomashavlas@raven-systems.eu>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
@maurostorch
maurostorch / progressbar.sh
Last active February 16, 2024 10:59
progressbar in bash for anything
#!/bin/bash
# could be placed in a single line
A=$1; # change to something with a number, first script's arg
B=$((A*40/$2)); # calculates the portion in a progress bar of 40 # where $2 is the total as 2nd script's arg
C=$((40-B)); # left
B=$(printf "%${B}s");
C=$(printf "%${C}s");
printf "\r[${B// /#}${C// /-}] $A%%\n" $A;
@maurostorch
maurostorch / progressbarcss.html
Created May 20, 2016 12:48
very thin top progressbar
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style media="screen">
div {
display: inline-block;
height: 1px;
background-color: rgba(0, 0, 200, 0.5);;