Skip to content

Instantly share code, notes, and snippets.

@rmasters
rmasters / gist:1585395
Created January 9, 2012 22:44
Started re-writing the UPSU:Radio site in LOLCODE
HAI
BTW The UPSU:Radio website, rewritten in LOLCODE
CAN HAS STDIO?
GIMMEH REQUEST
VISIBLE "UPSU:RADIO"
I HAS A COUNTER BTW Incrementer for the nav loop
@rmasters
rmasters / gist:1637232
Created January 19, 2012 02:18
Templating example
Two directories:
/public -> For publically accessible files
/templates -> For templated code, not publically accessible
Make pages in /public which have database/$_GET/etc. code in them (business logic/controller logic). At the end of them do:
$contentPath = __DIR__ . "/../templates/index.php";
require __DIR__ . "/../templates/layout.php";
<?php
function get_posts() {
$db = new PDO("mysql:host=localhost;dbname=threads", "user", "password");
$pStmt = $db->query("SELECT * FROM post");
$posts = $pStmt->fetchAll(PDO::FETCH_ASSOC);
$pStmt->closeCursor();
// Convert flat posts array to threaded dictionary
$app->add('home', '/', function() { return 'Homepage' });
$app->add(new NamedRoute('home', '/'), function() { return 'Homepage' });

The code:

String targetStr = in.readString();
if (targetStr != "null") {
    Log.d("ASDF", "\"" + targetStr + "\"");
    target = fmt.parseDateTime(targetStr);
}

Log:

<!doctype html>
<html>
<head>
<title>sucam</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
html, body { height: 100%; }
@rmasters
rmasters / gist:3925486
Created October 21, 2012 02:18
Finding occurrences of repeated events within a given datetime range
"""
Find all events from an iCalendar file, with some support for recurrent events
Implemented:
- Normal events (with DTSTART and DTEND)
- Daily, weekly, monthly, yearly, hourly and minutely frequencies (FREQ)
- Intervals in frequencies (INTERVAL)
- Until date (UNTIL)
- Maximum occurrences (COUNT)
- Excluded dates (EXDATE)
@rmasters
rmasters / luatut.lua
Created December 16, 2012 14:22
A demo of how to write Lua code for non-programmers
-- Ross's Lua-howto without knowing any Lua :)
-- To run this file:
-- Install lua
-- Copy this file (click the "download" link) to the Desktop
-- Open a command prompt
-- Type "cd Desktop" without quotes
-- Type "lua luatut.lua" and follow through this code.
@rmasters
rmasters / Cheerlights.ino
Last active December 30, 2015 11:18
Code for Cheerlights Arduino hack
#include <SPI.h>
#include <WiFi.h>
#include <b64.h>
#include <HttpClient.h>
#include <Adafruit_WS2801.h>
#define PIXELS 25
#define DATA_PIN 2
#define CLOCK_PIN 3
/*
-----------------------------------------------------------------------------
"THE BEER-WARE LICENSE" (Revision 42):
<[email protected]> wrote this file. As long as you retain this notice you
can do whatever you want with this stuff. If we meet some day, and you think
this stuff is worth it, you can buy me a beer in return. -Michaël Sokol
-----------------------------------------------------------------------------
*/