Skip to content

Instantly share code, notes, and snippets.

@alganet
alganet / fw.php
Created September 17, 2012 02:30
Framework-style Respect\Rest controllers
<?php
class MyUser implements Routable, Routinable, ProxyableWhen
{
public $path = '/users';
//Routinable
public function applyRoutines(AbstractRoute $route)
{
$route->userAgent(array('firefox' => function($data) {
@suissa
suissa / index.html
Created September 12, 2012 04:07
Works better in webkit, buggy in FF, flat in IE. Inspired by http://neography.com/experiment/circles/solarsystem/ and http://nicolasgallagher.com/css-pseudo-element-solar-system/demo/ [update] Added some basic responsive styles, github repo can be found
<body class="opening hide-UI view-2D zoom-large data-close controls-close">
<div id="navbar">
<a id="toggle-data" href="#data"><i class="icon-data"></i>Data</a>
<h1>3D CSS Solar System</h1>
<a id="toggle-controls" href="#controls"><i class="icon-controls"></i>Controls</a>
</div>
<div id="data">
<a class="sun" title="sun" href="#sunspeed">Sun</a>
<a class="mercury" title="mercury" href="#mercuryspeed">Mercury</a>
<a class="venus" title="venus" href="#venusspeed">Venus</a>
@alganet
alganet / rd.php
Created September 5, 2012 01:47
Respect\Database Thoughts
<?php
// Respect\Database is an easy API for any database with dead simple drivers
use Respect\Database\Data;
$data = new Data(array(
'p001' => new PDO(/*...*/),
'tweets' => new Mongo(/*...*/),
'timelines' => new Predis\Client(/*...*/),
@alganet
alganet / href.php
Created August 25, 2012 14:55
Full RESTful/Relational Blog in less than 100 lines [Work In Progress]
<?php
use Respect\Rest\Router;
use Respect\Relational\Mapper;
use Respect\Template\Xml;
use Respect\Template\Html;
$db = new Mapper(new PDO));
$db->postsBase = $db->select('id', 'title', 'text')->posts(
$db->select('name', 'bio')->author)
<?php
//Sample: http://localhost/controller.php?name=Fulano
include 'model.php';
$hw = new HelloWorld;
$name = $_GET['name'];
$greetings = $hw->say($name);
@cherifGsoul
cherifGsoul / RestController.php
Last active November 1, 2018 13:54
Yii simple rest controller exemple
<?php
/**
* Controller is the customized base controller class.
* All controller classes for this application should extend from this base class.
*/
class RestController extends CController
{
/**
* @var string the default layout for the controller view. Defaults to '//layouts/column1',
* meaning using a single column layout. See 'protected/views/layouts/column1.php'.
@19h
19h / TiYoutube.js
Last active November 11, 2015 16:24
Titanium Mobile SDK iPhone / Android: Extract Youtube Video URL / URI from video-id / identification / name and play mp4 file. (Workaround for the recent change of security in Youtube)
Titanium.App.addEventListener("playvideo", function (e) {
var win11 = Titanium.UI.createWindow({
orientationModes: [Ti.UI.LANDSCAPE_LEFT, Ti.UI.LANDSCAPE_RIGHT],
title: "Video",
zIndex: 222222
});
var activeMovie = Titanium.Media.createVideoPlayer({
fullscreen: !0,
autoplay: !0,
@wildlyinaccurate
wildlyinaccurate / AccountControllerTest.php
Created July 9, 2012 22:00
Laravel Controller Test Case
<?php
require_once 'ControllerTestCase.php';
class AccountControllerTest extends ControllerTestCase
{
public function testSignupWithNoDataRedirectsAndHasErrors()
{
$response = $this->post('account@signup', array());
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@raulriera
raulriera / PagingControl.js
Created April 19, 2012 02:13
Custom paging control for scrollableViews for Titanium Appcelerator
// I was unhappy about there was close to no control over the "pageControl"
// in scrollableViews, so I hacked my own
// -----
// Configuration
var pageColor = "#c99ed5";
PagingControl = function(scrollableView){
var container = Titanium.UI.createView({
height: 60