Skip to content

Instantly share code, notes, and snippets.

View k14i's full-sized avatar

kt k14i

View GitHub Profile
@k14i
k14i / bash_exe_-c_sudo_usr_sbin_sshd_-d.ps1
Created February 8, 2017 13:40
A script to run sshd of Bash on Windows quietly at the Windows starting up with a shortcut.
Set-ExecutionPolicy RemoteSigned -Scope Process
Set-Location C:\Windows\System32
Start-Process -FilePath bash -ArgumentList "-c `"sudo /usr/sbin/sshd -D`"" -WindowStyle hidden
@k14i
k14i / benz_and_cigarette.c
Last active August 29, 2015 14:09
「あそこにベンツが停まってますね」 参考: https://twitter.com/syusui_s/status/534548412889178112
#include <stdio.h>
#include <string.h>
#define BUGGY
#define PRICE_BENZ 6000000
#define PRICE_CIGARETTE 42
#define SEQ_1 "「一日何本くらい煙草をお吸いに?」: "
#define SEQ_2 "「%d本ですね」\n"
@k14i
k14i / tmux-pbcopy
Last active August 29, 2015 14:06
tmux-pbcopy
#!/bin/bash
if test x`uname -s` != x'Darwin'; then
exit 0
fi
if test `which reattach-to-user-namespace > /dev/null; echo $?` -ne 0; then
echo 'Error: reattach-to-user-namespace does not found.'
if test `which brew > /dev/null; echo $?` -eq 0; then
echo 'Info: Install reattach-to-user-namespace with homebrew.'
@k14i
k14i / file0.txt
Created December 22, 2013 09:05
ElixirでのMessage Passing入門 ref: http://qiita.com/keithseahus/items/58e9cd53c908dcdb4e76
% iex --sname foo --cookie elixir-example
Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Interactive Elixir (0.11.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(foo@mba11-keith)1>
@k14i
k14i / prime_31.rb
Last active December 27, 2015 11:29
Just to show a prime number of thirty one in a DRY way without any numerics.
# -*- coding: utf-8 -*-
require 'prime'
arr = []
n = Prime.first ** nil.to_i
foo = Proc.new {|x| x.times do n = Prime.first(n).last end }
bar = Proc.new {|x| arr << [[x] * x] }
Prime.first.times do |i| bar.call(Prime.first ** i) end
arr.flatten.map {|x| foo.call(x)}
puts n
@k14i
k14i / invitation_happy_birthday_u1_party_spec.rb
Last active December 27, 2015 11:29
An invitation of an event.
# -*- coding: utf-8 -*-
require 'spec_helper'
require 'prime'
arr = []
n = Prime.first ** nil.to_i
foo = Proc.new {|x| x.times do n = Prime.first(n).last end }
bar = Proc.new {|x| arr << [[x] * x] }
Prime.first.times do |i| bar.call(Prime.first ** i) end
arr.flatten.map {|x| foo.call(x)}
#!/usr/bin/env python
#
# Init script skeleton for Python-based service control scripts
#
# chkconfig: 123456 1 99
# description: My service
#
# Author: Josh Johnson <lionface dot lemonface at gmail dot com>
#
#
@k14i
k14i / etc-init.d-dropbox-debian
Last active January 11, 2020 22:56
An /etc/init.d script for dropbox on Debian.
#!/usr/bin/env bash
# dropbox service
DROPBOX_USERS="" # space-separated usernames
DAEMON=.dropbox-dist/dropbox
NICE=19 # -20 - 19
IONICE_CLASS=3 # 0 - 3
IONICE_PRIOR=7 # 0 - 7
KERNEL=`uname -s`
@k14i
k14i / etc-init.d-dropbox-rhel
Last active December 22, 2015 12:38
An /etc/init.d script for dropbox on RHEL.
#!/usr/bin/env bash
# chkconfig: 345 85 1
# description: Startup script for dropbox daemon
#
# processname: dropboxd
# pidfile: /var/run/dropbox.pid
# config: /etc/sysconfig/dropbox
#
### BEGIN INIT INFO
@k14i
k14i / cloud-client-ui.sh
Created August 25, 2013 16:02
A /etc/init.d script for starting/stopping CloudStack Client UI.
#!/bin/bash
#
### BEGIN INIT INFO
# Provides: cloud-client-ui
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $network $time
# Should-Stop: $network $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6