Skip to content

Instantly share code, notes, and snippets.

View WinstonN's full-sized avatar

Winston Nolan WinstonN

  • Christchurch, New Zealand
View GitHub Profile
@WinstonN
WinstonN / main.py
Created March 23, 2021 23:13
Simple Lotto number generator, with powerball
# Try and guess the lotto numbers
# http://lottoresults.co.nz/tools/lotto/number-analysis
import random
numbers_count = 6
powerball_numbers_count = 1
numbers = [
19,
1,
@WinstonN
WinstonN / flatten_additional_attributes.py
Last active March 16, 2021 19:58
Flatten additional_attributes from Magento 2 export csv
"""
This script formats a magento product export file, and sets each
additional_attribute as a new column in a target file
"""
import csv
# real files
source_file = './catalog_product_20210316_044037.csv'
target_file = './catalog_product_20210316_044037_formatted.csv'
def setup_host_group(context, environment, filter, tags='private_ip_address'):
"""
Setup hosts group from EC2 instances using boto3
"""
hosts = extract_instances_information(context, environment, filter, tags)
config = get_config()
connection = [Connection(host=host, config=config) for host in hosts]
return connection
def get_hosts_from_ec2(environment, filter):
"""
Create hosts pool, containing available hosts to be targeted
"""
if environment not in environments:
raise Exception(f"Environment must be one of {environments}")
# get ip information
get_local_ip_information()
FABRIC_SSH_CONFIG_FILE=.ssh/config.d/company_name
FABRIC_COMPANY=company_name
#!/usr/bin/env python3
"""
Fabric 2 script for executing commands on EC2 instances, and docker containers
@author Winston Nolan <winston.nolan@gmail.com>
Installation:
pip3 install fabric2 termcolor boto3
"""
import os
import sys
import requests
pip3 install boto3
pip3 install fabric2
@WinstonN
WinstonN / ArrayFunctions.mq4
Last active January 8, 2018 19:14 — forked from currencysecrets/ArrayFunctions.mq4
Array utility functions for MetaTrader 4. Helpful functions for doing some of the repetitive tasks in MQL.
/*
* clearIntArray
* This function deletes all items in array (sets it to 0) and resizes array according to size (default = 1).
* @param int& theArray - passing the array by reference
* @param int size - size of the array (default = 1)
* @return int blank array of size
*/
void clearIntArray( int& theArray[], int size = 0 ) {
ArrayResize( theArray, size );
if ( size > 0 ) { ArrayInitialize( theArray, 0 ); }
@WinstonN
WinstonN / gist:2ac4d50af25d29d3942e517e9faab418
Created July 26, 2016 17:49 — forked from JeroenBoersma/gist:60a4acb8e56498bce41c
Magento cleanup unused product images
<?php
/**
* Cleanup images from Magento
*/
require 'app/Mage.php';
if (!Mage::isInstalled()) {
echo "Application is not installed yet, please complete install wizard first.";
exit;