Skip to content

Instantly share code, notes, and snippets.

import java.io.InputStream
import org.apache.commons.io.IOUtils
// basically copied from https://gist.github.com/timoteoponce/1249184
object OracleToH2DMLMigration extends App {
def migrate_script(input_file_name: String) = {
val changed_lines = List()
for (line <- input_file_name.split("\n")) {
@ksaric
ksaric / ResourcesUtil.java
Last active January 3, 2016 20:58
Usefull Java methods for reading resources.
import com.google.common.base.Charsets;
import com.google.common.io.CharSource;
import com.google.common.io.CharStreams;
import com.google.common.io.InputSupplier;
import com.google.common.io.Resources;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@ksaric
ksaric / flask_deploy.sh
Last active July 14, 2016 04:01
Deploy flask app on centos from git.
# Flask installer
# If you want a quick setup for a flask app on CentOs 7, try this.
# Requires 'requirements.txt' on your application folder.
# WARNING: this script will open port 8081!
# ideas:
# - http://linuxcommand.org/lc3_new_script.php
# - http://stackoverflow.com/questions/14008125/shell-script-common-template
/**
* @author ksaric
*/
object Flatten {
def flatten[A](list: List[A]): List[A] = list match {
case Nil => Nil
case (head: List[A]) :: tail => flatten(head) ::: flatten(tail)
case head :: tail => head :: flatten(tail)
@ksaric
ksaric / git_branch_diff.py
Last active January 4, 2018 15:26
Find git branch PR diffs
import os, re
project_location = '~/projects/curry/cardano-sl/'
def find_diff_issues(source_branch, target_branch):
git_show_command = 'git show-branch --topics {source_branch} {target_branch}'.format(source_branch=source_branch, target_branch=target_branch)
print(git_show_command)
git_diff_output = os.popen("cd {project_location}; {git_show_command}".format(project_location=project_location, git_show_command=git_show_command)).read()
#print(git_diff_output)
@ksaric
ksaric / nix_diff.py
Created January 8, 2018 14:20
Find nix libraries diff
import re
import os
def _unidiff_output(expected, actual):
"""
Helper function. Returns a string containing the unified diff of two multiline strings.
"""
import difflib
expected=expected.splitlines(1)
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ScopedTypeVariables #-}
module EffectExample where
import Cardano.Prelude
{"name": "test", "description": "This is a test pool", "ticker": "testy", "homepage": "https://github.com/input-output-hk/cardano-db-sync/tree/master/cardano-db/src/Cardano/Db"}