Skip to content

Instantly share code, notes, and snippets.

View marihachi's full-sized avatar

marihachi marihachi

View GitHub Profile
@saiten
saiten / radiru.txt
Created September 1, 2011 09:02
らじるらじるをrtmpdumpで録音する
# RTMPEのtype9 handshakeに対応している必要があるのでRTMPDump v2.4必須
# CentOS5 32bitのさくらVPS、OSX Lionで動作確認。(OSX LionではRTMPDumpを32bitでビルド)
# ラジオ第1
rtmpdump --rtmp "rtmpe://netradio-r1-flash.nhk.jp" \
--playpath 'NetRadio_R1_flash@63346' \
--app "live" \
-W http://www3.nhk.or.jp/netradio/files/swf/rtmpe.swf \
--live \
-o r1.m4a
@rosylilly
rosylilly / gist:3401612
Created August 20, 2012 06:40
先輩と覚える HTTP ステータスコード

先輩に学ぶ HTTP Status Code

超雑にまとめました。修正してください。

登場人物

  • アプリケーション先輩: いつも忙しい。横に広がるのが得意(デブじゃない)。
  • 後輩: 頼んでばっかしで役に立たない。
  • サーバー先輩: アプリケーション先輩と仲がいい。Unix Socket でつながるくらい仲良し。
  • プロクシ先輩: アプリケーション先輩とかサーバー先輩と後輩の間を取り持って代わりに伝えたりしてくれる。たまに勝手にレスポンスを書き換える。
/*
* Simple MD5 implementation
*
* Compile with: gcc -o md5 -O3 -lm md5.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
@sunaot
sunaot / exception.md
Created August 2, 2013 09:13
例外設計の話

例外設計の話。

こんな指針がいいのかなー 2013 夏 ver.

例外の目的とは?

.NET の「例外のデザインのガイドライン」にもこう書いてある。

@dmajda
dmajda / gist:7688943
Created November 28, 2013 08:49
Simple PEG.js grammar to parse a markup language with nested elements (like XML)
Content =
(Element / Text)*
Element =
startTag:StartTag content:Content endTag:EndTag {
if (startTag != endTag) {
throw new Error(
"Expected </" + startTag + "> but </" + endTag + "> found."
);
}
@you21979
you21979 / loadbalance.md
Last active May 10, 2019 01:21
Websocketのロードバランス

Websocketのロードバランス戦略

問題

websocketに対応していないロードバランサを使うといくつか問題が起きる

  • upgradeヘッダを捨ててしまい接続できない(L7スイッチなど)
  • ポート番号枯渇により新規接続ができなくなる
  • タイムアウトの設定が短いと定期的に切断されてしまう
@danharper
danharper / CancellationTokenSource.js
Last active January 7, 2024 17:58
JavaScript "CancellationToken" for cancelling Async/Promise functions
const CANCEL = Symbol();
class CancellationToken {
constructor() {
this.cancelled = false;
}
throwIfCancelled() {
if (this.isCancelled()) {
@biogeo
biogeo / indentation.pegjs
Created March 23, 2017 17:55
"Offside rule" indentation parsing with PEG.js
// Parse a document using "offside rule" indentation (as in Python) into lines
// grouped by indentation level, using PEG.js.
// Attempts to segregate the "stateful" rules from the other production/parsing
// rules by "disallowing" indentation-level-sensitive rules from consuming any
// text.
{ var margin_stack = [""]; }
Document
= content: Element+
@xreiju
xreiju / montecarloPi.d
Created May 7, 2017 02:36
Calculate Pi with Monte Carlo Method in D
import std.stdio, std.random, std.math;
const POINT_AMOUNT = 1000;
struct Point {
real x, y;
bool isInCircle() {
real num = pow(x, 2) + pow(y, 2);
return num <= 1;
}
@betaEncoder
betaEncoder / STM32_programming_tips.md
Last active September 22, 2020 15:03
Tips for STM32 self programming

STM32のFlashメモリを書き換える時のメモ

アプリケーションによっては,製品出荷時にユニークなIDを記憶させたり,キャリブレーション値を保持する時にMCU内蔵のEEPROMへデータを書き込む事があります.
しかしながら,STM32シリーズのチップにはEEPROMがありません.どうやらFlashメモリをEEPROMのように書き換えて使う想定のようです.

Flash特有の懸念

FLASHメモリと言えば書き換え可能な回数が限られており,頻繁な書き換えは信頼性の低下が懸念されます.
そこでデータシートを参照してみると,最低でも1万回の書き換えが保証されているようでした.   これならループを回して書き換えたりしない限り,メモリの劣化は考えなくても良さそうです.
懸念はそれだけではありません.Flashメモリは1バイトづつ書き込む事はできるものの,消去はセクタ単位での一括消去となります.故に,書き換える場合には以下の手順が必要です.