Skip to content

Instantly share code, notes, and snippets.

View bluebrown's full-sized avatar

Nico Braun bluebrown

View GitHub Profile
@bluebrown
bluebrown / main.c
Created May 7, 2021 12:57
Posix Threads in C
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
pthread_cond_t hasMsg = PTHREAD_COND_INITIALIZER;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
void *work(void *ptr)
{
@bluebrown
bluebrown / index.html
Last active May 6, 2021 14:16
Monaco Editor Setup
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Monaco</title>
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css"
@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;
@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 / 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 / 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 / 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 / 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 / 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 / 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