Skip to content

Instantly share code, notes, and snippets.

mihkell

Block or report user

Report or block mihkell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View audit_table_static.sql
-- 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;
View play_sound_after_x_seconds.html
<!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
Creating and inserting into audit table. WIP
View audit_table_slow_dynamic.sql
-- 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';
@mihkell
mihkell / java
Last active Apr 8, 2020
Flyway example for Stackoverflow
View java
@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 / generate_postgresql_data.sql
Last active Jan 28, 2020
Generate PostgresSQL testing data. This will create 50k accounts with total of 140 million transactions.
View generate_postgresql_data.sql
-- 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 / floydhub-push.sh
Last active Dec 12, 2018
FloydHub workflow supporting script. Allows me to run code on floydhub while developing in jupyter notebook and with low power computer.
View floydhub-push.sh
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 / pytorch.py
Created Jun 23, 2018
Not working model
View pytorch.py
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):
View Tensorflow hashmap example.py
import numpy as np
import tensorflow as tf
input_tensor = tf.constant(1, dtype=tf.int64)
keys = tf.constant(np.array([1,2,3]), dtype=tf.int64)
values = tf.constant(np.array([4,5,6]), dtype=tf.int64)
default_value = tf.constant(-1, dtype=tf.int64)
table = tf.contrib.lookup.HashTable(
View .gitignore
.DS_Store
.idea
View dlnd_imageClassification.html
<!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
You can’t perform that action at this time.