Skip to content

Instantly share code, notes, and snippets.

View malcolmgreaves's full-sized avatar

Malcolm Greaves malcolmgreaves

View GitHub Profile
@manjuraj
manjuraj / scalaz-validation.scala
Last active June 25, 2018 21:01
scalaz validation
//
// Validation[E, A] represents either:
// - Success[A]
// - Failure[E]
//
// Isomporphic to scala.Either[E, A] and scalaz.\/[E, A]
//
// Unlike \/[E, A], Validation is not a Monad, but an Applicative
// Functor. So if you want to use it as a Monad you can convert back
// and forth using the `validation` and `disjunction` method
@manjuraj
manjuraj / scalaz-applicative.scala
Created July 9, 2015 06:01
scalaz applicative
//
// Apply extends the Functor Typeclass by adding a method `ap` which
// is similar to `map` from Functor in that it takes a functor that
// that has a function in it and another functor and extracts that
// function from the first functor and then maps it over the second
// one
//
// Alternatively, you can say `ap` lets you apply a function in a
// context to a value in a context
//
@fancellu
fancellu / SparkShellDebugOff.scala
Created August 6, 2015 11:20
Spark shell too chatty, want to turn off logging and can't be bothered to edit log4j files?
// Just run this inside the spark shell, no more chatty logs
import org.apache.log4j.Logger
import org.apache.log4j.Level
Logger.getLogger("org").setLevel(Level.OFF)
Logger.getLogger("akka").setLevel(Level.OFF)
@rponte
rponte / get-latest-tag-on-git.sh
Last active September 16, 2025 08:48
Getting latest tag on git repository
# The command finds the most recent tag that is reachable from a commit.
# If the tag points to the commit, then only the tag is shown.
# Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object
# and the abbreviated object name of the most recent commit.
git describe
# With --abbrev set to 0, the command can be used to find the closest tagname without any suffix:
git describe --abbrev=0
# other examples
@djspiewak
djspiewak / 0introduction.md
Last active November 28, 2023 15:03
Scala Collections Proposal

Collections Redesign Proposal

I'm going to start off by motivating what I'm doing here. And I want to be clear that I'm not "dissing" the existing collections implementation or anything as unproductively negative as that. It was a really good experiment, it was a huge step forward given what we knew back in 2.8, but now it's time to learn from that experiment and do better. This proposal uses what I believe are the lessons we can learn about what worked, what didn't work, and what is and isn't important about collections in Scala.

This is going to start out sounding really negative and pervasively dismissive, but bear with me! There's a point to all my ranting. I want to be really clear about my motivations for the proposal being the way that it is.

Problems

Generic Interfaces

import scala.language.higherKinds
import scala.reflect.ClassTag
import scala.language.implicitConversions
trait Data[D[_]] extends Serializable {
def map[A, B: ClassTag](d: D[A])(f: A => B): D[B]
def flatMap[A, B: ClassTag](d: D[A])(f: A => Iterable[B]): D[B]
@saliksyed
saliksyed / autoencoder.py
Created November 18, 2015 03:30
Tensorflow Auto-Encoder Implementation
""" Deep Auto-Encoder implementation
An auto-encoder works as follows:
Data of dimension k is reduced to a lower dimension j using a matrix multiplication:
softmax(W*x + b) = x'
where W is matrix from R^k --> R^j
A reconstruction matrix W' maps back from R^j --> R^k
@inanna-malick
inanna-malick / pusher.scala
Last active August 11, 2016 00:27 — forked from gre/pusher.scala
Using Pusher API with Play framework in scala for publishing events
//send messages via Pusher API in play 2.4
import play.api.libs.json.{ Writes, Json }
import play.api.libs.ws.{ WSResponse, WSClient }
import play.api.libs.ws.ning.NingWSClient
import java.security.MessageDigest
import java.math.BigInteger
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec
import scala.concurrent.{ ExecutionContext, Future }
@Chandler
Chandler / slack_history.py
Last active March 27, 2025 01:16
Download Slack Channel/PrivateChannel/DirectMessage History
print("UPDATE AUG 2023: this script is beyond old and broken")
print("You may find interesting and more up to date resources in the comments of the gist")
exit()
from slacker import Slacker
import json
import argparse
import os
# This script finds all channels, private channels and direct messages
@tedsta
tedsta / deep_learn_xor.rs
Last active February 2, 2016 20:16
Example of untrained xor circuit using deeplearn-rs
extern crate deeplearn;
extern crate matrix;
use deeplearn::Graph;
use deeplearn::op::{MatMul, Relu};
fn main() {
let ctx = matrix::Context::new();
// Setup the graph