Skip to content

Instantly share code, notes, and snippets.

View k14i's full-sized avatar

kt k14i

View GitHub Profile
#!/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 / 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
@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 / aa.sh
Created August 10, 2013 18:28
Convert an image file into an ascii art and show it in the terminal. This script requires netpbm.
#!/usr/bin/env bash
if [ $# -ne 1 ]; then
exit 1
fi
filetype=`file -b "$1" | awk '{print $1}'`
if [ x$filetype == x ]; then
msg="ERROR: Could not determine the file type of \"$1\""
@k14i
k14i / cloudstack.sh
Last active January 11, 2020 22:56
CloudStack API client shell script.
#!/usr/bin/env bash
ADDRESS="https://"
API_KEY=""
SECRET_KEY=""
USE_XMLLINT=0 # true => 1, false => 0
if [ x$ADDRESS == x ] || [ x$API_KEY == x ] || [ x$SECRET_KEY == x ] || [ x$USE_XMLLINT == x ]; then
echo 'ERROR: Set all required valiables.'
exit 1
@k14i
k14i / delete_dropbox-conflicted-copies.sh
Created August 10, 2013 17:32
Delete all conflicted copies on your Dropbox.
#!/usr/bin/env bash
DROPBOX_PATH="$HOME/Dropbox"
PREEXEC='sudo'
DUSTBOX='/tmp/rm'
DELETE_METHOD="$PREEXEC mv {} $DUSTBOX"
mkdir -p $DUSTBOX
$PREEXEC find $DROPBOX_PATH -name '*conflicted copy*' -exec $DELETE_METHOD \;
@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 / 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)}