Skip to content

Instantly share code, notes, and snippets.

@rrezzik
rrezzik / html_email_2.py
Created August 16, 2012 18:31
Encoding message text with correct MIME types.
# Create the body of the message (a plain-text and an HTML version).
alt_text = "This report requires a mail reader which supports HTML"
# Record the MIME types of both parts - text/plain and text/html.
text_part = MIMEText(text, 'plain')
html_part = MIMEText("".join(html_message), 'html') # Join the list containing the HTML read on STDIN
@rrezzik
rrezzik / html_email_1.py
Created August 16, 2012 18:26
MIMEMultipart
#! /usr/bin/python
import smtplib
import sys
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# Grab the message on stdin
@rrezzik
rrezzik / gist:3248953
Created August 3, 2012 16:00 — forked from swannodette/gist:3217582
sudoku_compact.clj
;; based on core.logic 0.8-alpha1
(ns sudoku
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn get-square [rows x y]
(for [x (range x (+ x 3))
y (range y (+ y 3))]
(get-in rows [x y])))
@rrezzik
rrezzik / json_encode.php
Created May 18, 2012 14:26
Using json_encode to go from PHP array to JSON
<?php
// Your PHP array
$my_array = array('array' => array('a', 'b', 'c'));
// Use json_encode to produce JSON
$json_string = json_encode($my_array);
// And let's see it!
echo $json_string . "\n";
@rrezzik
rrezzik / json_decode.php
Created May 17, 2012 16:31
Using json_decode to go from JSON to PHP array
<?php
// The response from an API call..
$json_string = '{"array" : ["a", "b", "c"]}';
// Use json_decode to get a JSON object as a PHP associative array
$json_obj = json_decode($json_string, true);
// Iterate through it for fun
foreach ($json_obj['array'] as $value) {
@rrezzik
rrezzik / print.asm
Created January 24, 2012 14:59
Print a byte out in Linux
SUMPROG.ASM;
%include "io.mac"
.DATA
abyte db 'A'
.UDATA
@rrezzik
rrezzik / dup.clj
Created August 26, 2011 15:49
Remove duplicates
(distinct (concat (range 3 1000 3) (range 5 1000 5)))
@rrezzik
rrezzik / mult_3_5.clj
Created August 26, 2011 15:44
Multiples of 3 and 5 under 1000
; multiples of 3 under 1000
(range 3 1000 3)
; multiples of 5 under 1000
(range 5 1000 5)
@rrezzik
rrezzik / client.pl
Created July 17, 2011 17:38
Our client
#!/usr/bin/env perl
use warnings;
use strict;
use IO::Socket;
my ($event_id, $dataroot) = @ARGV;
my $directory = "$dataroot$event_id/";
my $remote_host = "localhost";