Skip to content

Instantly share code, notes, and snippets.

7shi 7shi

Block or report user

Report or block 7shi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@7shi
7shi / hello1.c
Last active Nov 4, 2015
[VAX]アセンブラでハローワールド
View hello1.c
main() {
write(1, "hello\n", 6);
return 0;
}
@7shi
7shi / macron.vb
Created Oct 12, 2015
[VBA]マクロン変換(Excel)
View macron.vb
Sub マクロン変換()
Dim R As Range
For Each R In Selection
R = Replace(Replace(Replace(Replace(Replace(R, _
"a-", ChrW(&H101)), _
"e-", ChrW(&H113)), _
"i-", ChrW(&H12B)), _
"o-", ChrW(&H14D)), _
"u-", ChrW(&H16B))
Next R
@7shi
7shi / text.md
Last active Mar 15, 2017
アスキードワンゴ編集部 編集長 鈴木嘉平氏 『技術書を出版するには』
View text.md
@7shi
7shi / cont2.hs
Last active Aug 31, 2015
[Haskell] 継続モナドのテスト
View cont2.hs
import Control.Applicative
import Control.Monad.Cont
import Control.Monad.ST
import Control.Monad.Identity
import Data.STRef
-- callCC :: ((a -> m b) -> m a) -> m a
test1 :: Cont r Int
test1 = return 1
@7shi
7shi / cont.hs
Created Aug 19, 2015
[Haskell] 継続モナドによる脱出をEitherモナドで模倣
View cont.hs
import Data.Char
import Control.Monad.Cont
fun :: Int -> String
fun n = (`runCont` id) $ do
str <- callCC $ \exit1 -> do -- "exit1" を定義
when (n < 10) $ exit1 $ show n
let ns = map digitToInt $ show $ n `div` 2
n' <- callCC $ \exit2 -> do -- "exit2" を定義
when (length ns < 3) $ exit2 $ length ns
@7shi
7shi / PhotoAndVideoAcquire.reg
Last active Aug 29, 2015
Windowss 8/8.1/10: カメラの自動再生に「画像とビデオの読み込み」を追加
View PhotoAndVideoAcquire.reg
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\MyMPTPhotoAcquire]
"Action"="画像とビデオの読み込み"
"Provider"="Windows"
"DefaultIcon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,\
00,20,00,46,00,69,00,6c,00,65,00,73,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,\
77,00,73,00,20,00,50,00,68,00,6f,00,74,00,6f,00,20,00,56,00,69,00,65,00,77,\
00,65,00,72,00,5c,00,49,00,6d,00,61,00,67,00,69,00,6e,00,67,00,44,00,65,00,\
76,00,69,00,63,00,65,00,73,00,2e,00,65,00,78,00,65,00,2c,00,30,00,00,00
View 17-225401.scala
def rpn(str: String): Int = rpnPrime(str.split(' ').toList, Nil)
def rpnPrime(str: List[String], stack: List[Int]): Int = (str, stack) match {
case ("+"::t, y::x::zs) => rpnPrime(t, (x + y) :: zs)
case ("-"::t, y::x::zs) => rpnPrime(t, (x - y) :: zs)
case ("*"::t, y::x::zs) => rpnPrime(t, (x * y) :: zs)
case ("/"::t, y::x::zs) => rpnPrime(t, (x / y) :: zs)
case ("%"::t, y::x::zs) => rpnPrime(t, (x % y) :: zs)
case ( n::t, zs) => rpnPrime(t, (n.toInt) :: zs)
case _ => stack.head
View AlgebraCalculation.scala
import scala.language.implicitConversions
sealed trait Expr {
def +(that: Expr): Expr = Add(List(this, that))
def *(that: Expr): Expr = Mul(List(this, that))
def +(that: Int ): Expr = this + N( that)
def -(that: Int ): Expr = this + N(-that)
def *(that: Int ): Expr = this * N( that)
View AlgebraCalculation.scala
import scala.language.implicitConversions
// R is derived from Rational with some fixes.
// https://sites.google.com/site/scalajp/home/documentation/scala-by-example/chapter6
case class R(numer: Int, denom: Int) extends Ordered[R] {
def reduce: R = {
def gcd(x: Int, y: Int): Int = {
if (x == 0) y
else if (x < 0) gcd(-x, y)
View AlgebraCalculation.scala
import scala.language.implicitConversions
// R is derived from Rational with some fixes.
// https://sites.google.com/site/scalajp/home/documentation/scala-by-example/chapter6
case class R(n: Int, d: Int) extends Ordered[R] {
private def gcd(x: Int, y: Int): Int = {
if (x == 0) y
else if (x < 0) gcd(-x, y)
else if (y < 0) -gcd( x, -y)
You can’t perform that action at this time.