Skip to content

Instantly share code, notes, and snippets.

@hiroshiro
hiroshiro / lan_speed_one_liner.fish
Created September 8, 2017 16:52
One liner speed test by ping
function lan_speed_one_liner
set -l host $argv[1]
set -l datasize $argv[2]
printf "password: "
read -l pass
echo $pass | sudo -S ping -c 10 -s $datasize $host | grep avg | cut -d\/ -f5 | awk '{print $1/1000}' | awk '{print 120000/$1}' | awk '{print $1*8/1024/1024"Mbps"}'
end
@hiroshiro
hiroshiro / lan_speed.fish
Created September 8, 2017 16:44
speed test by ping
function lan_speed
set -l host $argv[1]
echo 'host ' $host
set -l size $argv[2]
echo 'size ' $size
set -l count $argv[3]
echo 'count ' $count
@hiroshiro
hiroshiro / random_emoji.fish
Last active July 20, 2017 18:12
random emoji for fish shell
function random_emoji
if count $argv >/dev/null
set emojis $argv
else
set emojis ♨ 🐟 ⚡ 🐳 🗿 🔥 🌻 🎐 🌿 🍷 🌹 🎀 🌺 🌱 🗻 🌼 🎠 🌈 🐝 🌊 🚃 🐧 🌷 🚀 🌙 🎩 🐍 🐞 🌕 🍒 🍎 🍓
end
set emoji $emojis[(math (random)%(count $emojis)+1)]
echo -n " $emoji "
end
fullBrewUpdate(){
brew update
brew cask update
casks=( $(brew cask list) )
for cask in ${casks[@]}
do
# in the first line there is version
current="$(brew cask info $cask | sed -n '1p' | sed -n 's/^.*: \(.*\)$/\1/p')"
@hiroshiro
hiroshiro / socketclient1.py
Last active July 21, 2016 18:10
サイバーセキュリティプログラミングp14~16
# -*- coding: utf-8 -*-
import socket
target_host = "127.0.0.1"
target_port = 8080
# ソケットオブジェクトの作成
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@hiroshiro
hiroshiro / myls.c
Created June 22, 2016 19:15
コマンドls Unixプログラミングp5
#include "include/apue.h"
#include <dirent.h>
int
main(int argc, char *argv[])
{
DIR *dp;
struct dirent *dirp;
if (argc != 2)
@hiroshiro
hiroshiro / sVimrc
Last active November 17, 2018 05:33
sVimrc
let mapleader = ","
let scrollstep = 200
let hintcharacters = "asdgwertzcvbnml";
let homeurl = "https://www.yahoo.co.jp";
unmap "x"
unmap "w"
unmap "t"
map "a" insertMode
map "?" help
map "r" toggleReader
@hiroshiro
hiroshiro / markdown_to_epub.rb
Created March 16, 2016 20:26
メモしたすべてのmarkdownをepubに変える。
#!/usr/bin/ruby
Dir::chdir(File.expand_path("~/Dropbox/memo/markdown"))
Dir::foreach('.') {|f|
s = File.basename(f,'.*')
system("pandoc -o ~/Dropbox/OneDrive/book/memo/#{s}.epub #{f}")
}
@hiroshiro
hiroshiro / coord.c
Created August 5, 2015 21:25
関数プログラミングP58座標変換
/* coord.c
$ gcc -o coord coord.c -W -Wall -Wextra -lm -ansi -pedantic
$ ./coord
(-0.000000,-0.707107)
(-0.707107,0.000000)
(0.000000,0.707107)
(0.707107,-0.000000)
*/
#include <stdio.h>
@hiroshiro
hiroshiro / Makefile.server
Last active August 29, 2015 14:17
LinuxネットワーキングプログラミングバイブルTCP/IPプログラミング入門Chapter01 socket server Makefile
PROGRAM = server
OBJS = server.o
SRCS = $(OBJS:%.o=%.c)
CFLAGS = -g -Wall
LDFLAGS =
$(PROGRAM):$(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(LDLIBS)