Skip to content

Instantly share code, notes, and snippets.

@ntd
ntd / _config.php
Last active August 29, 2015 14:24
SilverStripe hangman
<?php
// Code submitted by Nicola Fontana <[email protected]>
Director::addRules(100, array('hangman/$Tiles' => 'Hangman'));
class Hangman extends Controller {
public function index(SS_HTTPRequest $request) {
if(!($this->Tiles = $request->param('Tiles'))) {
$reflection = new ReflectionClass(array_rand(ClassInfo::allClasses()));
Session::set('Word', $reflection->name); // Just to have the class name in CamelCase
}
$this->Word = Session::get('Word');
@ntd
ntd / libserialport example.c
Last active October 16, 2019 15:13 — forked from Nixes/libserialport example.c
libserialport example
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <unistd.h> // for sleep function
#include <libserialport.h> // cross platform serial port lib
//#include "protocol.h"
const char* desired_port = "COM8";
@ntd
ntd / private-static-framework.txt
Created February 2, 2019 21:03
grep -or 'private static $\w*' | awk -F'[.:]' '{ if ($1!=g) { print $1; g=$1 } print "\t" substr($3,17) }' inside silverstripe/framework
Core/Injector/InjectorLoader
instance
Core/Injector/Injector
instance
Core/Config/ConfigLoader
instance
Core/ClassInfo
_cache_all_tables
_cache_ancestry
_cache_parse
@ntd
ntd / silverstripe4-deployer.php
Last active September 14, 2021 06:14
Deployer strategy for SilverStripe 4 (with public enabled)
<?php
/**
* This is the shared deployer code I use in my projects. I put it
* somewhere in the filesystem and then, in each SilverStripe project,
* I add `deploy.php`:
* ```
* <?php
* require '/path/to/my/deployer-silverstripe4.php';
* Deployer\set('application', 'my_application_name');