Skip to content

Instantly share code, notes, and snippets.

View masahitojp's full-sized avatar
🎯
Focusing

Masato Nakamura masahitojp

🎯
Focusing
View GitHub Profile
@knzm
knzm / gist:5185369
Last active December 30, 2020 14:34

Python パッケージングのこれまでとこれから

第1世代: distutils

$ python setup.py build
@sevastos
sevastos / aws-multipartUpload.js
Last active October 8, 2023 10:43
Example AWS S3 Multipart Upload with aws-sdk for Node.js - Retries to upload failing parts
// Based on Glacier's example: http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/examples.html#Amazon_Glacier__Multi-part_Upload
var fs = require('fs');
var AWS = require('aws-sdk');
AWS.config.loadFromPath('./aws-config.json');
var s3 = new AWS.S3();
// File
var fileName = '5.pdf';
var filePath = './' + fileName;
var fileKey = fileName;
@essen
essen / my_module.erl
Created October 14, 2013 03:25
Thinking in Erlang: The Code
-module(my_module).
-export([my_function/1, my_function/2]).
-export([infinite_loop/0, f/1, r/2, sort/1]).
-export([only_primes/1, is_prime/1]).
my_function(A) when is_integer(A) ->
my_function(A, 0);
my_function(A) when is_list(A) ->
my_function(list_to_integer(A), 0).
@dirkraft
dirkraft / build.gradle
Last active June 23, 2017 15:00
A build.gradle project template, which bootstraps all necessary parts of a Java, Maven, IntelliJ project on GitHub with the minimum artifact publishing requirements to Sonatype's Maven central.
/* Root build.gradle for Java, Maven, and IntelliJ with Maven central POM. Assumes GitHub.
You should eventually read through and understand this entire Gradle script. Last tried with IntelliJ 2017.1.
Quick start:
- Copy this file into a directory named for your project.
- Choose one Gradle integration mode. Once chosen, stick to it.
IntelliJ Gradle integration:
- Import the project directory as a Gradle project.
- To change Gradle files, enable auto-synchronize or click the synchronize button in the Gradle panel.
@thomaslee
thomaslee / connection.rs
Created January 17, 2014 07:34
A crappy, unbounded, half-baked, broken connection pool in Rust
use std::clone::Clone;
use std::option::{Option, None, Some};
use std::io::net::ip::{SocketAddr, IpAddr};
use std::io::net::tcp::TcpStream;
use std::io::net::addrinfo::get_host_addresses;
use std::rc::Rc;
pub struct Connection {
addr: SocketAddr,
conn: Rc<TcpStream>
@lestrrat
lestrrat / gist:9104980
Last active August 3, 2017 21:55
ヘビメタ英語を日常で使う風景
@slfritchie
slfritchie / presentation.md
Created March 18, 2014 09:22
Erlang tracing, for the Riak source code reading series, 2014-03-18, Tokyo, Japan

Erlang Tracing: more than you wanted to know

Rough Outline

  • What can be traced?
  • How can trace events be specified?
  • "match specifications": twisty passages, all alike
  • WTF, can I just use DTrace and drink my coffee/beer/whisky in peace?
  • Trace delivery mechanisms: pick one of two
@koron
koron / jquery.gc-helper.js
Last active December 17, 2015 11:05
Remove jQuery related objects when remove elements by DOM API
// jQuery GC Helper - v0.9.5
//
// Copyright (C) 2014 MURAOKA Taro
// Licensed under the MIT license.
(function(global, jQuery) {
var observer;
function callback(mutations) {
@gin0606
gin0606 / shinchoku.coffee
Last active August 29, 2015 13:58
hubot script
# Description:
# 進捗 is the most important thing in your life
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
@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 で定義する場合の例です。