Skip to content

Instantly share code, notes, and snippets.

The parameter weekday is True if it is a weekday, and the parameter vacation is True if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return True if we sleep in.
sleep_in(False, False) → True
sleep_in(True, False) → False
sleep_in(False, True) → True
@mmhan
mmhan / original
Last active January 4, 2016 08:29
The Tortoise and the Hare
There is a Hare and
a tortoise.
The hare and tortoise race.
The hare thinks that he is fast
and the tortoise is slow.
He decided to take a nap.
But he slept for too long and the tortoise passes him.
And the tortoise won the race.
@mmhan
mmhan / gist:8131701
Created December 26, 2013 09:34
MM Phone Number Regex
/^((\+\d+)*(\d+)[- ])*\d{3,}[- ]*\d{3,}$/
root (hd0, 5)
kernel /vmlinuz root=/dev/sda6
initrd /initrd.img
boot
@mmhan
mmhan / api.php
Last active December 25, 2015 01:09
Parameters and terms
<?php
/**
* Will take given parameters, query and return a list of listings for given params
*
* PARAMETERS
* ===================
*
* q Search string. Default = null (optional)
* build Car's build type Default = null (optional)
* make Manufacturer Default = null (optional)
<?php
/**
* MMJDB Google docs form embedding
**/
function mmjdb_some_form(){
if(is_page('page_slug')){
echo '<iframe src="https://docs.google.com/spreadsheet/embeddedform?formkey=dE1GWmZYTDNpSG5CSkVRZWgtc0JyWHc6MQ" width="906" height="790" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe>';
}
}
@mmhan
mmhan / gist:5127558
Last active December 14, 2015 18:09
<?php
// Let's say $result is the data that you want to show with pagination.
//First get all the NRs of the result
$nr = Set::extract("{n}.AF.NR", $data);
//Then get the names of all the companies for the given NR
$companies = $this->FIRMA->find('list', array('conditions' => array("NR" => $nr) ) );
?>
@mmhan
mmhan / MCAPI.php
Created December 26, 2012 07:50 — forked from anonymous/MCAPI.php
<?php
class MCAPI {
var $version = "1.3";
var $errorMessage;
var $errorCode;
/**
* Cache the information on the API location on the server
*/
The following was taken from Firebug's Net panel's POST tab.
This is how flash posted the data for entries/customize
--kysqyjqwoxedwqdyyutnftnihuuproui
Content-Disposition: form-data; name="title"
title
--kysqyjqwoxedwqdyyutnftnihuuproui
@mmhan
mmhan / UserAccessLogTest.java
Created June 8, 2012 11:08 — forked from anonymous/UserAccessLogTest.java
Reading the input from logfile. Printing the unique login ID from the past 10 mins.
import java.util.*;
import java.io.*;
import java.util.StringTokenizer;
public class UserAccessLogTest extends GenericTest
{
private String filePath ="";
public UserAccessLogTest(String args[])
{