Skip to content

Instantly share code, notes, and snippets.

💭
I may be slow to respond.

Kuniwak Kuniwak

💭
I may be slow to respond.
View GitHub Profile
View ack-sed
#!/usr/bin/env ruby
if ARGV.size != 3
puts "usage: ack-sed <pattern> <replace-string> <dir>"
end
query, replace, dir = ARGV
system("ack #{query} #{dir} | cut -d':' -f1 | uniq | LANG=C xargs sed -i -e 's/#{query}/#{replace}/g'")
View .vimrc
if has("gui_running")
set fuoptions=maxvert,maxhorz
au GUIEnter * set fullscreen
endif
View codegolf_circle_75.js
for(s='',x=y=n=40;y+n;s+='-*\n'[x+n?x*x--+y*y<900|0:(x=n,y-=2,2)]);return s
@rch850
rch850 / irc.sh
Created Sep 27, 2013
シェルスクリプトからIRCで発言
View irc.sh
#!/bin/sh
nc -w 10 $IRC_SERVER 6667 << EOF &>/dev/null
PASS $IRC_PASS
NICK $IRC_NICK
USER $IRC_NICK 8 * : $IRC_NICK
JOIN $IRC_CH
PRIVMSG $IRC_CH : $1
QUIT
EOF
View 絶望しかない.java
Set<String> keys = map.keySet();
for (String key : keys) {
//some condes
}
//↑が↓になった
Set<String> keys = map.keySet();
String[] keyarray = keys.toString().split(",");
for(int i=0; i<keyarray.length; i++){
@taiki45
taiki45 / fizzubzz.hs
Created Dec 17, 2013
http://bugrammer.hateblo.jp/entry/2013/12/15/220418 を読んで、こう書けばモーナド♡って気持ち、表現できたのではとおもってみたりでし
View fizzubzz.hs
fizz x = if x `mod` 3 == 0 then Left "fizz" else Right x
buzz x = if x `mod` 5 == 0 then Left "buzz" else Right x
fizzbuzz x = if x `mod` 15 == 0 then Left "fizzbuzz" else Right x
number x = Left $ show x
doFizzBuzz x = either id id $ fizzbuzz x >>= buzz >>= fizz >>= number
main = foldr1 (>>) $ fmap putStrLn (fmap doFizzBuzz [1..])
View return_if.rb
class Binding
def return_if(name)
eval "return #{name}" if local_variable_get(name)
end
end
def foo(v)
binding.return_if(:v)
'v is nil'
end
View OnePlusOneIsTwo.swift
class Number {}
class Zero : Number {}
class Succ<N:Number> : Number {}
typealias One = Succ<Zero>
typealias Two = Succ<Succ<Zero>>
typealias Three = Succ<Succ<Succ<Zero>>>
class Eq<S: Number, T: Number> {}
class Add<S: Number, T:Number> : Number {}
View value-witness-table.cpp
// swift/stdlib/public/runtime/Metadata.cpp をプリプロセッサのみ実行した結果から抜粋
struct ValueWitnessTable;
namespace value_witness_types {
typedef OpaqueValue * (*initializeBufferWithCopyOfBuffer) (ValueBuffer *, ValueBuffer *, const Metadata *);
typedef void (*destroy) (OpaqueValue *, const Metadata *);
typedef OpaqueValue * (*initializeWithCopy) (OpaqueValue *, OpaqueValue *, const Metadata *);
typedef OpaqueValue * (*assignWithCopy) (OpaqueValue *, OpaqueValue *, const Metadata *);
typedef OpaqueValue * (*initializeWithTake) (OpaqueValue *, OpaqueValue *, const Metadata *);
View bad-conv-report.md
func c(_ g: @escaping (Int) -> Void) {}

func a() {
    let f: ((Int) -> Void) -> Void
    
    f = { (g) -> Void in
        c(g)
    }
}
You can’t perform that action at this time.