Skip to content

Instantly share code, notes, and snippets.

Avatar

kt k14i

View GitHub Profile
@k14i
k14i / bash_exe_-c_sudo_usr_sbin_sshd_-d.ps1
Created Feb 8, 2017
A script to run sshd of Bash on Windows quietly at the Windows starting up with a shortcut.
View bash_exe_-c_sudo_usr_sbin_sshd_-d.ps1
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 Aug 29, 2015
「あそこにベンツが停まってますね」 参考: https://twitter.com/syusui_s/status/534548412889178112
View benz_and_cigarette.c
#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 Aug 29, 2015
tmux-pbcopy
View 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.'
View file0.txt
% 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 Dec 27, 2015
Just to show a prime number of thirty one in a DRY way without any numerics.
View prime_31.rb
# -*- 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
View invitation_happy_birthday_u1_party_spec.rb
# -*- 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)}
View init_skeleton.py
#!/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 Jan 11, 2020
An /etc/init.d script for dropbox on Debian.
View etc-init.d-dropbox-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 Dec 22, 2015
An /etc/init.d script for dropbox on RHEL.
View etc-init.d-dropbox-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 Aug 25, 2013
A /etc/init.d script for starting/stopping CloudStack Client UI.
View cloud-client-ui.sh
#!/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