This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"github.com/alexeyco/simpletable" | |
"github.com/google/go-github/v40/github" | |
"github.com/morikuni/failure" | |
"golang.org/x/oauth2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Field(target interface{}, field string, val interface{}) error { | |
targetVal := reflect.Indirect(reflect.ValueOf(target)) // セットするstructのreflect.Valueをとる | |
if targetVal.Kind() != reflect.Struct { | |
return ErrNotStruct | |
} | |
dstVal := targetVal.FieldByName(field) // セットするフィールドのreflect.Valueをとる | |
if !dstVal.IsValid() { | |
return ErrNoSuchField | |
} | |
srcVal := reflect.ValueOf(val) // セットする値のreflect.Valueをとる |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ParseError wraps err with parse error message. | |
func ParseError(err error) error { return errors.Wrap(err, “parse error“) } | |
// WithMessagse wraps err with arbitrary message. | |
func WithMessage(message string) func(err error) error { | |
return func(err error) error { returns errors.Wrap(err, message) } | |
} | |
// Ignore ignores err. | |
func Ignore(_ error) error { return nil } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use self::Either::{Left, Right}; | |
enum Either<E, A> { | |
Left(E), | |
Right(A), | |
} | |
trait Show { | |
fn show(self) -> String; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.language.higherKinds | |
trait Functor[F[_]]{ | |
def fmap[A, B](f: A => B)(fa: F[A]): F[B] | |
} | |
case class FunctorMap[A, B](val f: A => B){ | |
def apply[F[_]: Functor](fa: F[A]): F[B] = implicitly[Functor[F]].fmap(f)(fa) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xml._ | |
import java.io.File | |
object Extract{ | |
def main(args: Array[String]): Unit = { | |
val scaladoc = new File(args(0)) | |
if(scaladoc.exists){ | |
val html = XML.loadFile(scaladoc) | |
val builder = Set.newBuilder[String] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.language.implicitConversions | |
import scala.language.higherKinds | |
trait Functor[F[_]]{ | |
def map[A, B](fa: F[A])(f: A => B): F[B] | |
} | |
trait Monad[F[_]] extends Functor[F]{ | |
def unit[A](a: A): F[A] | |
def flatMap[A, B](fa: F[A])(f: A => F[B]): F[B] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.language.higherKinds | |
trait Functor[F[_]]{ | |
def fmap[A, B](fa: F[A])(f: A => B): F[B] | |
} | |
trait Apply[F[_]] extends Functor[F]{ | |
def apply1[A, B](fa: F[A])(f: A => B): F[B] = fmap(fa)(f) | |
def apply2[A, B, C](fa: F[A])(f: (A, B) => C): F[B => C] = apply1(fa)(a => (b => f(a, b))) | |
def apply3[A, B, C, D](fa: F[A])(f: (A, B, C) => D): F[B => C => D] = apply1(fa)(a => b => c => f(a, b, c)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo platex "$TEXPAD_ROOTFILE" | |
platex "$TEXPAD_ROOTFILE" | |
echo pbibtex "$TEXPAD_ROOTFILE_NO_EXT" | |
pbibtex "$TEXPAD_ROOTFILE_NO_EXT" | |
echo platex "$TEXPAD_ROOTFILE" | |
platex "$TEXPAD_ROOTFILE" | |
echo platex "$TEXPAD_ROOTFILE" | |
platex "$TEXPAD_ROOTFILE" |