Skip to content

Instantly share code, notes, and snippets.

View kwuite's full-sized avatar

Kelvin Wuite kwuite

View GitHub Profile
@superseb
superseb / create_user_and_kubeconfig_rancher2.sh
Last active November 1, 2023 18:51
Create local user and generate kubeconfig in Rancher 2 via API
#!/bin/bash
RANCHERENDPOINT=https://your_rancher_endpoint/v3
# The name of the cluster where the user needs to be added
CLUSTERNAME=your_cluster_name
# Username, password and realname of the user
USERNAME=username
PASSWORD=password
REALNAME=myrealname
# Role of the user
GLOBALROLE=user
@ianks
ianks / slugify.sql
Last active July 11, 2024 20:50
Generating Slugs in Postgres
CREATE EXTENSION IF NOT EXISTS "unaccent";
CREATE OR REPLACE FUNCTION slugify("value" TEXT)
RETURNS TEXT AS $$
-- removes accents (diacritic signs) from a given string --
WITH "unaccented" AS (
SELECT unaccent("value") AS "value"
),
-- lowercases the string
"lowercase" AS (
@webknjaz
webknjaz / test_client_fake_server.py
Created May 20, 2018 17:35 — forked from ambivalentno/test_client_fake_server.py
pytest-asyncio aiohttp client testing with fake server
import asyncio
import pathlib
import socket
import ssl
import pytest
import aiohttp
from aiohttp import web
from aiohttp.resolver import DefaultResolver
@ambivalentno
ambivalentno / test_client_fake_server.py
Created November 17, 2017 13:48
pytest-asyncio aiohttp client testing with fake server
import asyncio
import pathlib
import socket
import ssl
import pytest
import aiohttp
from aiohttp import web
from aiohttp.resolver import DefaultResolver
@mihow
mihow / load_dotenv.sh
Last active July 25, 2024 04:35
Load environment variables from dotenv / .env file in Bash
# The initial version
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
# My favorite from the comments. Thanks @richarddewit & others!
set -a && source .env && set +a
@rclai
rclai / meteor-wrapAsync.js
Last active January 30, 2023 15:20
Flexible example of Meteor.wrapAsync
// Thanks @trusktr
var requestSync = Meteor.wrapAsync(function(url, callback) {
request(url, function(error, response, body) {
callback(error, {response: response, body: body})
})
});
var result = requestSync("http://google.com");
console.log(result.response, result.body);
@jepio
jepio / chain.py
Created September 10, 2015 13:20
chain method calls in python
class chain:
"""
A class that allows the chaining of function/method calls on objects
and modules.
To use create chain an object and then go crazy calling methods one
after the other.
>>> import curses
@phybros
phybros / update-route53.sh
Last active February 12, 2024 00:07
BASH Script to keep Route53 updated with your current external IP address
#!/bin/bash
# (optional) You might need to set your PATH variable at the top here
# depending on how you run this script
#PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# Hosted Zone ID e.g. BJBK35SKMM9OE
ZONEID="enter zone id here"
# The CNAME you want to update e.g. hello.example.com
@willurd
willurd / web-servers.md
Last active July 25, 2024 21:14
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000