Skip to content

Instantly share code, notes, and snippets.

@qlawmarq
qlawmarq / clone-k8s-deployment.sh
Created July 18, 2023 05:00
Clone kubernetes(k8s) deployment
# The following is an example of a command to clone an development(ex-app-development) as an production(ex-app-production).
kubectl get deployment ex-app-development -o json \
| jq '.metadata.name = "ex-app-production"' \
| kubectl apply -f -
@dimitrovs
dimitrovs / dockerhost.sh
Last active September 17, 2017 20:36
Add the IP of a dockerhost to the /etc/hosts file of a Docker container if not already there.
#!/bin/bash
if [[ -z $(grep dockerhost /etc/hosts) ]]
then
echo `/sbin/ip route|awk '/default/ { print $3 }'` dockerhost >> /etc/hosts
fi
@msabramo
msabramo / tsuru-setup.sh
Created November 12, 2014 05:56
Script to automate a lot of the setup of tsuru
PROG="tsuru-setup"
if [ -z "${TSURU_USER}" ]; then
echo "${PROG}: Please set the TSURU_USER environment variable before running this script"
exit 1
fi
if [ -z "${TSURU_TARGET}" ]; then
echo "${PROG}: Please set the TSURU_TARGET environment variable before running this script"
exit 2
@eglute
eglute / gist:7382c35de6985d45f831
Created July 20, 2014 18:38
OSCON OpenStack Workshop Commands
cat ~/credentials/user
source ~/credentials/user
keystone discover
keystone catalog
keystone endpoint-get --service volume
keystone token-get --wrap 50
nova list
nova flavor-list
nova boot --image cirros-qcow2 --flavor 1 MyFirstInstance
@msabramo
msabramo / Makefile
Last active December 20, 2015 04:59
A Possible bug in Cython? This is the code for a message that I'm posting to the cython-users group at https://groups.google.com/forum/#!forum/cython-users
test: hello.so
python -c 'import hello; hello.byte_bugginess()'
hello.so: hello.pyx
python setup.py build_ext --inplace
clean:
$(RM) -r *.so *.c *.pyc __pycache__ *.egg-info build
@msabramo
msabramo / io_module_redirect_stdin_stdout_stderr.patch
Last active December 20, 2015 01:29
Experiment for Python issue 15805: An attempt at adding redirect_stdin, redirect_stdout, and redirect_stderr context manager functions to the `io` module
diff -r e7305517260b Lib/io.py
--- a/Lib/io.py Sat Jul 20 15:12:19 2013 +0200
+++ b/Lib/io.py Sun Jul 21 10:14:26 2013 -0700
@@ -56,6 +56,8 @@
BufferedWriter, BufferedRWPair, BufferedRandom,
IncrementalNewlineDecoder, TextIOWrapper)
+from unittest.mock import patch
+
OpenWrapper = _io.open # for compatibility with _pyio
@danverbraganza
danverbraganza / tox.ini
Created January 26, 2012 00:54
My standard tox.ini file that allows you to run coverage, lettuce, nosetests and lint, and to pick out a given feature or a module for nosetest (So that you don't have to run the whole suite)
[tox]
envlist=py27,lint
[testenv]
downloadcache={homedir}/.pipcache
distribute=True
sitepackages=False
[testenv:py27]
deps=nose
@msabramo
msabramo / print_settings.py
Created October 12, 2011 07:12
A super simple but useful Django management command to print the active project settings
from django.core.management.base import BaseCommand
from django.conf import settings
class Command(BaseCommand):
help = "Print the active Django settings."
def handle(self, *args, **options):
for key in dir(settings):
if key.startswith('__'):
@karmi
karmi / hook_up_homebrew.sh
Created September 2, 2011 10:24
Hook up your Homebrew installed with curl to your Github fork
# Install Homebrew
#
mkdir -p /usr/local
mkdir -p /usr/local/bin
sudo chown -R $USER /usr/local
cd $HOME && mkdir -p homebrew
curl -L https://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C homebrew
ln -nfs $HOME/homebrew/bin/brew /usr/local/bin/
brew update
@CHH
CHH / MetaObject.php
Created August 30, 2011 13:55
PHP does Meta Programming too! (Requires PHP 5.4)
<?php
namespace CHH;
trait MetaObject
{
protected static $__metaClass;
static function setMetaClass(MetaClass $metaClass)
{