Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
building jedmud

Tanel Tammik keevitaja

💭
building jedmud
View GitHub Profile
View autosort.js
const print = obj => {
for (const key in obj) {
console.log(obj[key])
}
}
const num = {}
num[5] = 5
num[2] = 2
View index.js
const { app, component, controllers, system, options } = require('jedmud-component')
component(()=> {
const { alias, short, trigger, block, gag } = controllers
alias.set('^yolo$', ()=> system.send('say yolo'))
short.set('^y$', 'yolo')
short.set('^rl ', '#system reload ')
const id = trigger.set('\{say\}You say', ()=> {
@keevitaja
keevitaja / letsencrypt_2017.md
Created May 9, 2018 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)
View letsencrypt_2017.md

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

@keevitaja
keevitaja / nginx.conf
Created May 9, 2018 — forked from nrollr/nginx.conf
NGINX config for SSL with Let's Encrypt certs
View nginx.conf
# Advanced config for NGINX
server_tokens off;
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options nosniff;
# Redirect all HTTP traffic to HTTPS
server {
listen 80;
server_name www.domain.com domain.com;
return 301 https://$host$request_uri;
@keevitaja
keevitaja / default.vcl
Created Apr 30, 2018 — forked from kamigerami/default.vcl
haproxy + ssl -> varnish -> back to haproxy for loadbalancing to --> backend0/1/2 (webhost)
View default.vcl
# This versions uses ELB loadbalancing
# The ELB points to these two HAProxy hosts
# The C-name of the Domain points to the ELB
# ELB -> HAPROXY 1 or 2 -> Varnish --> HIT or MISS --> HAPROXY 1 or 2 -> Backend 1/2/3
vcl 4.0;
import directors;
backend haproxy1 {
.host = "172.31.xx.235"; # back to HAPROXY-1 internal address
.port = "8080";
.probe = {
View blessed_is_super_fast.js
const blessed = require('blessed')
const colors = require('colors')
const screen = blessed.screen({
smartCSR: true
})
let index = 0
let page = []
View blessed_is_slow.js
const blessed = require('blessed')
const colors = require('colors')
const screen = blessed.screen({
smartCSR: true
})
let index = 0
const display = blessed.box({
@keevitaja
keevitaja / checksum.js
Created May 6, 2017
Cheap hash for javascript
View checksum.js
export default (s)=> {
let hash = 0
let strlen = s.length
if ( strlen === 0 ) {
return hash;
}
for (let i = 0; i < strlen; i++) {
let c = s.charCodeAt(i)
@keevitaja
keevitaja / dropdown.scss
Last active Mar 20, 2018
Bulma nav dropdown
View dropdown.scss
.has-dropdown {
display: relative;
.dropdown {
display: none;
position: absolute;
background-color: $white-bis;
padding: 14px;
border: 1px solid $grey-lighter;
border-radius: $radius;
View Middleware.php
<?php namespace Keevitaja\TestModule;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Translation\Translator;
class LoadTranslations
{
protected $trans;