Skip to content

Instantly share code, notes, and snippets.

View joangrigorov's full-sized avatar

Yoan-Alexander Grigorov joangrigorov

  • Amsterdam, Netherlands
View GitHub Profile
import Syntax::Abstract::Glagol;
import Prelude;
import Parser::ParseAST;
import Config::Reader;
import Compiler::PHP::Compiler;
import Transform::Glagol2PHP::Namespaces;
println(toCode(toList(range(toPHPScript(<zend(), doctrine()>, parseModule(|cwd:///../Example.g|).\module)))[0]));
@joangrigorov
joangrigorov / social_plugins.php
Last active December 31, 2015 12:00
Dependency Inversion complaint strategy
<?php
/**
* We use this interface to break dependencies between the framework and the domain
*/
interface SocialConnectorFactoryInterface
{
/**
* @param string $socialNetwork The key of the social network
*
@joangrigorov
joangrigorov / bubble_sort.rsc
Created October 20, 2015 17:03
Cool bubble sort
public list[int] sort2(list[int] numbers){
switch(numbers){
case [*int nums1, int p, int q, *int nums2]:
if(p > q){
return sort2(nums1 + [q, p] + nums2);
} else {
fail;
}
default: return numbers;
}
<?php
// BEFORE:
public function deletionAction()
{
$project = $this->getProject($this->params()->fromRoute('projectId'));
if ($this->request->isPost() && $project) {
/** @var \Projects\Model\ProjectDeleter $deleter */
$VAR$ = typeof $VAR$ !== 'undefined' ? $VAR$ : $DEFAULT$;
(function ($) {
'use strict';
$END$
})(window.jQuery);
(function ($, scope) {
'use strict';
/**
* Class for $PURPOSE$
*
* @constructor
*/
var $CLASS_NAME$ = function ($PARAMS$) {
/**
* Setter for $${PARAM_NAME}
*
* @param ${TYPE_HINT} $${PARAM_NAME}
* @return ${CLASS_NAME} Provides fluent interface
*/
public ${STATIC} function set${NAME}($${PARAM_NAME})
{
#if (${STATIC} == "static")
self::$${FIELD_NAME} = $${PARAM_NAME};
/**
* Getter for $${FIELD_NAME}
*
* @return ${TYPE_HINT}
*/
public ${STATIC} function ${GET_OR_IS}${NAME}()
{
#if (${STATIC} == "static")
return self::$${FIELD_NAME};
#else