Skip to content

Instantly share code, notes, and snippets.

View LondonAppDev's full-sized avatar

Mark Winterbottom LondonAppDev

View GitHub Profile
@renoirb
renoirb / etc-salt-master-d-pillars.conf
Created November 27, 2013 18:36
Separating a secret pillar repository, and spreading SSL certificates among hosts.
## in /etc/salt/master.d/pillars.conf
pillar_roots:
base:
- /srv/pillar
- /srv/private/pillar
@mariocesar
mariocesar / jenkins.sh
Last active January 5, 2016 12:11
Jenkins build script for a Django project
export PIP_DOWNLOAD_CACHE=/var/lib/jenkins/pip-cache
export AQUIPAGO_ENVIRONMENT=testing
make
env/bin/pip install -r requirements/base.txt --download-cache=/var/lib/jenkins/pip-cache --use-mirrors --timeout 1
env/bin/pip install -r requirements/project.txt --download-cache=/var/lib/jenkins/pip-cache --use-mirrors --timeout 1
env/bin/python runtests.py || :
env/bin/pylint --rcfile=.pylintrc aquipago --ignore=test > reports/pylint.txt || :
@LondonAppDev
LondonAppDev / bootstrap.sh
Created February 7, 2017 08:19
Python REST API bootstrap.sh script
#!/usr/bin/env bash
# Update the apt repos.
sudo apt-get update
# Install required dev packages.
sudo apt-get install -y language-pack-en
sudo apt-get install -y python3-dev python-pip python-dev
# Install virtualenvwrapper
@sloped
sloped / paging.php
Created March 19, 2012 16:21
Bootstrap Paging and Wordpress
<?php
//Use this function to create pagingation links that are styleable with Twitter Bootstrap
function paging() {
global $wp_query;
$total_pages = $wp_query->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var('paged'));
@microcipcip
microcipcip / redux.js
Last active March 4, 2019 11:55
Redux simple implementation
function createStore(reducer, initialState) {
let state = initialState;
const listeners = [];
const subscribe = listener => listeners.push(listener);
const getState = () => state;
const dispatch = action => {
state = reducer(state, action);
listeners.forEach(l => l());
};
@amalgjose
amalgjose / DateDifference.py
Last active January 4, 2022 19:02
This is a very simple python code snippet for calculating the difference between two dates or timestamps. This will calculate the difference in terms of number of years, months, days, hours, minutes etc. For more details, refer https://amalgjose.com/2015/02/19/python-code-for-calculating-the-difference-between-two-time-stamps/
__author__ = 'Amal G Jose'
from datetime import datetime
from dateutil import relativedelta
##Aug 7 1989 8:10 pm
date_1 = datetime(1989, 8, 7, 20, 10)
##Dec 5 1990 5:20 am
date_2 = datetime(1990, 12, 5, 5, 20)
@chrisdpa-tvx
chrisdpa-tvx / athena.rst
Last active March 20, 2022 06:28
Create an Athena database, table, and query

All Your Data Does Not Belong In a Database

Businesses are machines producing mountains of data about sales, usage, customer, costs, etc... Traditionally data processing is highly centralised with teams of staff and computer running hot a whirling ready to process. We can do better than moving the mountain of data into the corporate data machine - so long as that machinary is light enough to be moved to the data.

Don't move the mountain - Bring the processing to the data

We've had this problem; a huge directory of files in CSV format, conataining vital information for our business. But it's in CSV, requires analysis, and don't you don't feel like learning sed/grep/awk today - besides it's 2017 and no-one thinks those tools are easy to use.

@chrisbodhi
chrisbodhi / deep_work.md
Last active December 22, 2022 17:57
A summary of the tips & tricks in Cal Newport's "Deep Work"

Deep Work

Rules for Focused Success in a Distracted World

Cal Newport, 2016 [purchase it at half-price books]

Part I: The Idea

  • Deep Work is valuable
  • Deep Work is rare
  • Deep Work is meaningful
@gustavohenke
gustavohenke / svg2png.js
Created February 18, 2014 15:27
SVG to PNG
var svg = document.querySelector( "svg" );
var svgData = new XMLSerializer().serializeToString( svg );
var canvas = document.createElement( "canvas" );
var ctx = canvas.getContext( "2d" );
var img = document.createElement( "img" );
img.setAttribute( "src", "data:image/svg+xml;base64," + btoa( svgData ) );
img.onload = function() {
@hgomez
hgomez / jenkins-plugins-batch-install.md
Last active December 11, 2023 07:47
Mass install/update of Jenkins Plugins

Scripted Jenkins Plugins install

Jenkins has a very rich catalog of plugins and it's quite easy to install and update them via UI. BTW, when you want to add tons of plugin via UI, it's a fairly long and boring procedure.

Hopefully, mass installation (or update) could be easy using a simple bash script (curl/python required) :

Create a file containing plugins to be installed (or updated), ie iplugins :