Skip to content

Instantly share code, notes, and snippets.

@dmontagu
dmontagu / fastapi_cbv.py
Last active May 2, 2024 03:24
FastAPI CBV
import inspect
from typing import Any, Callable, List, Type, TypeVar, Union, get_type_hints
from fastapi import APIRouter, Depends
from pydantic.typing import is_classvar
from starlette.routing import Route, WebSocketRoute
T = TypeVar("T")
CBV_CLASS_KEY = "__cbv_class__"
apiVersion: batch/v1beta1
kind: CronJob
metadata:
annotations:
name: ecr-cred-helper
namespace: default
spec:
concurrencyPolicy: Allow
failedJobsHistoryLimit: 1
jobTemplate:
@netgusto
netgusto / README.md
Last active February 5, 2022 01:25
Run a graphical app in docker on OSX

Run a graphical app in docker on OSX

Note: Replace 192.168.0.5 below by your own interface ip

mac $ socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
mac $ docker run --device=/dev/tty0 -e DISPLAY=192.168.0.5:0 -i -t ubuntu /bin/bash
ubuntu $ apt-get update && apt-get install -y firefox
ubuntu $ firefox
@nachokb
nachokb / centos-scaleway.md
Last active March 16, 2017 07:11
Instruction for running CentOS 6.7 on Scaleway's C2
  1. create a scaleway instance, let's call it centos-builder
  2. Ubuntu Trusty on a C2S is ok
  3. make sure to add an additional 50gb volume Screenshot_from_2016-03-11_02-19-22
  4. upload centos-root.fsa to centos-builder
  5. install FSArchiver
  6. apt-get install fsarchiver
  7. extract it on /dev/nbd1
  8. fsarchiver -v restfs centos-root.fsa id=0,dest=/dev/nbd1
  9. shut the machine down from Scaleway's web UI

Kubernetes + AWS ECR = ❤️

Makefile and YAML templates for automating the use of AWS Elastic Container Registry with Kubernetes.

Based off of this awesome Redsaid blog post.

Requirements

  • Amazon ECR, along with your AWS account ID and the region your ECR is in
  • AWS CLI
@nikhan
nikhan / twitter.sh
Created January 1, 2016 04:45
twitter ffmpeg
ffmpeg -i test.mov -vcodec libx264 -vf 'scale=640:trunc(ow/a/2)*2' -acodec aac -vb 1024k -minrate 1024k -maxrate 1024k -bufsize 1024k -ar 44100 -strict experimental -r 30 out.mp4
tested in OS 10.9.5
Configure Postfix for Gmail SMTP
Edit file /etc/postfix/main.cf
sudo vim /etc/postfix/main.cf
and add in the following below the commented out relayhosts :-
relayhost = [smtp.gmail.com]:587
@amuraru
amuraru / create-hadoop-ext4.sh
Created December 13, 2014 14:23
Hadoop EXT4 formatting options
mkfs.ext4 -m 1 -T largefile -O dir_index,extent,sparse_super /dev/sdb
@prb
prb / maven_spark_magic.xml
Created May 12, 2014 16:47
Fragment of a pom.xml file for packaging separate worker and driver JARs for Spark.
<!-- Fragment of pom.xml -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.2</version>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
@julienhay
julienhay / index.html
Last active September 26, 2018 14:04
Base template, jquery, jquery UI, bootstrap (CDN)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>test</title>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css" />