Skip to content

Instantly share code, notes, and snippets.

View mjul's full-sized avatar

Martin Jul mjul

View GitHub Profile
@mjul
mjul / quoted.fsx
Created April 15, 2016 10:55
F# Quoted Expressions (writing a compiler)
// F# Quoted Expressions
open Microsoft.FSharp.Quotations
open Microsoft.FSharp.Quotations.Patterns
open Microsoft.FSharp.Quotations.DerivedPatterns
// A typed code quotation.
let expr : Expr<int> = <@ 1 + 1 @>
// An untyped code quotation.
@mjul
mjul / elasticsearch.fsx
Last active June 1, 2022 08:15
Elasticsearch in F# example
// paket add nuget NEST
#I "../../packages"
#r "Elasticsearch.Net/lib/net46/Elasticsearch.Net.dll"
#r "NEST/lib/net46/Nest.dll"
open System
//open Elasticsearch.Net
open Nest
@mjul
mjul / Dockerfile
Created June 2, 2016 08:53
Running R scripts in a Docker container
FROM r-base:latest
COPY . /usr/local/src/myscripts
WORKDIR /usr/local/src/myscripts
CMD ["Rscript", "myscript.R"]
@mjul
mjul / core.clj
Last active July 5, 2016 09:48
Convert XLS file to CSV (here just the A, B and C columns) (Clojure)
(comment
(defproject importer "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/data.csv "0.1.3"]
[dk.ative/docjure "1.10.0"]]
@mjul
mjul / aws_env
Created July 8, 2016 13:32
Get environment variables from AWS profile (for use with docker-machine)
#!/bin/sh
# Set the AWS environment variables for an AWS profile
# Useful for docker-machine
#
# Example:
#
# aws_env profile-for-testing
#
# Further information:
# See the AWS CLI `aws configure`
@mjul
mjul / Dockerfile
Created August 9, 2016 14:36
Dockerfile for R with extra libraries
FROM r-base
# Install some libraries that we need for the R packages we use
# with git we can use install_github("foo/bar") from R
RUN apt-get update && \
apt-get install -y git libssl-dev libssh2-1-dev libcurl4-openssl-dev
COPY . /usr/local/src/myscripts
WORKDIR /usr/local/src/myscripts
@mjul
mjul / rsync.md
Created August 19, 2016 10:06
RSync a local directory to docker-machine to make it available for VOLUME

Docker VOLUME directories are local directories on the docker host. Hence, when using docker-machine with remote hosts they are not available. However, we can rsync files to the remote docker host and MOUNT them from there

Local directory to docker-machine home directory

Assuming rs is a directory, this copies its contents to the home directory of the default user (ubuntu) on the remote docker-machine with the name my-sandbox. : denotes the remote machine, with no path it defaults to the current directory of the shell (the ubuntu user's home directory).

@mjul
mjul / 02_nginx_gzip_configuration.config
Last active November 6, 2020 03:29
Enable gzip compression in Elastic Beanstalk Docker nginx proxy (add to .ebextensions folder)
files:
"/etc/nginx/conf.d/gzip.conf":
mode: "644"
owner: "root"
group: "root"
content: |
# enable gzip compression
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
@mjul
mjul / log.txt
Created October 18, 2016 07:43
F# interactive exposes a bug in Mono (OSX)
fsibug $ cat mini.fsx
type A = A of int
let result = [for a in 1..3 -> A a]
printfn "Succeeded: %A" result
fsibug $ fsharpi mini.fsx
System.TypeLoadException: Failure has occurred while loading a type.
at [email protected] (System.Collections.Generic.IEnumerable`1[FSI_0001+A]& next) [0x000a0] in <096c3b14bd5948a9921b6ca3f280fec3>:0
at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1[T].MoveNextImpl () [0x00017] in <57dfe31ddff9fae1a74503831de3df57>:0
@mjul
mjul / Shell
Last active January 2, 2018 15:40
Check the signature of PyCharm if it keeps asking "accept incoming connections" (patches break it - delete and reinstall if sig broken)
codesign -vvv /Applications/PyCharm.app