Last active
August 29, 2015 14:00
-
-
Save rinx/11471480 to your computer and use it in GitHub Desktop.
ラボにチェックイン・チェックアウトするときにつかうやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
timecard="${HOME}/.timecard" | |
tweetrb="${HOME}/.bin/timecard/tweet.rb" | |
role=$1 | |
today=`date "+%Y/%m/%d"` | |
nowtime=`date "+%H:%M:%S"` | |
if [ ! -f $timecard ]; then | |
touch $timecard | |
fi | |
if [ "$role" = "checkin" ]; then | |
grep $timecard -e $today > /dev/null | |
if [ $? = 1 ]; then | |
echo "$today $nowtime" >> $timecard | |
echo "$today $nowtime" | |
echo "checkin successful!!" | |
ruby $tweetrb checkin "$today $nowtime" | |
else | |
echo "sorry, you're already checked in..." | |
fi | |
elif [ "$role" = "checkout" ]; then | |
grep $timecard -e $today > /dev/null | |
if [ $? = 0 ]; then | |
tmp=`grep $timecard -e $today` | |
tmptoday=`date "+%Y\/%m\/%d"` | |
chrcnt=`grep $timecard -e $today | sed -e 's@[^:]@@g' | wc -c` | |
if [ "$chrcnt" = "3" ]; then | |
sed -e "s/^${tmptoday}.*$//g" $timecard | sed '/^$/d' > ${timecard}_tmp | |
rm $timecard | |
mv ${timecard}_tmp $timecard | |
echo "$tmp $nowtime" >> $timecard | |
echo "$tmp $nowtime" | |
echo "checkout successful!!" | |
ruby $tweetrb checkout "$tmp -> $nowtime" | |
else | |
echo "sorry, you're already checked out..." | |
fi | |
else | |
echo "sorry, you're not checked in today..." | |
fi | |
else | |
echo "invalid arguments" 1>&2 | |
exit 1 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
require 'twitter' | |
CONSUMER_KEY = '' | |
CONSUMER_SECRET = '' | |
ACCESS_TOKEN = '' | |
ACCESS_SECRET = '' | |
client = Twitter::REST::Client.new do |config| | |
config.consumer_key = CONSUMER_KEY | |
config.consumer_secret = CONSUMER_SECRET | |
config.access_token = ACCESS_TOKEN | |
config.access_token_secret = ACCESS_SECRET | |
end | |
if ARGV[0] == "checkin" then | |
client.update("三( っ'ヮ'c)<ラボに入室しました!さて,進捗進捗!✧*。ヾ(。>﹏<。)ノ゙。*✧ [#{ARGV[1]}]") | |
client.update_profile(body={:location => "らぼ"}) | |
elsif ARGV[0] == "checkout" then | |
client.update("(っ>ω<c)<ラボを退出しました!きょうもいちにちおつかれさまですっ三ヾ(⌒(_*'ω'*)_ [#{ARGV[1]}]") | |
client.update_profile(body={:location => "notらぼ"}) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment