Skip to content

Instantly share code, notes, and snippets.

@exts
exts / Kernel.php
Last active December 4, 2017 23:50
Symfony 4, Symfony Flex, Vagrant, Failed to remove directory (cache, de~, pools), Windows 10
<?php
class Kernel extends BaseKernel
{
use MicroKernelTrait;
const CONFIG_EXTS = '.{php,xml,yaml,yml}';
public function getCacheDir()
{
def to_hex(decimal)
decimal_remainder = decimal % 16
hexchars = "0123456789ABCDEF"
div = decimal / 16
if div == 0
hexchars[decimal_remainder].to_s
else
to_hex(div) + hexchars[decimal_remainder].to_s
end
end
class Test
@stored = [] of Proc(Nil)
def captured(&block)
@stored << block
end
def example
@stored.each do |b|
b.call()
end
@exts
exts / fresh-php7-nginx-server.txt
Last active November 30, 2023 06:02
Fresh PHP 8.0 LEMP setup info/Ubuntu 16
## Requires newer versions of ubuntu, I'm using Ubuntu 20
# install nginx
sudo apt install nginx
# add php8.X repository
sudo add-apt-repository ppa:ondrej/php
sudo apt update
# search libraries
function say(a) {
cleanUp = function(str) {
return str.replace(/[^a-zA-Z0-9]+/, "");
}
addDashes = function(str) {
return cleanUp(str).split("").join("-");
}
return function(b) {
function say(a)
{
splitUp = function(data) {
dataArray = data.split("")
stringArray = [];
for(x = 0; x < dataArray.length; x++) {
if(dataArray[x].match(/[a-zA-Z0-9]/)) {
stringArray[stringArray.length++] = dataArray[x];
}
}
@exts
exts / route-parser.cr
Created January 7, 2017 04:06
Crystal Lang: Screwing around, trying to figure out a simple way to parse a route w/ named parameters (and optional ones)
#idiotcoder.com
#eatcodegame.com
class RouteParser
@default_regex_replacement = "w+"
getter regex_variables = {} of String => String
getter default_variables = {} of String => String
getter matched_variables = [] of String
@exts
exts / route-container.cr
Last active January 5, 2017 05:00
Example of how to approach route containers with groups and sub groups in crystal language (inspired by php frameworks such as Slim Framework 3)
class Route
def initialize(@route = "")
end
def route
@route
end
end
class RouteContainer
@exts
exts / pass-closure-as-argument.cr
Last active January 5, 2017 04:57
Pass closure blocks to methods/functions as parameter arguments in crystal language
# idiotcoder.com
def example(&ex)
ex.call()
end
example &-> {
puts "sup"
}
def example(&ex)
ex.call()
end