Skip to content

Instantly share code, notes, and snippets.

View aoiroaoino's full-sized avatar
🏠
Working from home

Naoki Aoyama aoiroaoino

🏠
Working from home
View GitHub Profile
@rogerleite
rogerleite / install_monaco_font.sh
Last active April 27, 2024 05:27
Install Monaco font in Linux
#!/bin/bash
# Install Monaco font in Linux
# Version from nullvideo https://gist.github.com/rogerleite/99819#gistcomment-2799386
sudo mkdir -p /usr/share/fonts/truetype/ttf-monaco && \
sudo wget https://gist.github.com/rogerleite/b50866eb7f7b5950da01ae8927c5bd61/raw/862b6c9437f534d5899e4e68d60f9bf22f356312/mfont.ttf -O - > \
/usr/share/fonts/truetype/ttf-monaco/Monaco_Linux.ttf && \
sudo fc-cache
@jimbojsb
jimbojsb / gist:1630790
Created January 18, 2012 03:52
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

def index(id:String) = Action {
getFirstData(id)
}
private def getFirstData(id:String) = {
Cache.get(id) match {
case Some(id2) => getSecondData(id2)
case None => NotFound
}
}
private def getSecondData(id2:String) = {
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@switzer
switzer / gist:4218526
Created December 5, 2012 19:03
Custom Mongodb Serializer/Deserializer
package com.example.core.application
import com.mongodb.casbah.Imports._
import java.util.UUID
import com.example.domain.{User, Address, Customer}
/**
* Contains type classes that deserialize records from Casbah into "our" types.
*/
trait CasbahDeserializers {
@MLnick
MLnick / StreamingHLL.scala
Last active January 24, 2024 19:39
Spark Streaming meets Algebird's HyperLogLog Monoid
import spark.streaming.StreamingContext._
import spark.streaming.{Seconds, StreamingContext}
import spark.SparkContext._
import spark.storage.StorageLevel
import spark.streaming.examples.twitter.TwitterInputDStream
import com.twitter.algebird.HyperLogLog._
import com.twitter.algebird._
/**
* Example of using HyperLogLog monoid from Twitter's Algebird together with Spark Streaming's
@repeatedly
repeatedly / msgpack_issue_121.md
Last active November 30, 2021 02:09
MessagePackが文字列とバイナリをわけないのは問題?

MessagePackが文字列とバイナリをわけないのは問題?

msgpack/msgpack#121

Objective Cの実装使ってるとある問題にぶちあたった.なので,文字列をちゃんとバイナリ(Raw)と分けるべき,という提案

(*) 俺は熟読したわけではないので,中身が気になる人はちゃんと本スレを読みましょう

そもそもMessagePackとは

@gakuzzzz
gakuzzzz / article.md
Last active October 29, 2019 06:19
「Javaで継続モナド」をScalaに翻訳/Scala Advent Calendar 2013

「Javaで継続モナド」をScalaに翻訳

この記事はScala Advent Calendar 2013の7日目の記事です。

昨日は @shogogg さんのScala + sbt-android + IntelliJ で快適Androidアプリ開発でした。

明日は @takezoux2 さんのScalaのParserCombinator実践入門+です。

継続モナドを調べていたら、@terazzo さんのJavaで継続モナドという記事が非常に判りやすかったんですが、サンプルコードがJavaのボイラープレートの嵐でちょっと読むのが辛い感じだったのでScalaで翻訳してみました、というのがこの記事です。

@dsugden
dsugden / StateTLearning.scala
Last active August 29, 2015 13:57
StateT with Option and Either
import scalaz._
import Scalaz._
object StateTLearning extends App with StateTFunctions {
case class DB(v: Int)
val initial = DB(1)
@gakuzzzz
gakuzzzz / 1_.md
Last active June 19, 2023 12:53
trait と abstract class の使い分け

trait と abstract class の使い分け

  • 基本は迷ったら trait にしておけば良いと思います
    • trait は一つの class に複数 mixin できますが、class は一つしか継承できません
    • つまり、trait であれば mixin される class を気にしなくてよいですが、 abstract class にした場合は、extends される class が他に継承したい物が無いか気にする必要があります
  • trait はコンストラクタを持つ事ができませんが、abstract class はコンストラクタを持つ事ができます
    • 従って、型引数に制約をつけたい時や、共通のフィールドの初期化などがある場合は、abstract class にすると楽な場合があります。
  • 以下に具体例を示します。良くある Java の enum を Scala で定義する場合の例です。