Skip to content

Instantly share code, notes, and snippets.

View maatthc's full-sized avatar

Alexandre Andrade maatthc

  • MaaT Tech
  • Melbourne
View GitHub Profile
var CardIO = null;
try {
CardIO = UIViewController.extend({
setup: function() {
CardIOUtilities.preload();
},
init: function() {
var self = this.super.init();
if (self) {
import serial
import kivy
from kivy.app import App
from kivy.clock import Clock
from kivy.core.window import Window
from kivy.uix.scrollview import ScrollView
from kivy.uix.gridlayout import GridLayout
from kivy.properties import ObjectProperty, StringProperty
@maatthc
maatthc / generate_big_file.py
Created June 16, 2017 10:28
Generates a file with one random number per line.
#!/usr/bin/env python
from sys import argv, exit
import random
big_file_name = "big_file.txt"
max_size_of_number = 1000000
random.seed(123)
if len(argv) != 2:
print "Usage: %s Num_Lines" % __file__
@maatthc
maatthc / topN.py
Last active June 16, 2017 10:25
Read numbers from a big file and present the N largest numbers
#!/usr/bin/python
from sys import argv
import multiprocessing as mp
import time
# Ajust for number of cpus/memory
# Each process will sort an array of size : ratio_per_process * size_array_largest
ratio_per_process = 30000
# Lets consolidate the Sort after some number of interations
num_interations = 50
puts "The Mick "
puts "Gap Year "
puts "Stan Lees Lucky Man "
puts "The Worst Witch "
puts "The Middle "
puts "Master of None "
puts "Sense8 "
puts "Da Vincis Demons "
puts "Scorpion "
puts "Citizen Khan "
# Ruby 2.3.3
# puts print
# Simbols are simpler String objs
# Constants are Capitalized variables
# Methods name finishing with a question mark returns booleans
# You can chain methods: job.get().askRaise()
# Global vars starts with a Dollar sign: $
# Instance vars starts with an At sign: @
@maatthc
maatthc / Dockerfile_Python_Mysql_Django
Created June 12, 2016 16:16
Dockerfile to build Python / Django / Mysql small container images . Based on Linux Alpine.
############################################################
# Dockerfile to build Python / Django / Mysql small container images
# Based on Linux Alpine
############################################################
# Set the base image
FROM alpine
# File Author / Maintainer
MAINTAINER Alexandre Andrade [email protected]
@maatthc
maatthc / CC_SoftLayer.py
Created May 5, 2016 07:16
Helper to the SoftLayer API - Helps protectig the API Key
import getpass
from cryptography.fernet import Fernet
import sys
def get_credentials():
# SoftLayer Username/ Api Key encrypted
encrypted_credentials = b''
secret_key = getpass.getpass("Please enter your secret key: ")
@maatthc
maatthc / CC_Datadog.py
Created May 5, 2016 07:14
Helper for Datadog API
from datadog import initialize, api
import sys
def dd_init():
dd_options = {
'api_key': '',
'app_key': ''
}
initialize(**dd_options)
return api
@maatthc
maatthc / softlayer_cancel_servers.py
Last active May 6, 2016 03:54
It cancels Baremetal servers running at SoftLayer.It also power off the server and muted the monitoring at Datadog.
"""
Cancel the server with SoftLayer, turn it off and mute the Datadog alerts for it.
The host will be available until the next 16th day of the month.
"""
import SoftLayer
import sys
from CC_SoftLayer import get_credentials as sl_get_cred
from CC_Datadog import dd_init