Skip to content

Instantly share code, notes, and snippets.

Avatar

Denis Mysenko dusterio

View GitHub Profile
View GatewayController.php
<?php
class GatewayController extends Controller
{
/**
* @param Request $request
* @param RestClient $client
* @return Response
*/
public function get(Request $request, RestClient $client)
View RouteRegistry.php
<?php
class RouteRegistry
{
/**
* @param Application $app
*/
public function bind(Application $app)
{
$this->getRoutes()->each(function ($route) use ($app) {
View AppServiceProvider.php
<?php
class AppServiceProvider extends ServiceProvider
{
/**
* @return void
*/
protected function registerRoutes()
{
$registry = $this->app->make(RouteRegistry::class);
View config.php
<?php
return (static function() {
$configTemplate = [
'routes' => [
[
'aggregate' => true,
'method' => 'GET',
'path' => '/v1/devices/{mac}/details',
'actions' => [
'device' => [
View 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 Nov 15, 2019
Simple status page generation using Pingdom and AWS Lambda
View .js
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 Jan 15, 2020
Add parity bits to a 7 byte DES encryption key
View addParityBits.php
<?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);
@dusterio
dusterio / .js
Created Oct 20, 2019
Decrypting Laravel's session cookie with JavaScript and Cloudflare
View .js
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
}