Skip to content

Instantly share code, notes, and snippets.

remove gnome apps

sudo dnf remove gnome-tour gnome-abrt gnome-calculator gnome-calendar gnome-maps gnome-weather \
    rhythmbox gnome-contacts totem gnome-logs gnome-photos gnome-clocks gedit gnome-system-moniter \
    gnome-user-docs gnome-screenshot gnome-remote-desktop

remove fedora chromium policies

sudo dnf remove fedora-chromium-config
@graninas
graninas / cpp_stm_free_tutorial.md
Last active October 8, 2024 23:12
Software Transactional Memory in C++: Pure Functional Approach (tutorial)

Software Transactional Memory in C++: pure functional approach (Tutorial)

In this article I’ll tell you about my pure functional library for Software Transactional Memory (STM) that I’ve built in C++. I adopted some advanced functional programming concepts that make it composable and convenient to use. Its implementation is rather small and robust, which differentiates the library from competitors. Let’s discuss what STM is and how to use it.

@annappropriate
annappropriate / UpdateReturning.scala
Created June 10, 2016 08:54
Update returning for Slick 3.1.1
private def updateReturning[A, F](
returningQuery: Query[A, F, C], v: U): SqlStreamingAction[Vector[F], F, Effect.All] = {
val ResultSetMapping(
_, CompiledStatement(_, sres: SQLBuilder.Result, _), CompiledMapping(_updateConverter, _)) =
updateCompiler.run(updateQuery.toNode).tree
val pconv: SetParameter[U] = {
val ResultSetMapping(_, compiled, CompiledMapping(_converter, _)) =
updateCompiler.run(updateQuery.toNode).tree
val converter = _converter.asInstanceOf[ResultConverter[JdbcResultConverterDomain, U]]

An expression is said to be referentially transparent if it can be replaced with its value without changing the behavior of a program (in other words, yielding a program that has the same effects and output on the same input)

https://en.wikipedia.org/wiki/Referential_transparency

This example is taken from the book "Functional Programming in Scala"

The following is referentially transparent:

scala> val x = "hello, world"
@non
non / operators-for-cats.md
Last active January 5, 2018 15:26
Basic write-up of how Cats supports using symbolic operators with type classes.

Symbolic operators and type classes for Cats

One of the simplest and most recognizable type classes is the semigroup. This type class abstracts over the ability to combine values of a certain type in an associative manner.

Cats provides cats.Semigroup[A] to model semigroups [1]. The combine method takes two values of the type A and returns an A value.

@invkrh
invkrh / mockInput.scala
Last active November 24, 2017 10:15
input mocking for test need
object test extends App {
import scala.collection.JavaConversions.asJavaEnumeration
import java.io.{ByteArrayInputStream, SequenceInputStream}
val inputs = Iterator("asdf", "qewr", "wert")
.map(x => new ByteArrayInputStream((x + "\n").getBytes))
val in = new SequenceInputStream(asJavaEnumeration(inputs))
Console.setIn(in)
val a = readLine()
val b = readLine()
@azymnis
azymnis / KMeansJob.scala
Created October 23, 2014 23:07
K-Means in scalding
import com.twitter.algebird.{Aggregator, Semigroup}
import com.twitter.scalding._
import scala.util.Random
/**
* This job is a tutorial of sorts for scalding's Execution[T] abstraction.
* It is a simple implementation of Lloyd's algorithm for k-means on 2D data.
*
* http://en.wikipedia.org/wiki/K-means_clustering
@vjache
vjache / SRB
Last active August 29, 2015 14:07
Deadly simple Shared Ring Buffer in Erlang.
%% Shared Ring Buffer
-module(srb).
-export([new/2, push/2, pop/2, pop/1]).
-compile(export_all).
-record(counters,
{ clock :: non_neg_integer(),
max_size :: non_neg_integer() }).
@micmarsh
micmarsh / flip.clj
Last active May 12, 2022 17:16
Flip the arguments of a function, Clojure style
(defn flip [function]
(fn
([] (function))
([x] (function x))
([x y] (function y x))
([x y z] (function z y x))
([a b c d] (function d c b a))
([a b c d & rest]
(->> rest
(concat [a b c d])
@jamarparris
jamarparris / Generate Mongo Object ID in PostGres
Last active November 17, 2024 20:15
Create ObjectIds in PostGres following the MongoDB semantics. Very similar to the Instagram approach linked below.http://docs.mongodb.org/manual/reference/object-id/http://instagram-engineering.tumblr.com/post/10853187575/sharding-ids-at-instagram
The MIT License (MIT)
Copyright (c) 2013 Jamar Parris
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE S