Skip to content

Instantly share code, notes, and snippets.

View calam1's full-sized avatar

Christopher Lam calam1

View GitHub Profile
@calam1
calam1 / clean_aged_artifacts.rb
Last active December 20, 2015 00:09
This script will delete directories from Artifactory that have artifacts that have not been downloaded in "x" amount of days. In this example it is 8 days. Tried to just delete the individual artifacts but needed the pro version to do that. We are just deleting the directories instead since that appears to work in the free version. This is more …
#!/bin/env ruby
# --- Configuration ---------------------------------
# Remove artifacts which were created before $age_days ago and haven't been downloaded in recent $age_days.
$age_days = 8
# The repository to be cleaned.
$repo = 'lib-release-local'
@calam1
calam1 / project.clj
Last active August 29, 2015 13:57
Clojure code to search a dynamodb product table. server.clj is the code and project.clj is the project file
(defproject product "0.1.0-SNAPSHOT"
:description "Product Search for Orion MCP"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.5.1"]
[compojure "1.1.6"]
[liberator "0.5.0"]
[ring/ring-json "0.2.0"]
[rotary "0.4.1"]
[org.clojure/data.json "0.2.2"]]
:plugins [[lein-ring "0.8.10"]]
(ns dynamodb.dynamodb-client
(:require [cljs.nodejs :as node]
[cljs.core :as cljs]))
(def express (node/require "express"))
(def express-middlewares (node/require "express-middlewares"))
(def app (express))
(.use app (.bodyParser express-middlewares))
(def aws (node/require "aws-sdk"))
(def deals-all {:TableName "commerce.business.promote.DEAL"
@calam1
calam1 / core.clj
Last active August 29, 2015 14:02
java/clojure interop example - also example of how to handle the _id (ObjectId) from MongoDB when you use the clojure.data.json library. examples of how to convert java Set and List to keywords for monger batch insert and queries.
(ns interop.core
(:require [monger.core :as mongo]
[monger.collection :as mc]
[monger.operators :refer :all]
[clojure.data.json :as json])
(:gen-class :name com.mongodb.dao.Deals
:methods [#^{:static false} [saveDeal [java.lang.String] java.lang.String]
#^{:static false} [getDealsByIds [java.lang.String java.util.Set] java.lang.String]
#^{:static false} [saveEffectiveDeals [java.util.List] void]
#^{:static false} [getEffectiveDeals [java.lang.String java.lang.String java.lang.String] java.lang.String]]))
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Stream;
public class ExtensionTester {
//================================ Supporting classes ======================================
package com.examples;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import java.util.stream.Stream;
public class FuncVsImp {
public static int fibonacciSingleValueIter(int x) {
int a = 1;
/**
The following is not a java class, but some interfaces and implementations of Functors and Monads and a test class(Main.java)
FUNCTOR:
A functor is a typed data structure that encapsulates some value(s). Benefits of functors - they abstract away the internal representation and provide consistent, easy to use API over various data structures.
MONAD:
A monad a set of three things:
* a parameterized type M<T>
@calam1
calam1 / Currying.java
Last active March 5, 2017 20:58
java currying example
public class Currying {
// curry method
public static <A, B, C> Function<A, Function<B, C>> curry(final BiFunction<A, B, C> f) {
return (A a) -> (B b) -> f.apply(a, b);
}
// ADD function
public static BiFunction<Integer, Integer, Integer> biAdd = (a, b) -> {
return a + b;
@calam1
calam1 / stringMix.js
Last active July 7, 2017 23:22
CodeWars String Mix javascript solution
var s1 = "my&friend&Paul has heavy hats! &"
var s2 = "my friend John has many many friends &"
// mix(s1, s2) --> "2:nnnnn/1:aaaa/1:hhh/2:mmm/2:yyy/2:dd/2:ff/2:ii/2:rr/=:ee/=:ss"
// var s1 = "Are they here";
// var s2 = "yes, they are here";
// "2:eeeee/2:yy/=:hh/=:rr")
// Test.assertEquals(mix("looping is fun but dangerous", "less dangerous than coding"), "1:ooo/1:uuu/2:sss/=:nnn/1:ii/2:aa/2:dd/2:ee/=:gg")
@calam1
calam1 / contravariant_functor.js
Last active December 10, 2017 05:30
contravariant functor in javascript
//https://medium.com/@drboolean/monoidal-contravariant-functors-are-actually-useful-1032211045c4
const log = require('./lib/log')
log(
'testing'
)
const daggy = require('daggy')