Skip to content

Instantly share code, notes, and snippets.

<?php
class Magical {
public $name = 'The Penguin';
protected $realName = 'Jack Snow';
private $reallyRealName = 'Santa Claus';
public function getAge() {
return 42;
@rmasters
rmasters / gulpfile.js
Created March 5, 2014 15:24
Gulp is neato
'use strict';
var gulp = require('gulp'),
less = require('gulp-less'),
clean = require('gulp-clean'),
coffee = require('gulp-coffee'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat');
var paths = {
/*
-----------------------------------------------------------------------------
"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
-----------------------------------------------------------------------------
*/
@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
@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 / 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)
<!doctype html>
<html>
<head>
<title>sucam</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
html, body { height: 100%; }

The code:

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

Log:

$app->add('home', '/', function() { return 'Homepage' });
$app->add(new NamedRoute('home', '/'), function() { return 'Homepage' });
<?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