Skip to content

Instantly share code, notes, and snippets.

@newmen
newmen / safe_heads.hs
Last active December 27, 2015 21:59
Pattern matching forever!
app_head :: [a] -> [a] -> [a]
app_head acc [] = acc -- so easy
app_head acc xs = acc ++ [head xs]
safe_heads :: [[a]] -> [a]
safe_heads [] = []
safe_heads xs = foldl app_head [] xs
-- hard way over Maybe
@newmen
newmen / find_algorithm_declarations.rb
Last active May 7, 2016 14:38
Declaration of find algorithm builder
COMMON: ##########################################################################################################
intermediate checking order # =>
> none
> more number of amorph bonds of unit atom in unit specie
> more number of crystal bonds of unit atom in unit specie
> more number of unit specie relations
public:
@newmen
newmen / Vagrant file
Last active February 29, 2016 13:35
The environment files for OSA CentOS 7
# -*- mode: ruby -*-
# vi: set ft=ruby :
OWN_EMAIL = ''.freeze
JOB_EMAIL = ''.freeze
JDK_PKG = '/root/Downloads/jdk-8u73-linux-x64.rpm'.freeze
OSA_PKGS = %(
apr-devel bison bison flex flex gcc-c++ gettext glib2-devel glib2-devel glibc.i686 hiredis-devel libev-devel
libevent-devel libevent-devel libuuid-devel libuuid-devel mariadb-devel openldap-devel openldap-devel
syntax on
set autoindent
set cindent
set ruler
if has("autocmd")
filetype plugin indent on
autocmd FileType make set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab
endif
set tabstop=4
(ns ideal.tools.graph)
(defn add-edge
[graph v w]
(update graph v (fnil conj #{}) w))
(defn all-children
[graph key]
(if-let [first-children (get graph key)]
(into #{}
package ...;
import reactor.core.publisher.Flux;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
package com.odin.rating.application.utils;
import com.odin.rating.application.api.PersistenceHandler;
import reactor.core.publisher.Mono;
import javax.persistence.EntityTransaction;
import java.util.function.Function;
public class TransactionalMono<T> {
private final EntityTransaction transaction;
private Map<String, Map<String, Map<SchemaInternalOperation, List<SchemaCharge>>>> splitTotal(List<SchemaCharge> charges) {
return MapSeq.map(splitByOffer(charges), (String k, List<SchemaCharge> v) -> {
return MapSeq.map(splitByResource(v), w -> splitByOperation(w));
});
}
private Map<String, List<SchemaCharge>> splitByOffer(List<SchemaCharge> charges) {
return MapSeq.orderedGroupBy(charges, SchemaCharge::getOfferId);
}
@newmen
newmen / .zsh_aliases
Last active May 13, 2024 14:44
.zsh_aliases
export PATH=$HOME/bin:$PATH:/usr/local/sbin
export PATH=$PATH:$HOME/appengine-java-sdk/bin
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export HISTFILESIZE=5000000
#export HISTCONTROL=ignoredups
export HISTCONTROL=ignoreboth:erasedups
@newmen
newmen / .zshrc
Created May 13, 2024 14:42
.zshrc
# .zshrc
#autoload -Uz compinit && compinit
autoload -U select-word-style
select-word-style bash
setopt extended_history
setopt hist_expire_dups_first
setopt hist_ignore_dups
setopt hist_ignore_all_dups