Skip to content

Instantly share code, notes, and snippets.

@makersm
makersm / main.py
Created May 26, 2016 15:12
email notifier using multiprocessing(manager process, worker process[pool])
import os
import random
from multiprocessing import Queue, Process, Pool
from time import sleep
class EmailNotifier:
def __init__(self):
self.r_queue = Queue()
self.manager_proc = Process(target=EmailNotifier.init_manager_proc, name='EmailNotifier', args=(self.r_queue,))
@makersm
makersm / email_sender.py
Created May 27, 2016 17:59
send email using python
import smtplib
from email.mime.text import MIMEText
sender = 'sender@example.com' #my domain
recipient = 'recipient@example.com'
mail = MIMEText('message goes here')
mail['Subject'] = 'title goes here'
mailserver = smtplib.SMTP('localhost')
@makersm
makersm / mail_send_with_image.py
Created May 28, 2016 10:53
mail send with image
from smtplib
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
mail = MIMEMultipart()
mail['Subject'] = 'this is title'
fp = open(file, 'rb') # only image works
mail.attach(MIMEImage(fp.read()))
@makersm
makersm / mail_send_with_files.py
Created May 30, 2016 05:36
mail send with files
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.application import MIMEApplication
mail = MIMEMultipart()
mail['Subject'] = title
mail.preamble = 'This is a multi-part message in MIME format'
mail.attach(MIMEImage(message))
@makersm
makersm / ImageConverter.py
Last active August 13, 2016 09:03
convert image to ascii text.
import functools
import os
import re
import asyncio
from PIL import Image
def pixel_converter(bright):
if bright == 255:
val = ' '
import socket
import subprocess
server_address = '/superpython'
if __name__ == '__main__':
# create socket
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
# Bind the socket to the port
@makersm
makersm / gist:1e40c4906adb0deb6a9cfd920cba05e5
Created December 22, 2017 11:31 — forked from chad3814/gist:2924672
deleting array items in javascript with forEach() and splice()
// This is from my comment here: http://wolfram.kriesing.de/blog/index.php/2008/javascript-remove-element-from-array/comment-page-2#comment-466561
/*
* How to delete items from an Array in JavaScript, an exhaustive guide
*/
// DON'T use the delete operator, it leaves a hole in the array:
var arr = [4, 5, 6];
delete arr[1]; // arr now: [4, undefined, 6]
@makersm
makersm / login.sh
Created December 26, 2017 09:32
login script
#!/bin/bash
ID="loginID"
PWD="Password"
URL="https://testurl.com"
COOKIE_FILE="cookies.txt"
LOG_FILE="login_log.html"
`(curl ${URL} \
--data-urlencode "id=${ID}" \
--data-urlencode "pwd=${PWD}" \
@makersm
makersm / quick.cpp
Last active January 11, 2018 07:14
quick sort
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdlib.h>
#include <time.h>
#include <map>
#define MAX 20
using namespace std;
@makersm
makersm / 234tree.psuedo
Last active January 13, 2018 23:28
234tree
class TtFTree {
constructor() {
this._children = []
this._key = []
}
insert(node, prenode, key) {
if(_key.length == 3) {
_middleUp(node, prenode)
}