Skip to content

Instantly share code, notes, and snippets.

@arbabnazar
arbabnazar / websocket-elb.md
Created Apr 23, 2019 — forked from zhiguangwang/websocket-elb.md
Configure websockets behind an AWS ELB.
View websocket-elb.md
@simpixelated
simpixelated / start-non-split.js
Created Apr 23, 2019
Disable Code Splitting (and caching) In Create React App
View start-non-split.js
const rewire = require('rewire');
const defaults = rewire('react-scripts/scripts/start.js');
let configFactory = defaults.__get__('configFactory');
defaults.__set__('configFactory', (env) => {
const config = configFactory(env);
config.optimization.splitChunks = {
cacheGroups: {
default: false,
},
@essidimed
essidimed / PY0101EN-1-1-Types.ipynb
Created Apr 23, 2019
Created on Cognitive Class Labs
View PY0101EN-1-1-Types.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Araton95
Araton95 / SwappableERC20.sol
Created Apr 23, 2019
Swappable ERC20 smart contracts NEW
View SwappableERC20.sol
pragma solidity 0.5.2;
/**
* @title SafeMath
* @dev Unsigned math operations with safety checks that revert on error
*/
library SafeMath {
/**
* @dev Multiplies two unsigned integers, reverts on overflow.
*/
View gist:830eb56a22ad8b33d6c61fb552193236
using System;
using System.Linq;
using NodaTime;
using NodaTime.Extensions;
public class Program
{
public static void Main()
{
var latest = (from zone in DateTimeZoneProviders.Tzdb.GetAllZones()
@bhoriuchi
bhoriuchi / chef-databag-v3.js
Created Apr 23, 2019
nodejs Chef Databag V3 Encrypt/Decrypt
View chef-databag-v3.js
import crypto from 'crypto';
// decrypt a v3 databag
export function decryptV3(data, key) {
try {
const decipher = crypto.createDecipheriv(
data.cipher.trim(),
crypto
.createHash('sha256')
.update(key.trim())
@NaveenaDraksharam
NaveenaDraksharam / index.html
Created Apr 23, 2019
JS Bin rotated array find index // source https://jsbin.com/jeboniy
View index.html
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="rotated array find index">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
@arbabnazar
arbabnazar / elb-nginx-websockets.md
Last active Apr 23, 2019 — forked from Likeyn/elb-nginx-websockets.md
How-to websockets through ELB + Nginx reverse proxy
View elb-nginx-websockets.md

Websockets-through-ELB-to-Nginx-to-another-ELB recap

We need to setup an ELB with SSL termination in front of a Nginx reverse proxy to some already working ELB + project system. IOW: SSL-ELB -> Nginx reverse proxy -> ELB -> project. We'll assume the last ELB + project bit works properly.

Front ELB configuration

  • Configure the listeners to use TCP (80) instead of HTTP to allow the websockets (non-HTTP) to pass through. For HTTPS with SSL termination, simply use SSL (443) -> TCP (80)
@malex984
malex984 / sample_app.py
Created Apr 23, 2019
Sample module / application
View sample_app.py
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# encoding: utf-8
# coding: utf-8
"""
Sample cli application
"""
@rust-play
rust-play / playground.rs
Created Apr 23, 2019
Code shared from the Rust Playground
View playground.rs
fn main() {
let filter = "Joh";
let names = vec!["John", "Jane", "Johnny"];
let lowered_filter = filter.to_lowercase();
let filterNames = |x: &&str| -> bool {
x.to_lowercase().contains(&lowered_filter)
};
let filtered: Vec<&str> = names.iter().cloned().filter(filterNames).collect();
println!("List {:?}", filtered);
You can’t perform that action at this time.