Skip to content

Instantly share code, notes, and snippets.

View spapas's full-sized avatar

Serafeim Papastefanos spapas

View GitHub Profile
@spapas
spapas / gist:6305393
Created August 22, 2013 10:02
Sample django models
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()
@spapas
spapas / get_attachments.py
Created December 22, 2014 18:37
Extract attachments from text mail messages
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 / Hasher.java
Created March 17, 2016 21:46 — forked from lukaszb/Hasher.java
Java implementation of Django PasswordHasher
/* 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;
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 / i3-config
Last active May 12, 2020 10:43
My i3 config put it to .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>
@spapas
spapas / termite
Created May 12, 2020 10:43
My termite config put it to .config/termite/config
[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
<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 / n2w.py
Created December 14, 2020 07:52
Greek numbers to words in python
import unittest
num2words = {
1: "ένα",
2: "δύο",
3: "τρία",
4: "τέσσερα",
5: "πέντε",
6: "έξι",
7: "επτά",
from Measurements import find
sums_list =[]
with open('input', 'r') as f:
l=[int(i) for i in f.readlines()]
for idx in range(2, len(l)):
sums_list.append(l[idx] + l[idx-1] + l[idx-2])
print(find(sums_list))
# Docker-notes
# Test docker installation
docker ps
# and run a test container
docker run hello-world
# and stop it with