Skip to content

Instantly share code, notes, and snippets.

Avatar

Serafeim Papastefanos spapas

View GitHub Profile
@spapas
spapas / n2w.py
Created Dec 14, 2020
Greek numbers to words in python
View n2w.py
import unittest
num2words = {
1: "ένα",
2: "δύο",
3: "τρία",
4: "τέσσερα",
5: "πέντε",
6: "έξι",
7: "επτά",
View cropper.html
<html>
<head>
<link href="https://cdn.paperindex.com/bootstrap/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/cropper/2.3.4/cropper.min.css">
<style>
@spapas
spapas / termite
Created May 12, 2020
My termite config put it to .config/termite/config
View termite
[options]
#allow_bold = true
#audible_bell = false
#bold_is_bright = true
#cell_height_scale = 1.0
#cell_width_scale = 1.0
#clickable_url = true
#dynamic_title = true
font = SourceCode Pro 12
#fullscreen = true
@spapas
spapas / i3-config
Last active May 12, 2020
My i3 config put it to .i3/config
View i3-config
# i3 config file (v4)
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
# Set mod key (Mod1=<Alt>, Mod4=<Super>)
set $mod Mod4
# set default desktop layout (default is tiling)
# workspace_layout tabbed <stacking|tabbed>
# Configure border style <normal|1pixel|pixel xx|none|pixel>
View non_transitive_dice_test.py
import random
die_a = [ 2, 2, 4, 4, 9, 9]
die_b = [ 1, 1, 6, 6, 8, 8]
die_c = [ 3, 3, 5, 5, 7, 7]
times = 100000
def compare_dice(d1, d2, times):
d1_wins = 0
@spapas
spapas / Hasher.java
Created Mar 17, 2016 — forked from lukaszb/Hasher.java
Java implementation of Django PasswordHasher
View Hasher.java
/* Example implementation of password hasher similar on Django's PasswordHasher
* Requires Java8 (but should be easy to port to older JREs)
* Currently it would work only for pbkdf2_sha256 algorithm
*
* Django code: https://github.com/django/django/blob/1.6.5/django/contrib/auth/hashers.py#L221
*/
import java.nio.charset.Charset;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
@spapas
spapas / get_attachments.py
Created Dec 22, 2014
Extract attachments from text mail messages
View get_attachments.py
import email
import sys
if __name__=='__main__':
if len(sys.argv)<2:
print "Please enter a file to extract attachments from"
sys.exit(1)
msg = email.message_from_file(open(sys.argv[1]))
for pl in msg.get_payload():
@spapas
spapas / gist:6305393
Created Aug 22, 2013
Sample django models
View gist:6305393
class Category(models.Model):
name = models.CharField()
class Attribute(models.Model):
category = models.ForeignKey(Category)
name = models.CharField
class Item(models.Model):
slug = models.SlugField()
price = models.DecimalField()