Skip to content

Instantly share code, notes, and snippets.

@mihkell
mihkell / gist:408ccbeae8da0ee7366e22a2ece93c41
Last active February 20, 2017 12:39
Example of diagonal swap of graph
import pandas as pd
import matplotlib.pyplot as plt
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 100000)
price = 'Price'
quantity = 'Quantity'
def make_table():
global price, quantity
table = pd.DataFrame({price:[1,3,3,2,5,6], quantity:[1,2,3,4,5,6]})
<!DOCTYPE html>
<html>
<head><meta charset="utf-8" />
<title>dlnd_image_classification</title><script src="https://unpkg.com/jupyter-js-widgets@2.0.*/dist/embed.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<style type="text/css">
/*!
*
* Twitter Bootstrap
@mihkell
mihkell / .gitignore
Created June 10, 2017 19:14
.gitignore
.DS_Store
.idea
@mihkell
mihkell / pytorch.py
Created June 23, 2018 10:19
Not working model
import numpy as np
import torch
import torch.nn as nn
import torchvision.transforms as transforms
from torchvision import datasets
torch.manual_seed(1)
class MnistModel(nn.Module):
@mihkell
mihkell / floydhub-push.sh
Last active December 12, 2018 21:25
FloydHub workflow supporting script. Allows me to run code on floydhub while developing in jupyter notebook and with low power computer.
notebook_name=$1
project_name=$2
hostname=$3
if [ $(hostname) == $hostname ];
then
echo "worked"
clear
jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace $notebook_name.ipynb
floyd run --gpu --env pytorch-0.4.0 --follow "jupyter nbconvert --execute --ExecutePreprocessor.timeout=-1 $notebook_name.ipynb"
floyd data clone dasmus/projects/$project_name/
@mihkell
mihkell / generate_postgresql_data.sql
Last active January 28, 2020 14:30
Generate PostgresSQL testing data. This will create 50k accounts with total of 140 million transactions.
-- Used https://vnegrisolo.github.io/postgresql/generate-fake-data-using-sql as template to create this simplified solution.
-- psql -h localhost -U postgres
-- CREATE DATABASE test_db;
-- \c test_db
CREATE TABLE transaction (
id serial primary key,
amount integer,
account varchar,
@mihkell
mihkell / java
Last active April 8, 2020 11:38
Flyway example for Stackoverflow
@Configuration
public class FlywayConfiguration {
@Bean(initMethod = "migrate")
@FlywayDataSource
public Flyway firstFlyway(DataSource dataSource) {
return new Flyway(
new FluentConfiguration()
.locations("db/first-migration")
.schemas("first")
@mihkell
mihkell / play_sound_after_x_seconds.html
Created May 14, 2020 15:09
Plays sound after x seconds
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script>
function out() {
x = document.getElementById('a').value;
@mihkell
mihkell / audit_table_slow_dynamic.sql
Last active May 19, 2020 13:13
Creating and inserting into audit table. WIP
-- psql -h localhost -U postgres
-- CREATE DATABASE test_db;
-- \c test_db
CREATE OR REPLACE FUNCTION create_or_update(schema_name_val varchar, tabel_name_val varchar) RETURNS void AS
$$
DECLARE
log_trigger_name varchar = 'log_trigger_' || tabel_name_val;
full_table_name varchar = schema_name_val || '.' || tabel_name_val;
audit_table_name varchar = tabel_name_val || '_log';
-- psql -h localhost -U postgres
-- CREATE DATABASE test_db;
-- \c test_db
-- Trigger create START
create schema if not exists public_log;
DO
$$
DECLARE
drop_clause varchar;