Skip to content

Instantly share code, notes, and snippets.

View dusterio's full-sized avatar

Denis Mysenko dusterio

View GitHub Profile
<?php
class GatewayController extends Controller
{
/**
* @param Request $request
* @param RestClient $client
* @return Response
*/
public function get(Request $request, RestClient $client)
<?php
class RouteRegistry
{
/**
* @param Application $app
*/
public function bind(Application $app)
{
$this->getRoutes()->each(function ($route) use ($app) {
<?php
class AppServiceProvider extends ServiceProvider
{
/**
* @return void
*/
protected function registerRoutes()
{
$registry = $this->app->make(RouteRegistry::class);
<?php
return (static function() {
$configTemplate = [
'routes' => [
[
'aggregate' => true,
'method' => 'GET',
'path' => '/v1/devices/{mac}/details',
'actions' => [
'device' => [
@dusterio
dusterio / Rails structure
Created December 22, 2016 03:04
Rails structure
./app/assets
./app/assets/config
./app/assets/images
./app/assets/javascripts
./app/assets/javascripts/channels
./app/assets/stylesheets
./app/channels/application_cable
./app/controllers
./app/controllers/concerns
./app/helpers
@dusterio
dusterio / .js
Created October 20, 2019 08:16
Decrypting Laravel's session cookie with JavaScript and Cloudflare
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
const string2buffer = string => {
let tempArray = new Uint8Array(string.length)
for(let i = string.length; i--) tempArray[i] = string.charCodeAt(i)
return tempArray.buffer
}
@dusterio
dusterio / .js
Created November 15, 2019 04:23
Simple status page generation using Pingdom and AWS Lambda
const fetch = require("node-fetch")
const fs = require("fs")
const PINGDOM_API_KEY = process.env.PINGDOM_API_KEY
const AWS = require('aws-sdk')
const s3 = new AWS.S3({signatureVersion: 'v4'})
const checksConfig = [
{
id: 123,
title: 'event'
@dusterio
dusterio / addParityBits.php
Created January 15, 2020 11:01
Add parity bits to a 7 byte DES encryption key
<?php
/**
* @param string $key - Input 7 byte DES key, without parity bits, in hex format
* @return string - Output 8 byte DES key, with parity bits, in hex format
*/
function addParityBitsToDESKey($key) {
$binary = base_convert($key, 16, 2);
$bytes = str_split($binary, 7);