Skip to content

Instantly share code, notes, and snippets.

View bluebrown's full-sized avatar

Nico Braun bluebrown

View GitHub Profile
@bluebrown
bluebrown / flexgrid.css
Last active February 28, 2020 09:25
simple column layout
.flex-row {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-direction: row;
flex-direction: row;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
@bluebrown
bluebrown / linode_dc.sh
Created September 17, 2019 18:07
Linode docker-compose stack script
#!/bin/bash
yum update -y
yum install -y git yum-utils device-mapper-persistent-data lvm2 httpd-tools
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py && rm -f $PWD/get-pip.py
pip install docker-compose
systemctl start docker && systemctl enable docker
@bluebrown
bluebrown / a_usage.js
Last active December 2, 2019 18:33
golongpoll javascript client implementation with socket.io like interface
import {LongpollManager} from 'http://0.0.0.0:6611/client.js'
let lpm = new LongpollManager('http://0.0.0.0:6611')
lpm.subscribe('example', (data) => document.write(`${JSON.stringify(data)} <br>`))
lpm.publish('example', {hello: 'world'}) // publish objects to given category
@bluebrown
bluebrown / zsh_smarthistory.md
Created February 19, 2020 09:07
zsh smart-history

Add the following lines to the zsh config e.g. .zshrc

bindkey '\e[A' history-beginning-search-backward
bindkey '\e[B' history-beginning-search-forward

The behavior of history-beginning-search-backward is as follows:

Search forward in the history for a line beginning with the current line up to the cursor. This leaves the cursor in its original position.

@bluebrown
bluebrown / slider.css
Last active March 8, 2020 20:14
Slider
:root {
overflow: hidden;
--slide-transition: all 2s ease 0s;
--image-height: 300px;
--image-padding: 0.2vw;
--image-opacity: 0.5;
--image-left: 0%;
--wrap-width: 100%;
--wrap-right: 00%;
@bluebrown
bluebrown / javascript.devcontainer.json
Created May 18, 2020 15:03
VS Code Sample .devcontainer.json
{
"name": "sample-devcontainer",
"image": "node",
"workspaceFolder": "/sample-devcontainer",
"workspaceMount": "source=sample-devcontainer,target=/sample-devcontainer,type=volume",
"mounts": [ // reuse global node modules and vscode extensions across containers
"source=npm_global,target=/npm_global,type=volume",
"source=javascript_vscode_extensions,target=/root/.vscode-server/extensions,type=volume",
],
"postCreateCommand": "npm config set prefix '/npm_global'",
@bluebrown
bluebrown / docker-compose.yml
Created October 19, 2020 00:51
Single-Node Jenkins & Blue Ocean - Docker Compose
version: "3.7"
services:
jenkins:
image: docker:dind
privileged: true
environment:
- DOCKER_TLS_CERTDIR="/certs"
volumes:
@bluebrown
bluebrown / s3authentication.py
Last active April 20, 2021 14:36
Authenticate for AWS S3 request
from datetime import datetime
from hashlib import sha256
import hmac
import requests
from os import environ as env
# templates for creating the auth header
Canonical_Request = '{HTTPMethod}\n{CanonicalURI}\n{CanonicalQueryString}\n{CanonicalHeaders}\n\n{SignedHeaders}\n{HashedPayload}'
Scope = '{DATE}/{REGION}/{SERVICE_NAME}/{KIND}'
@bluebrown
bluebrown / Dockerfile
Last active June 26, 2021 22:48
Docker - call command from entrypoint.sh
FROM alpine
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]
CMD echo 'hello, captain!'
ENV FOO=bar
@bluebrown
bluebrown / main.c
Last active May 7, 2021 13:02
Berkeley Sockets in C
#include <sys/socket.h>
#include <netdb.h>
#define BACKLOG 10
#define PORT 8080
int main(void)
{
int sockfd, new_fd, sin_size;
struct sockaddr_in server, client;