Skip to content

Instantly share code, notes, and snippets.

@khrome
khrome / gist:7d87534748545f576fd2
Last active September 16, 2023 17:33
__dirname in the browser
(function(){ //make __dirname, __filename work in the browser
if(window && !window['__dirname']){
var stackTrace = function () {
var lines = (new Error()).stack.split("\n");
// 0 = message, 1 = stackTrace
lines.shift(); lines.shift();
var result = lines.map(function(line){
if(line.indexOf('(native)') != -1){
return {
@everpeace
everpeace / Why People Want Microservices.md
Last active November 8, 2022 10:37
マイクロサービス化が進む背景について考えてみた

マイクロサービス化が進む背景について考えてみた

最近マイクロサービスって流行ってますよね。バズってると言ってもいいくらい。

個人的には、「マイクロサービスって結局何なの?」とか、「SOAと何が違うわけ?」とかいう議論は苦手です。

でも「なんでみんなマイクロサービスで作りたいのか?なんでマイクロサービスで作られるサービスが多いのか?」にはすごく興味があるんです。

僕は今、シリコンバレーにある日系SIerの小さな子会社で駐在員をやっていますが、このエリアに居ると、とにかく最近、

「サービス全体が、独立した小さなサービスの集合で構成されるようになってきている」

@prophetgoddess
prophetgoddess / pixelsort.py
Last active November 24, 2023 11:39
Python pixel sorting.
# The MIT License (MIT)
# Copyright (c) 2014 Lycaon (lycaon.me)
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@sonots
sonots / start_server.sh
Last active April 3, 2016 06:56
Gracefully restart unicorn using Server::Starter
start_server --status-file=/path/to/app/log/start_server.stat \
--port=10080 --signal-on-hup=CONT --dir=/path/to/app -- \
bundle exec --keep-file-descriptors unicorn -c config/unicorn.conf.rb config.ru

ECMAScript6th Quiz

Q.1

let func = function() {};
func.name
  1. ""
  2. "func"
@oskar456
oskar456 / bh1750.py
Created June 20, 2015 15:26
BH1750 python library
#!/usr/bin/python2
# vim: expandtab ts=4 sw=4
# Inspired by http://www.raspberrypi-spy.co.uk/2015/03/bh1750fvi-i2c-digital-light-intensity-sensor/
import smbus
import time
class BH1750():
""" Implement BH1750 communication. """
@azu
azu / Incremental DOM.md
Last active July 13, 2022 16:07
Incremental DOM ざっと見たやつ。追記: 初期バージョンのコードなので最新では異なる場合があります。

Incremental DOM

Introducing Incremental DOM — Google Developers — Medium

Reactやvirtual-dom、Glimmer(Ember)などVirtual DOMの実装は色々あるが、これらのVirtual DOM実装には2つの問題がある

  • 既存のテンプレート言語を利用していない(しにくい)
  • モバイルでのパフォーマンス、特にメモリに関しては大きすぎる

これらを解決するためにIncremental DOMと言うものを作っている(WIP)

@chroth7
chroth7 / reactD3rescources.md
Last active December 6, 2017 05:37
React/D3 Resources

React <-> D3 Resources

Thanks for all the stars.

Due to unexpected demand, I move this to a proper github repo, see here: https://github.com/chroth7/reactD3resources

I would very much like to get your PRs there, thank you!

@omarstreak
omarstreak / threadDataManager.js
Created September 10, 2015 17:54
Thread Data Manager example
import Kefir from 'kefir';
class ThreadDataManager {
constructor(){
Kefir.stream(emitter => {this._emitter = emitter; return () => null});
this._threadData = {}; //map from threadID to thread data
}
setThreadData(threadID, data){
this._threadData[threadID] = data;
@voluntas
voluntas / webrtc.rst
Last active June 9, 2024 14:01
WebRTC コトハジメ