Skip to content

Instantly share code, notes, and snippets.

View petitviolet's full-sized avatar
🕶️
😃

petitviolet petitviolet

🕶️
😃
View GitHub Profile
@okapies
okapies / promises-are-functional.md
Last active August 14, 2023 11:44
翻訳: ”命令型のコールバック、関数型のプロミス: Node が逸した最大の機会” by James Coglan

命令型のコールバック、関数型のプロミス: Node が逸した最大の機会

Original: "Callbacks are imperative, promises are functional: Node's biggest missed opportunity" by James Coglan

Translated by Yuta Okamoto (@okapies)

Note

  • 訳者は JavaScript や Node.js に関する専門知識がほとんどありません。識者のツッコミをお待ちしております。「◯◯が分からない」等も歓迎です。
  • 元記事から構成を一部変更しています。また、関数型プログラミングに関する記述のうち、議論の骨子に絡まないものは省略しています。
@abeluck
abeluck / gist:6243306
Last active April 14, 2020 04:43
Local HTTP server to stream an InputStream to MediaPlayer on Android
/**
* This is simple HTTP local server for streaming InputStream to apps which are capable to read data from url.
* Random access input stream is optionally supported, depending if file can be opened in this mode.
*
* from: http://stackoverflow.com/a/9096241
*/
public class StreamOverHttp{
private static final boolean debug = false;
private final Browser.FileEntry file;
@johnynek
johnynek / twophase.scala
Last active October 2, 2020 22:36
A two-phase commit Transaction Monad. See: http://en.wikipedia.org/wiki/Two-phase_commit_protocol
// Run this with scala <filename>
/**
* A Two-phase commit Monad
*/
trait Transaction[+T] {
def map[U](fn: T => U): Transaction[U] = flatMap { t => Constant(fn(t)) }
def flatMap[U](fn: T => Transaction[U]): Transaction[U] =
FlatMapped(this, fn)
@voluntas
voluntas / erlang.rst
Last active October 12, 2021 22:34
Erlang/OTP コトハジメ
@seratch
seratch / getting_started_ja.md
Last active June 5, 2018 02:56
Skinny Framework 1.0 Introduction in Japanese

NOTICE: This is just a draft of Skinny framework introduction (written in Japanese for now). English version will be published soon.

Skinny Framework とは

Logo

https://github.com/seratch/skinny-framework

Skinny Framework は Scala のフルスタックな Web アプリケーション開発フレームワークです。2014/03 を目処に最初の安定バージョン 1.0.0 をリリースするべく精力的に開発しています。(追記: 2014/03/28 に 1.0.0 がリリースされました)

@nolanlawson
nolanlawson / completion-for-gradle.md
Last active April 5, 2024 07:43
Gradle tab completion for Bash. Works on both Mac and Linux.

Gradle tab completion script for Bash

A tab completion script that works for Bash. Relies on the BSD md5 command on Mac and md5sum on Linux, so as long as you have one of those two commands, this should work.

Usage

$ gradle [TAB]
@gakuzzzz
gakuzzzz / 1_.md
Last active August 2, 2023 01:59
Scala の省略ルール早覚え

Scala の省略ルール早覚え

このルールさえ押さえておけば、読んでいるコードが省略記法を使っていてもほぼ読めるようになります。

メソッド定義

def concatAsString(a: Int, b: Int): String = {
  val a_ = a.toString();
  val b_ = b.toString();
@schmmd
schmmd / pre-commit
Created May 7, 2014 16:54
Scalariform Precommit
#!/bin/sh
exec scala -savecompiled "$0" $@
!#
//
// Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
// Modified 2014 AI2 <http://www.allenai.org>
//
// This script will check that the commit is correctly formatted. It only checks files that are to be committed.
// To be run this file should be at `.git/hooks/pre-commit`.
@jrudolph
jrudolph / TestJsonClassHierarchyFormat.scala
Created June 2, 2014 12:21
spray-json: JsonFormat for class hierarchy
import spray.json._
object TestJsonClassHierarchyFormat extends App {
sealed trait Animal extends Product
case class Dog(name: String, age: Int) extends Animal
case class Cat(name: String, catchesBirds: Boolean)extends Animal
import DefaultJsonProtocol._
implicit val dogFormat = jsonFormat2(Dog)
@runarorama
runarorama / gist:a8fab38e473fafa0921d
Last active April 13, 2021 22:28
Compositional application architecture with reasonably priced monads
sealed trait Interact[A]
case class Ask(prompt: String)
extends Interact[String]
case class Tell(msg: String)
extends Interact[Unit]
trait Monad[M[_]] {
def pure[A](a: A): M[A]