Skip to content

Instantly share code, notes, and snippets.

@simbo1905
simbo1905 / git_clobber_contents.sh
Created December 10, 2017 05:13
git replace local repo contents with new remote repo contents
# sometimes your local repo is created by some tool and you need to seed it with some other
# sample code where you don't need/want to fork the sample code. Try this:
GIT_SRC_URL=$1
remote add simplecode $GIT_SRC_URL
git pull simplecode master -X theirs --allow-unrelated-histories
@simbo1905
simbo1905 / gist:1d2d198db1c54b85e41b1389cd37dce8
Created February 12, 2018 20:22
chmod recursively if you only have ftp and cpanel access
#!/bin/bash
lftp <<EOF
set ftp:ssl-allow no
set ftp:passive-mode true
set ftp:list-options -a
open -u user,password my.host.com
chmod -R 0777 /public_html/images/cache
EOF
# you can 'brew install lftp'
@simbo1905
simbo1905 / .htaccess
Last active February 13, 2018 08:10
.htaccess write traffic to a subfolder to move a site into a subfolder
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/concrete575/
RewriteRule (.*) http://www.mysite.net/concrete575/$1 [R=301,L]
</IfModule>
@simbo1905
simbo1905 / create-env-secret.sh
Last active March 19, 2018 20:29
loads an .env file containing key=value environment variables into an openshift secret `NAME=example ./create-env-secret.sh .env`
#!/bin/bash
if [ "$NAME" = "" ]
then
echo "You must set NAME of the secet as an env var"
exit 1
else
echo "Creating secet/$NAME"
fi
@simbo1905
simbo1905 / commands.sh
Created July 2, 2018 12:32
create a project on one git server with an upstream elsewhere
# If there is a repo in, say Heroku, or say BitBucket, and you want to push to it code from GitHub
git remote add upstream git@github.com:hyperledger/indy-sdk.git
# pull everything from upstream clobbering anything local (assumes you start with an empty repo)
git pull -s recursive -X theirs upstream master
@simbo1905
simbo1905 / php-5.2.17.patch
Created July 24, 2017 21:01
patch php 5.2.17 for Centos7 with patch -p0 < ../php-5.2.17.patch
--- ext/dom/node.c 2012-08-06 17:49:48.826716692 +0800
+++ ext/dom/node.c 2012-08-06 17:52:47.633484660 +0800
@@ -1895,9 +1895,17 @@ static void dom_canonicalization(INTERNA
RETVAL_FALSE;
} else {
if (mode == 0) {
+#ifdef LIBXML2_NEW_BUFFER
+ ret = xmlOutputBufferGetSize(buf);
+#else
ret = buf->buffer->use;
@simbo1905
simbo1905 / java-images-broken-in-chrome.java
Last active November 6, 2018 22:06
This Java code renders the text "Houcine Salma Bendor" as jpg or png it renders differently
public static final String FORMAT_NAME = "jpg"; // change me to png!
public final static void generateImage(final String text, final String fileNameWithoutExt) throws Exception {
/*
Because font metrics is based on a graphics context, we need to create
a small, temporary image so we can ascertain the width and height
of the final image
*/
BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
@simbo1905
simbo1905 / how-to-start-up-on-openshift.md
Last active November 11, 2018 08:50
Starting Up On OpenShift with Laravel and ReactJS www.realworld.io demo apps

Introduction

This is the code that goes with the presentation at https://docs.google.com/presentation/d/1kQhNGoVdoXhnsfwnsgmEBYMftVYR1Vx8QqdCqWSZXiI

These instructions are how to setup what I demoed in that presentation. It is a realistic backend API and frontend SPA. Due to time constraints my presentation demo will start with a working setup and the section "Some 'real world' things to demo in the presentation". All the steps to set everything up are below.

The demo code we will deploy is part of the www.realworld.io project where different people write alternative interoperable frontends or backends. Below I have chosen ReactJS and Laravel but you could use any of the demo apps that use different langages and frameworksgs

Prerequisites Instructions

@simbo1905
simbo1905 / question.md
Last active November 11, 2018 19:25
proposed revised devops question

when should a pod run multiple containers and how would container failures be handled?

The kubernetes docs allow for multiple containers in a pod. When might this be a good idea and how are failures handled?

@simbo1905
simbo1905 / run
Created November 29, 2018 06:28
OKD openshift randomise which database portal host to use for compose.com high availability
#!/bin/sh -e
if [[ ! -z ${DB_HOST_LIST} ]]; then
echo "Selecting DB_HOST from ${DB_HOST_LIST}"
SELECT_LIST_SEPERATOR=","
SELECT_ARRAY=( ${DB_HOST_LIST//$SELECT_LIST_SEPERATOR/ } )
export DB_HOST="${SELECT_ARRAY[$RANDOM % ${#SELECT_ARRAY[@]}]}"
echo "DB_HOST=${DB_HOST}"
fi