Skip to content

Instantly share code, notes, and snippets.

@ymero
ymero / snakecoin-server-full-code.py
Created May 2, 2018 03:11 — forked from aunyks/snakecoin-server-full-code.py
The code in this gist isn't as succinct as I'd like it to be. Please bare with me and ask plenty of questions that you may have about it.
from flask import Flask
from flask import request
import json
import requests
import hashlib as hasher
import datetime as date
node = Flask(__name__)
# Define what a Snakecoin block is
class Block:
@ymero
ymero / gencert.py
Created June 13, 2017 08:37 — forked from toolness/gencert.py
Python script to create server SSL certs and sign them with a custom CA.
#! /usr/bin/python
"""
This simple script makes it easy to create server certificates
that are signed by your own Certificate Authority.
Mostly, this script just automates the workflow explained
in http://www.tc.umn.edu/~brams006/selfsign.html.
Before using this script, you'll need to create a private
@ymero
ymero / mysql_secure.sh
Created April 1, 2017 07:29 — forked from Mins/mysql_secure.sh
Automating mysql_secure_installation
#!/bin/bash
aptitude -y install expect
// Not required in actual script
MYSQL_ROOT_PASSWORD=abcd1234
SECURE_MYSQL=$(expect -c "
set timeout 10
@ymero
ymero / bash_colours
Created March 23, 2017 09:35 — forked from ian128K/bash_colours
Shell script colours
## Colours and font styles
## Syntax: echo -e "${FOREGROUND_COLOUR}${BACKGROUND_COLOUR}${STYLE}Hello world!${RESET_ALL}"
# Escape sequence and resets
ESC_SEQ="\x1b["
RESET_ALL="${ESC_SEQ}0m"
RESET_BOLD="${ESC_SEQ}21m"
RESET_UL="${ESC_SEQ}24m"
# Foreground colours
@ymero
ymero / example.com
Created December 16, 2016 03:40 — forked from mignev/example.com
Django deployment with Nginx and Tornado Web
upstream tornadoFrontends {
server 127.0.0.1:8000;
server 127.0.0.1:8001;
server 127.0.0.1:8002;
server 127.0.0.1:8003;
}
server {
listen 80;
@ymero
ymero / tree.md
Created November 24, 2016 11:21 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

# coding=utf-8
from mapreduce import SimpleMapReduce
from simple import FILES, file_parser
def count_err_log(item):
word, occurances = item
return (word, sum(occurances))
@ymero
ymero / create_tables.sql
Created July 21, 2016 03:28 — forked from hoverruan/create_tables.sql
MySQL性能测试
use test;
create table rs_myisam (
follower_id bigint(20) not null,
target_id bigint(20) not null,
created_at datetime not null,
primary key(follower_id,target_id)
) engine=MyISAM default charset=utf8;
create table rs_innodb (
""" An example of a Linux daemon written in Python.
Based on http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
The changes are:
1 - Uses file open context managers instead of calls to file().
2 - Forces stdin to /dev/null. stdout and stderr go to log files.
3 - Uses print instead of sys.stdout.write prior to pointing stdout to the log file.
4 - Omits try/excepts if they only wrap one error message w/ another.
@ymero
ymero / pdaemon-sample.py
Created May 25, 2016 06:38 — forked from thatsdone/pdaemon-sample.py
A python-daemon 'runner.DaemonRunner' class extension (v0.1) and a sample.
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#!/usr/bin/python
import sys
import time
import logging
from daemon import runner
#
# An example daemon main logic application class.
# Just keep writing timestamps to a log file periodically.
#