Skip to content

Instantly share code, notes, and snippets.

@sweikenb
sweikenb / install_ramcache.sh
Last active December 22, 2015 22:19
Speedup your symfony2 vagrant box by mounting the app/cache folder into the ram of the vm (run this script as root!)
#!/bin/sh
# create mount point
if [ ! -d /ram ]
then
mkdir /ram
fi
# create ramfs
mount -t ramfs -o size=512M ramfs /ram/
@sweikenb
sweikenb / iban_check.php
Created April 8, 2014 06:26
iban validator function
<?php
$iban = "DE89 3704 0044 0532 0130 00";
function getValidIban($iban)
{
// normalize
$iban = str_replace(array(' ', '-', '.', ','), '', strtoupper($iban));
// define the pattern
@sweikenb
sweikenb / GitlabSyncCommand
Last active August 29, 2015 14:01
GitlabSyncCommand for custom packagist installations
<?php
namespace Packagist\WebBundle\Command;
use Gitlab\Api\Projects;
use Gitlab\Api\Repositories;
use Packagist\WebBundle\Entity\Package;
use Packagist\WebBundle\Entity\User;
use sweikenb\Library\Threading\Thread;
use sweikenb\Library\Threading\ThreadRegistry;
@sweikenb
sweikenb / deploy.sh
Last active April 18, 2016 08:47
Dimple GIT deployment for symfony apps
#!/bin/bash
#
# Example and very basic deplosy script
#
# change to the right directory
cd /path-to-project-root;
# Remove unsecure files
@sweikenb
sweikenb / README.md
Created August 9, 2016 18:35 — forked from tjamps/README.md
Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

The API we are creating in this gist will follow these rules :

  • The API only returns JSON responses
  • All API routes require authentication
  • Authentication is handled via OAuth2 with password Grant Type only (no need for Authorization pages and such).
  • API versioning is managed via a subdomain (e.g. v1.api.example.com)

The API will be written in PHP with the Symfony 2 framework. The following SF2 bundles are used :

/**
* Creates the container instance
*
* @param {Object|null} params
* @constructor
*/
var Dicon = function (params) {
this.params = {};
this.services = {};
this.container = {};
/**
* EventDispatcherEvent
*
* @param eventName
* @param payload
* @constructor
*/
var EventDispatcherEvent = function (eventName, payload) {
this._stoppped = false;
this._name = eventName;
/**
* strap.js by Simon Schroeer | http://strapjs.org | License: MIT
*/
var strapjs_root = {},
strapjs_eventstack = {},
strapjs = {};
/**
* Get the global root object
@sweikenb
sweikenb / Dockerfile
Created January 30, 2019 15:01
Simple LAMP Docker Setup
FROM php:7.2.1-apache
RUN docker-php-ext-install pdo pdo_mysql mysqli
@sweikenb
sweikenb / array_practice.php
Created February 5, 2019 14:42
PHP array practice (recursion)
<?php
/*
* Conditions:
***********************************************************************************************************************
*
* Do not modify or edit this file/array -> include it into your working file and use the $tree array as it is.
*
*
* Tasks: