Skip to content

Instantly share code, notes, and snippets.

Ansible playbook to setup HTTPS using Let's encrypt on nginx.
The Ansible playbook installs everything needed to serve static files from a nginx server over HTTPS.
The server pass A rating on [SSL Labs](https://www.ssllabs.com/).
To use:
1. Install [Ansible](https://www.ansible.com/)
2. Setup an Ubuntu 16.04 server accessible over ssh
3. Create `/etc/ansible/hosts` according to template below and change example.com to your domain
4. Copy the rest of the files to an empty directory (`playbook.yml` in the root of that folder and the rest in the `templates` subfolder)
class BinaryNode:
__slots__ = ("value", "left", "right")
def __init__(self, value=None, left=None, right=None):
self.value = value
self.left = left
self.right = right
def __repr__(self):
return f"<BinaryNode value={self.value}; {1 if self.left else 0 + 1 if self.right else 0} children>"
@c80609a
c80609a / convert2voice.sh
Created September 12, 2023 06:44 — forked from samoshkin/convert2voice.sh
Google Text-to-Speech API example
#!/bin/bash
text=$(cat -)
request="{
'input':{
'ssml':'<speak>$text</speak>'
},
'voice':{
'languageCode':'en-gb',
'name':'en-GB-Wavenet-D',
@c80609a
c80609a / jira_ticket_status_diagram_in_mermaid.mmd
Created September 12, 2023 06:36 — forked from samoshkin/jira_ticket_status_diagram_in_mermaid.mmd
JIRA ticket state diagram written in Mermaid DSL
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@c80609a
c80609a / socket-io-and-redux-saga-integration.js
Created September 12, 2023 06:32 — forked from samoshkin/socket-io-and-redux-saga-integration.js
Socket.IO and redux-saga integration. Connection management
import { io } from 'socket.io-client';
import * as SentrySDK from '@sentry/react';
import {
call,
fork,
takeEvery,
put,
race,
take,
} from 'redux-saga/effects';
@c80609a
c80609a / research.md
Created September 9, 2023 15:08 — forked from Code-Hex/research.md
Research performance nginx per configuration

wrk -c 100 -t 4 -d 10 http://127.0.0.1:8080/

Default configuration

nginx.conf

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;
@c80609a
c80609a / README.md
Created July 14, 2023 15:39 — forked from adevil5/README.md
Create Postgres Roles

Create Postgres Roles

read_access

Read all data (tables, views, sequences), as if having SELECT rights on those objects, and USAGE rights on all user-created schemas.

  1. Replace db_name with the relevant database name.
  2. Run the Database section of the script.
#!/bin/bash
################################################################################
#
# Helper variables to print text using some colors.
#
################################################################################
# Restore to default colours
RESTORE='\033[0m'
@c80609a
c80609a / fb-base-code-example.js
Created March 13, 2023 08:51 — forked from dbradley/fb-base-code-example.js
Facebook Pixel Standard Events
<!-- Facebook Pixel Code Example -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', '1234567890');
fbq('track', "PageView");
[Unit]
Description=Download IP Geolocation Database from Maxmind.com
[Service]
Type=oneshot
WorkingDirectory=/tmp
ExecStart=/bin/sh -c "\
mkdir -p /home/core/ip_database \
curl -O http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz ; \
gunzip GeoLite2-City.mmdb.gz ; \
curl -O http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.md5 ; \