Skip to content

Instantly share code, notes, and snippets.

View discosultan's full-sized avatar

Jaanus Varus discosultan

  • Amsterdam, The Netherlands
View GitHub Profile
@discosultan
discosultan / kubernetes.sh
Last active November 2, 2020 14:47
Cheat sheet for common programming tasks
# Delete all evicted pods.
kubectl get po --all-namespaces --field-selector 'status.phase!=Running' -o yaml | kubectl delete -f -
# List all resources in a namespace.
kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get --show-kind --ignore-not-found -n <namespace>
# Trigger cronjob manually.
kubectl create job --from=cronjob/<cronjob-name> <job-name>
# Run busybox.
input = [
50811,
128897,
89996,
149611,
141114,
135923,
111930,
92803,
55111,
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>Hello world</h1>
<div style="width: 100px; height: 100px; background-color: red"></div>
<h2>This is a header</h2>
@asynccontextmanager
async def ws_connect_with_refresh(
session: ClientSession,
url: str,
interval: int,
loads: Callable[[str], Any],
take_until: Callable[[Any, Any], bool]) -> AsyncIterator[AsyncIterable[Any]]:
conn = session.ws_connect(url)
ws = await conn.__aenter__()
@discosultan
discosultan / copy_secret.sh
Last active February 15, 2019 12:18
Copy k8s secret from one namespace to another
kubectl get secret bigquery --namespace=default --export -o yaml | kubectl apply --namespace=monitoring -f -
import requests
assets = ['blockport', 'iota', 'bitcoin', 'litecoin', 'ethereum', 'bitcoin-cash', 'ripple',
'eos', 'neo', 'tron', 'aelf', 'monero']
for asset in assets:
res = requests.get(f'https://api.coincap.io/v2/assets/{asset}/history?interval=d1')
res.text
import sys
inputs = [
[ # High.
94.1875, 94.5000, 93.5000, 92.7500, 92.8750, 90.7500, 89.8750, 89.1250, 90.4375,
90.0000, 88.5000, 87.7500, 87.0625, 85.8125, 86.5625, 90.3750, 91.3750, 92.2500,
93.3750, 92.0625, 92.8750, 93.9375, 95.2500, 97.1250, 97.1875, 94.8750, 94.3125,
93.3125, 94.1250, 96.9375, 101.125, 108.750, 115.000, 117.125, 115.000, 116.625,
118.000, 119.250, 119.250, 118.812, 118.375, 119.938, 117.750, 118.625, 117.125,
@discosultan
discosultan / Program.cs
Created June 8, 2018 19:58
interval merging
using static System.Diagnostics.Debug;
using static System.Math;
using Intervals = System.Collections.Generic.List<(int Start, int End)>;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
@discosultan
discosultan / observable.cs
Last active June 8, 2018 11:59
Observable.FromEventPattern verbose example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading.Tasks;
namespace Pronoodle.Products
{
/// <summary>
@discosultan
discosultan / keybindings.json
Created September 18, 2017 09:58
VSCode keybindings to execute Rust commands
// Place your key bindings in this file to overwrite the defaults
[{
"key": "ctrl+shift+t",
"command": "workbench.action.tasks.runTask",
"args": "cargo test",
"when": "editorTextFocus && editorLangId == rust"
},{
"key": "ctrl+shift+r",
"command": "workbench.action.tasks.runTask",
"args": "cargo run",