Skip to content

Instantly share code, notes, and snippets.

View thirukkural2022's full-sized avatar

mv thirukkural2022

View GitHub Profile
@ruurtjan
ruurtjan / functional-dsl-blog-8.scala
Created May 22, 2020 12:02
Final encoded email filter
object final_encoded_email_filter {
final case class Address(emailAddress: String)
final case class Email(sender: Address, to: List[Address], subject: String, body: String)
case class EmailFilter(run: Email => Boolean) { self =>
def &&(that: EmailFilter): EmailFilter = EmailFilter(email => self.run(email) && that.run(email))
def ||(that: EmailFilter): EmailFilter = EmailFilter(email => self.run(email) || that.run(email))
def negate : EmailFilter = EmailFilter(email => !self.run(email))
@ruurtjan
ruurtjan / functional-dsl-blog-7.scala
Created May 22, 2020 12:02
Initial encoded email filter example
object initial_encoded_email_filter {
final case class Address(emailAddress: String)
final case class Email(sender: Address, to: List[Address], subject: String, body: String)
sealed trait EmailFilter { self =>
def &&(that: EmailFilter): EmailFilter = EmailFilter.And(self, that)
def ||(that: EmailFilter): EmailFilter = (self.negate && that.negate).negate
def negate : EmailFilter = EmailFilter.Not(self)
#define _GNU_SOURCE
#include <errno.h>
#include <sched.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
@jeffreyscarpenter
jeffreyscarpenter / cqlsh_intro.cql
Last active August 1, 2024 07:05
Introduction to CQL / cqlsh
#
# cqlsh_intro.cql
#
# Copyright (C) 2017 Jeff Carpenter
# Execute the commands in this file for a short guided tour of the CQL Shell (cqlsh)
#
# For more description, see Cassandra, The Definitive Guide 2nd Ed., Chapter 3: Installing
# http://shop.oreilly.com/product/0636920043041.do
#
@blackcater
blackcater / diagrams.md
Created July 6, 2018 16:45
Markdown Diagrams

Diagrams

Markdown Preview Enhanced supports rendering flow charts, sequence diagrams, mermaid, PlantUML, WaveDrom, GraphViz, Vega & Vega-lite, Ditaa diagrams. You can also render TikZ, Python Matplotlib, Plotly and all sorts of other graphs and diagrams by using Code Chunk.

Please note that some diagrams don't work well with file exports such as PDF, pandoc, etc.

Flow Charts

This feature is powered by flowchart.js.

@ldclakmal
ldclakmal / Stemmer.java
Created January 21, 2018 02:47
Stemmer, implementing the Porter Stemming Algorithm
package DM;
/*
Porter stemmer in Java. The original paper is in
Porter, 1980, An algorithm for suffix stripping, Program, Vol. 14,
no. 3, pp 130-137,
See also http://www.tartarus.org/~martin/PorterStemmer
@eddytseng
eddytseng / counter.controller.js
Last active May 21, 2018 12:21
Angularjs counter component
function CounterController() {
this.increment = function() {
this.count++;
};
this.decrement = function() {
this.count--;
};
}
@bmc
bmc / StaticFile.scala
Last active September 3, 2021 20:08
I needed code to serve static files from an Akka HTTP server. I wanted to use fs2 to read the static file. Michael Pilquist recommended using streamz to convert from an fs2 Task to an Akka Source. This is what I came up with. (It does actually work.)
object StaticFile {
// Various necessary imports. Notes:
//
// 1. fs2 is necessary. See https://github.com/functional-streams-for-scala/fs2
// 2. streamz is necessary. See https://github.com/krasserm/streamz
// 3. Apache Tika is used to infer MIME types from file names, because it's more reliable and
// fully-featured than using java.nio.file.Files.probeContentType().
//
// If using SBT, you'll want these library dependencies and resolvers:
@ikhoon
ikhoon / must-watch-talks.md
Last active April 14, 2020 10:46
Must watch talks - reddit /r/scala