Skip to content

Instantly share code, notes, and snippets.

View linxlad's full-sized avatar

Nathan Daly linxlad

  • Bury St Edmunds, England
View GitHub Profile
@linxlad
linxlad / camelCaseToUnderscore.php
Last active April 25, 2016 12:29
Camel case to underscore
/**
* Return the underscored version of a CamelCase string.
*
* @return string
*/
function camelCaseToUnderscore($camelCaseString)
{
return ltrim(
strtolower(
preg_replace(
@linxlad
linxlad / raspbian-jessie-chromium-install.sh
Created April 22, 2016 20:32
Chromium installer script for Raspbian Jessie.
wget https://dl.dropboxusercontent.com/u/87113035/chromium-browser-l10n_45.0.2454.85-0ubuntu0.15.04.1.1181_all.deb
wget https://dl.dropboxusercontent.com/u/87113035/chromium-browser_45.0.2454.85-0ubuntu0.15.04.1.1181_armhf.deb
wget https://dl.dropboxusercontent.com/u/87113035/chromium-codecs-ffmpeg-extra_45.0.2454.85-0ubuntu0.15.04.1.1181_armhf.deb
sudo dpkg -i chromium-codecs-ffmpeg-extra_45.0.2454.85-0ubuntu0.15.04.1.1181_armhf.deb
sudo dpkg -i chromium-browser-l10n_45.0.2454.85-0ubuntu0.15.04.1.1181_all.deb chromium-browser_45.0.2454.85-0ubuntu0.15.04.1.1181_armhf.deb
@linxlad
linxlad / downloader-form.html
Last active April 15, 2016 13:01
Form part of the JSON API tester.
<html>
<head>
<title>{{ .Title }}</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<style>
.alert.alert-danger {
text-align: center;
}
</style>
@linxlad
linxlad / downloader.go
Last active April 15, 2016 13:01
Downloader part of the JSON API tester.
package main
import (
. "fmt"
"net/http"
"net/url"
"io"
"bytes"
"html/template"
"log"
@linxlad
linxlad / template.go
Created April 13, 2016 15:43
Example of rendering a template in Go.
package main
import (
. "fmt"
"net/http"
"html/template"
"log"
)
type User struct {
@linxlad
linxlad / github-user.go
Created April 10, 2016 23:41
Test Go Http Request
package main
import (
// "bytes"
. "fmt"
"net/http"
// "io/ioutil"
// "net/url"
// "strconv"
"net/url"
@linxlad
linxlad / example.go
Created April 10, 2016 18:54 — forked from yanmhlv/example.go
simple DRY controller. golang github.com/labstack/echo example
package main
import (
"fmt"
"net/http"
"reflect"
"strconv"
"github.com/jinzhu/gorm"
"github.com/labstack/echo"
@linxlad
linxlad / ObjectPrototypes.js
Created March 2, 2016 15:30
Get the size of an object and determine if the object has any true values.
Object.prototype.anyValueTrue = function() {
var key;
for (var key in this) {
if (this.hasOwnProperty(key)) {
if (this[key] === true) {
return true;
}
}
}
return false;
@linxlad
linxlad / docker-compose.yml
Created February 20, 2016 22:48
Phalcon 2 Docker Environment
db:
image: mysql:latest
expose:
- "3306"
ports:
- "3307:3306"
environment:
MYSQL_DATABASE: phalcon-db
MYSQL_USER: root
MYSQL_PASSWORD: root123
@linxlad
linxlad / PrepareFormErrorsForCache.php
Last active February 23, 2016 14:23
Symfony 3 PHP 7 Serialize all form errors before storing to cache and retrieve them again.
<?php
namespace OpenObjects\Bundle\CoreBundle\Util;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormError;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Validator\ConstraintViolation;