Skip to content

Instantly share code, notes, and snippets.

View comtom's full-sized avatar

Tomás Dowling comtom

View GitHub Profile
@comtom
comtom / db.py
Created September 13, 2017 18:07
import asyncio
import aiomysql
loop = asyncio.get_event_loop()
# async def main(all_done):
# """Get all messages."""
# conn = await aiomysql.connect(host='127.0.0.1', port=3306, user='test',
@comtom
comtom / boot.py
Last active July 12, 2018 14:22
ESP32 / ESP8266 code
# This file is executed on every boot (including wake-boot from deepsleep)
def wifi_connect():
import network
sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected():
sta_if.active(True)
sta_if.connect('ss', 'wifi')
while not sta_if.isconnected():
@comtom
comtom / virtualenv_alias.sh
Created October 13, 2017 14:13 — forked from haridas/virtualenv_alias.sh
A Simple bash alias for python virtualenv. :)
# Python virtual env alias
alias activate='test -d ENV && source ./ENV/bin/activate || echo "No Virtualenv in the current folder"'
alias mkenv='test -d ENV && echo "Already exists" || virtualenv --system-site-packages ENV; activate'
import matplotlib.pyplot as plt
from sklearn.datasets.base import load_data
from sklearn.utils import Bunch
from sklearn.decomposition import PCA
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
def load_netflix(return_X_y=False):
data, target, target_names = load_data('/home/comtom/extra/netflix/', 'file1.csv')
import time
import datetime
with open('file1.csv', 'w') as output:
with open('combined_data_1.txt', 'r') as f:
currentMovieID = 0
for line in f:
line = line.strip()
from bhtsne import tsne
from sklearn.datasets.base import load_data
from sklearn.utils import Bunch
import pandas as pd
import numpy as np
from ggplot import *
def load_netflix(return_X_y=False):
data, target, target_names = load_data('/home/comtom/extra/netflix/', 'file1-100mil.csv')
@comtom
comtom / rename_models_controllers.sh
Last active July 12, 2018 14:21
Migrate CodeIgniter models and controllers from 2.x to 3.x
sudo rename 's/(?<!\.)\b\w*/\u$&/g' *
@comtom
comtom / redirect_index_example.php
Last active May 24, 2018 11:10
Redirect index example for codeigniter
class IndexController extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->helper('captcha');
$this->load->model('user', 'user');
}
public function location($location_id) {
$this->index($location_id);
}
public function index($location_id = 1) {
@comtom
comtom / Dockerfile
Created July 12, 2018 14:19
Build a custom micro binary with all plugins you want in your machine and then make a docker image with it
FROM alpine:3.2
RUN apk add --update ca-certificates && \
apk add libc6-compat && \
rm -rf /var/cache/apk/* /tmp/*
ADD micro /micro
WORKDIR /
ENTRYPOINT [ "/micro" ]
FROM alpine:3.7
ENV KUBE_VERSION="v1.11.2"
ENV ANSIBLE_VERSION="2.5.0"
ENV TERRAFORM_VERSION="0.11.8"
# install kubectl
RUN set -ex \
&& apk add --update ca-certificates \
&& apk add --update -t deps curl \