Skip to content

Instantly share code, notes, and snippets.

View cronoh's full-sized avatar

Andrew Steele cronoh

View GitHub Profile
@cronoh
cronoh / gist:9d5515146971541503b49643d165675e
Created January 21, 2018 18:51
RaiBlocks TPS Test Results
Current TPS: 0
Current TPS: 0
Current TPS: 0
Current TPS: 0
Current TPS: 0
Current TPS: 17
Current TPS: 1
Current TPS: 0
Current TPS: 0
Current TPS: 0
@cronoh
cronoh / CodeTemplateFunction.js
Created September 29, 2017 18:05
Mirth Connect SOAP PasswordDigest Generation
/**
Generate a password digest for SOAP authentication.
Returns an object with a passwordDigest (Base64), nonce (Base64), and created property.
@param string password -
@return { passwordDigest: string, nonce: string, created: string }
*/
function generatePasswordDigest(password) {
// Generate nonce from random bytes
var random = java.security.SecureRandom.getInstance("SHA1PRNG");
@cronoh
cronoh / file.js
Last active March 3, 2017 08:50
Which is better to read?
// For context, we have two arrays of routes (['get', '/', ...], ['put', '/:id', ...]) that we are checking for collisions
// Then removing the collisions from the base array (actions)
// #1
// Remove conflicting routes by filtering out items from the base actions where the first 2 values are equal. Coerce the result of find() to a boolean.
actions = actions.filter(a => !actions2.find(a2 => a[0].toLowerCase() === a2[0].toLowerCase() && a[1].toLowerCase() === a2[1].toLowerCase()));
// #2
actions = actions.filter(a => {
// Search the new actions for a case insensitive match. Coerce the result to boolean, and return the inverse.
@cronoh
cronoh / 1-LaravelController.php
Created January 21, 2017 23:34
Socket IO JWT Flow
public function launchWidget($oAuthToken)
{
// .. Redacted lots of code
$loyaltyIoJwt = $this->loyaltyIoService->createJwt(['user' => $laravelUser->id, 'scopes' => ['**']]);
return view('pages.loyalty.widget', [
'jwt' => $loyaltyIoJwt,
]);
}
$variable = static::where('name', $name)
->whereHas('widget', function ($q) use ($widget) {
$q->where('name', $widget);
})
->first();
return $variable ? : false;
@cronoh
cronoh / NativeSessionHandler.php
Created December 10, 2016 17:43
Laravel 5.x Native Session Handler
<?php
namespace App\Extensions;
use SessionHandlerInterface;
class NativeSessionHandler implements SessionHandlerInterface
{
public function open($savePath, $sessionName)
{
User.get({username: req.body.username}, function(err, user) {
if(err) {return console.log(err);}
if(user) {
res.status(404).json({error: ["Username already exist."]});
} else {
var user = new User({username: req.body.username, provider: 'local', email: req.body.email, password: bcrypt.hashSync(req.body.password, 10)});
user.put(function(err, success){
if(err) {return console.log(err)}
var getConfigDirectory = function () {
switch (process.platform) {
case 'linux': return process.env.XDG_CONFIG_HOME || path.join(home(), '.config')
case 'darwin': return path.join(home(), 'Library', 'Preferences');
case 'win32': return path.join(home(), 'AppData', 'Roaming');
default: return home();
}
}
server {
listen 4567;
server_name _;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host \$host;
proxy_cache_bypass \$http_upgrade;
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host \$host;