Instantly share code, notes, and snippets.

View PckFileExposer.cs
public class PckFileExposer : IDisposable
{
private byte[] _data;
private string _filename;
private string _tmpDataFilename;
private bool _disposed;
public PckFileExposer(string filename)
{
View deploy.php
<?php
namespace Deployer;
require 'recipe/common.php';
//Project Name
set('application', 'app_name');
// Project repository
set('repository', 'git@bitbucket.org:USER/REPO.git');
View AuthenticatedSubscriber.php
<?php
namespace App\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\KernelEvents;
/**
View Kernel.php
<?php
class Kernel extends BaseKernel
{
use MicroKernelTrait;
const CONFIG_EXTS = '.{php,xml,yaml,yml}';
public function getCacheDir()
{
View decimalToHex.cr
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
View macro-woes.cr
class Test
@stored = [] of Proc(Nil)
def captured(&block)
@stored << block
end
def example
@stored.each do |b|
b.call()
end
View fresh-server.txt
# install nginx
sudo apt-get install nginx
# add php7.X repository
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
# search libraries
sudo apt-cache search php7-*
View hey-dominos2.js
function say(a) {
cleanUp = function(str) {
return str.replace(/[^a-zA-Z0-9]+/, "");
}
addDashes = function(str) {
return cleanUp(str).split("").join("-");
}
return function(b) {
View heydominos.js
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];
}
}
View route-parser.cr
#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