Skip to content

Instantly share code, notes, and snippets.

@orenbenkiki
orenbenkiki / gist:4027328
Created November 6, 2012 20:33
lein autodoc can't find "sh"
Exception in thread "main" java.lang.IllegalAccessError: sh does not exist
at clojure.core$refer.doInvoke(core.clj:3778)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invoke(core.clj:603)
at clojure.core$load_lib.doInvoke(core.clj:5279)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:603)
at clojure.core$load_libs.doInvoke(core.clj:5298)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:605)
@orenbenkiki
orenbenkiki / http.ex.patch
Created February 23, 2013 05:35
Patch expm http.ex to pass http proxy settings to hackney
diff --git a/lib/repositories/http.ex b/lib/repositories/http.ex
index 2dae690..bdb1ece 100644
--- a/lib/repositories/http.ex
+++ b/lib/repositories/http.ex
@@ -9,7 +9,7 @@ defrecord Expm.Repository.HTTP, url: "https://expm.co", username: nil, password:
{"accept", "text/html"},
{"user-agent", "expm/#{Expm.version}"},
],
- "", [follow_redirect: true, force_redirect: true])
+ "", Expm.Repository.HTTP.Decoder.proxy(follow_redirect: true, force_redirect: true))
@orenbenkiki
orenbenkiki / enhanced_extension.ex
Last active February 21, 2022 22:29
Elixir module inheritance
defmodule Extension do
defmacro extends(module) do
# As above...
end
defmacro implements(module, protocol: protocol) do
quote do
defimpl unquote(protocol), for: unquote(module) do
import Extension
@orenbenkiki
orenbenkiki / gist:5189329
Created March 18, 2013 18:01
Enhanced mix cover (generate index.html, and more)
defmodule Mix.Tasks.Test do
use Mix.Task
@shortdoc "Run a project's tests"
@moduledoc """
Run the tests for a project.
This task will preload the `test/test_helper.exs` which
should do all testing setup and then require all files
$ rustc --lib src/atom/crate.rs
src/anthill/atom.rs:3:4: 5:5 warning: missing documentation for a struct
src/anthill/atom.rs:3 pub struct Atom {
src/anthill/atom.rs:4 priv id: int,
src/anthill/atom.rs:5 }
src/anthill/crate.rs:4:7: 4:18 note: lint level defined here
src/anthill/crate.rs:4 #[warn(missing_doc)]
^~~~~~~~~~~
warning: missing crate link meta `name`, using `crate` as default
warning: missing crate link meta `vers`, using `0.0` as default
src/anthill/intern.rs:71:24: 73:25 error: instantiating a type parameter with an incompatible type `intern::intern::Interner`, which does not fulfill `Send+Freeze`
src/anthill/intern.rs:71 do arc_interner.read |interner| {
src/anthill/intern.rs:72 interner.id_to_str[self.id].clone()
src/anthill/intern.rs:73 }
src/anthill/intern.rs:88:20: 108:21 error: instantiating a type parameter with an incompatible type `intern::intern::Interner`, which does not fulfill `Send+Freeze`
src/anthill/intern.rs:88 do arc_interner.read |interner| {
src/anthill/intern.rs:89 match interner.str_to_intern.find(&burrowed.to_str()) {
src/anthill/intern.rs:90 Some(intern) => *intern,
src/anthill/intern.rs:91 None => {
src/anthill/intern.rs:92 // TRICKY: If we didn't find it above, we need
/// Intern a string using the task local interner.
pub fn intern(burrowed: &str) -> Intern {
do local_data::get(KEY_ARC_INTERNER) |maybe_arc_interner| {
match maybe_arc_interner {
None => fail!("no task local ARC for global interner"),
Some(arc_interner) => {
// TRICKY: Only obtain a read lock for the common case
// where the string was previously interned.
do arc_interner.read |interner| {
match interner.str_to_intern.find(&burrowed.to_str()) {
@orenbenkiki
orenbenkiki / code.rs
Last active December 20, 2015 22:49
macro_export not working?
mod code {
use macros; // compiler warning: unused import :-(
#[test]
fn asserts() {
assert_eq!(1, 1);
assert_ne!(1, 2); // compiler error: macro undefined :-(
}
}
@orenbenkiki
orenbenkiki / plotly_fast_large_heatmap.py
Last active August 12, 2019 14:46
Plotly Dash Fast Large Heatmap
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.graph_objs as go
import pandas as pd
import numpy as np
from math import ceil
from math import floor
@orenbenkiki
orenbenkiki / slant.r
Last active June 4, 2020 09:37
R code for visualization of similarity matrices, by reordering them so high values move to the diagonal (become "slanted"), and optionally apply order-preserving clustering to the result.
#' Compute rows and columns orders which move high values close to the diagonal.
#'
#' For a matrix expressing the cross-similarity between two (possibly different)
#' sets of entities, this produces better results than clustering (e.g. as done
#' by \code{pheatmap}). This is because clustering does not care about the order
#' of each two sub-partitions. That is, clustering is as happy with \code{((2, 1),
#' (4, 3))} as it is with the more sensible \code{((1, 2), (3, 4))}. As a result,
#' visualizations of similarities using naive clustering can be misleading.
#'
#' @param data A rectangular matrix.