Skip to content

Instantly share code, notes, and snippets.

View tiqwab's full-sized avatar

Naohisa Murakami tiqwab

View GitHub Profile
@tiqwab
tiqwab / tetris.c
Created September 6, 2019 10:18
Tetris in C
#include <stdbool.h>
#include <curses.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#define STAGE_ROW 20
@tiqwab
tiqwab / pinky.md
Last active September 6, 2019 10:17
Signed division by 2^n
@tiqwab
tiqwab / openjdk_interpreter.md
Last active August 10, 2019 08:57
short memo for interpreter implementation of OpenJDK11

OpenJDK の interpreter とは

  • Java byte code の interpreter
  • (Java) メソッドはまず interpreter で実行される
  • (条件を満たすと) JIT コンパイルで生成されたネイティブコードを実行する

簡単な Java byte code 例

class Example1 {
@tiqwab
tiqwab / icmp_with_ip_hdrincl.c
Created June 18, 2019 23:46
IP_HDRINCL socketopt
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip_icmp.h>
#include <arpa/inet.h>
#define SEND_BUF_LEN 64
@tiqwab
tiqwab / main.c
Created March 27, 2019 13:12
Brainf**k
#include <stdio.h>
#include <stdlib.h>
static char buf[30000];
static char input[30000];
static int idx = 0;
static char *ptr = buf;
void interpreter(int start);
(for {
conn <- withConnection
currentIssue <- findIssueById(editReq.id)(conn)
_ <- isIssueEditable(currentIssue)(BadRequest)
_ <- updateIssue(editReq.id, editReq.content)
} yield Ok("ok")).run(Future.successful)
@tiqwab
tiqwab / HashPerformance.scala
Created January 11, 2019 03:29
MD5 and SHA-256 with Scala
package example
trait HashPerformance {
def hash(str: String): String
def doCheck(count: Int): Unit = {
val key = "something"
val hashed = hash(key)
println(hashed)
@tiqwab
tiqwab / MyList.scala
Last active December 28, 2018 06:59
Sample collection implementation with Scala 2.13
package com.tiqwab.example.step4
import scala.collection.mutable.ListBuffer
import scala.collection.{immutable, mutable, SeqFactory, StrictOptimizedLinearSeqOps}
class MyList[+A] private (elems: List[A])
extends immutable.LinearSeq[A] with immutable.LinearSeqOps[A, MyList, MyList[A]]
with StrictOptimizedLinearSeqOps[A, MyList, MyList[A]] {
// To be overridden in implementations, as said in scala.collection.LinearSeq
override def isEmpty: Boolean = elems.isEmpty
@tiqwab
tiqwab / MyList.scala
Last active December 22, 2018 02:22
Sample collection implementation to understand CanBuildFrom in Scala 2.12.7
package com.tiqwab.example.step6
import scala.collection.JavaConverters._
import scala.collection.immutable
trait MyBuilder[-Elem, +To] {
def +=(elem: Elem): this.type
def result(): To
}
package sample
import java.io.{BufferedReader, InputStreamReader}
import com.amazonaws.auth.{AWSStaticCredentialsProvider, BasicAWSCredentials}
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration
import com.amazonaws.services.s3.{AmazonS3, AmazonS3ClientBuilder}
import sample.FilePath
import org.scalatest._