Skip to content

Instantly share code, notes, and snippets.

using System.Net.Mail;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public class TestClass {
public static void Main() {
string subject = "";
string body = "";
string host = "smtp.hubapi.com";
@axiak
axiak / html2pdf.py
Created December 22, 2010 17:49
convert a url to pdf
import tempfile
import os
from subprocess import Popen, PIPE
# Prereqs:
# apt-get install html2ps ghostscript
def convert_to_pdf(html):
" Convert some html to a pdf. "
ps_process = Popen("html2ps", stdin=PIPE, stdout=PIPE, shell=True)
@axiak
axiak / gist:889352
Created March 27, 2011 16:33
Splash scheduling

The way I envision any scheduling system to work is by (1) a brute force program generating a feasible but poor schedule subject to hard constraints and (2) some probabilistic algorithm(s) optimizing said poor schedule given a number of things to weigh in.

I’ve already written a quick brute force program 1. The result is the attached file. Please look at the attached file, and consider why the schedule is so poor. In order for the schedule to get better, we need to figure out what makes a schedule good and what data we will need in order to measure that. Some of this is tricky since it’s so intuitive.

I’ve written below a list of what I think are some pieces missing. Any text in square brackets ([….]) are data that I’ve identified we will likely need/use in order to implement the constraint.

FEASIBILITY PROBLEMS (aka hard constraints)

- For Splash, some timeslots only work with certain grade ranges. Timeslots don’t know this. I’m not sure how we should encode this type of constraint, but we would need

@axiak
axiak / gist:889351
Created March 27, 2011 16:32
Splash scheduling
The way I envision any scheduling system to work is by (1) a brute force program generating a feasible but poor schedule subject to hard constraints and (2) some probabilistic algorithm(s) optimizing said poor schedule given a number of things to weigh in.
I've already written a quick brute force program [1]. The result is the attached file. Please look at the attached file, and consider why the schedule is so poor. In order for the schedule to get better, we need to figure out what makes a schedule good and what data we will need in order to measure that. Some of this is tricky since it's so intuitive.
I've written below a list of what I think are some pieces missing. Any text in square brackets ([....]) are data that I've identified we will likely need/use in order to implement the constraint.
FEASIBILITY PROGLEMS (aka hard constraints)
- For Splash, some timeslots only work with certain grade ranges. Timeslots don't know this. I'm not sure how we should encode this type of constraint, but we would need
sealed abstract class Token[T <: Ordered[T]](location: T) extends Ordered[Token[T]] {
override def compare(other: Token[T]): Int = {
location compare other.location()
}
def location(): T = location
}
case class Start[T <: Ordered[T]](loc: T) extends Token[T](loc)
case class End[T <: Ordered[T]](loc: T) extends Token[T](loc)
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
</web-app>
/*
* jQuery placeholder Plugin
* version: 0.1
* @requires: jQuery v1.4.1 or later, Modernizr, and jquery livequery plugin
*
* http://docs.jquery.com/Plugins/livequery
*
* To use: When you write your input tags, include a title and placeholder attribute as
* well as a placeholder class. Also include styling for the hasPlaceholder class.
*
@axiak
axiak / gist:949670
Created April 30, 2011 13:33
jquery.placeholder.js
/*
* jQuery placeholder Plugin
* version: 0.1
* @requires: jQuery v1.4.1 or later, Modernizr, and jquery livequery plugin
*
* http://docs.jquery.com/Plugins/livequery
*
* To use: When you write your input tags, include a title and placeholder attribute as
* well as a placeholder class. Also include styling for the hasPlaceholder class.
*
@axiak
axiak / gist:963879
Created May 10, 2011 03:58
Dumper.java
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
public class Dumper {
private static final Class[] printtableClasses = new Class[]{
String.class, Integer.class, Float.class, Double.class,
BigDecimal.class, Character.class, Byte.class,
class MyJobRunner extends Job<List<Something>> {
// ...
public List<Something> doJobWithResult() throws Exception {
// some preparation logic
List<List<Something>> = await(F.Promise.waitAll(firstJob.now(), secondJob.now(), ...));
// some merging logic...
return ...;
}