Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexander Deider vpArth

View GitHub Profile
@vpArth
vpArth / TicTacToe.php
Created Aug 24, 2018
TicTacToe implementation (variable map size, win condition, players set)
View TicTacToe.php
<?php
class TicTacToeGame
{
/** @var int */
private $width;
/** @var int */
private $height;
/** @var int */
private $winCond;
@vpArth
vpArth / AjaxAuthenticationListener.php
Created Nov 30, 2016 — forked from xanf/AjaxAuthenticationListener.php
AJAX auth errors listener for Symfony2
View AjaxAuthenticationListener.php
<?php
namespace Application\ProdrepHelperBundle\Component\Event;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
/**
*/
class AjaxAuthenticationListener
@vpArth
vpArth / php5mod.py
Last active Jul 14, 2016
Ansible modules
View php5mod.py
#!/usr/bin/python
import os.path
import re
from subprocess import call
DOCUMENTATION = '''
module: php5mod
short_description: Wraps php5enmod/php5dismod functionality
description:
@vpArth
vpArth / _service.md
Created Dec 7, 2015 — forked from naholyr/_service.md
Sample /etc/init.d script
View _service.md

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
View piano.js
// http://www.multiplayerpiano.com/
var TEMP = 210; // bpm
function tap(note, part, next) {
MPP.piano.play(note, 1, MPP.client.getOwnParticipant(), 0);
setTimeout(function(){
MPP.piano.stop(note, MPP.client.getOwnParticipant(), 0);
next();
}, 60e3/(TEMP*part)*4);
@vpArth
vpArth / Symfony2 + FOSRestBundle.md
Created Sep 15, 2015 — forked from tjamps/README.md
Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle
View Symfony2 + FOSRestBundle.md

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 :

View SigManager.cpp
#include <map>
#include <iostream>
#include <signal.h>
#include <unistd.h>
class Strategy
{
public:
virtual void use(void) = 0;
};
View commenting.vimrc
" Toggle comment line
" Ctrl+/
let s:comment_map = {
\ "c": '//',
\ "cpp": '//',
\ "go": '//',
\ "java": '//',
\ "javascript": '//',
\ "php": '//',
@vpArth
vpArth / 0_reuse_code.js
Created Jun 20, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
You can’t perform that action at this time.