Skip to content

Instantly share code, notes, and snippets.

View riaf's full-sized avatar
🏠
Working from home

Keisuke SATO riaf

🏠
Working from home
View GitHub Profile
@riaf
riaf / Cat.php
Created February 22, 2012 14:16
文学的PHP ref: http://qiita.com/items/2730
<?php
class Cat
{
protected $name;
public function getName()
{
return $this->name;
}
@riaf
riaf / fbhealth.php
Created February 2, 2012 04:31
Facebook の API に何かあったときに IRC で通知すると便利じゃないかと思いまして ref: http://qiita.com/items/1976
<?php
require_once 'Net/Socket/Tiarra.php';
$api_uri = 'http://www.facebook.com/feeds/api_status.php';
$db = __DIR__ . '/log.sqlite';
$pdo = new PDO("sqlite:$db");
$tiarra_socket = 'riaf';
$irc_channel = '#nequal@freenode';
$last_row = $pdo->query('SELECT * FROM log ORDER BY created_at DESC')->fetch(PDO::FETCH_ASSOC);
<?php
require_once __DIR__ . '/path/to/src/Selfish/Loader.php';
Selfish\Loader::register();
use Selfish\iCalendar\iCalendar;
use Selfish\iCalendar\Component\Event;
use Selfish\iCalendar\Component\Timezone;
$ical = new iCalendar();
$ical->addComponent(new Timezone);
@riaf
riaf / growl-watch.sh
Created November 28, 2011 09:22
Growl が暴走したら再起動してほしくて ref: http://qiita.com/items/1158
#!/bin/sh
CPU_USAGE=`ps aux | grep Growl.app | sed -e 's/ */ /g' -e 's/ /=/g' -e ' 2d' | cut -d '=' -f 3 | cut -d '.' -f 1`
if [ $CPU_USAGE -gt 20 ]; then
killall Growl
open /Applications/Growl.app
fi
<?php
require_once '/path/to/selfish/src/Selfish/Loader.php';
Selfish\Loader::register();
use Selfish\Service\Redmine\Connection;
use Selfish\Service\Redmine\Issues;
$redmine_connection = new Connection('http://redmine.example.com/');
$redmine_connection->setApiKey('redmine-api-access-token');
// $redmine_connection->setBasicAuth('member', 'password');
@riaf
riaf / gist:1327057
Created October 31, 2011 07:07
clearfix
.clearfix:after {
content: ".";
display: block;
clear: both;
height: 0;
visibility: hidden;
}
.clearfix {
min-height: 1px;
@riaf
riaf / gist:1013905
Created June 8, 2011 06:37
Facebook App Permissions
user_about_me
user_activities
user_birthday
user_checkins
user_education_history
user_events
user_groups
user_hometown
user_interests
user_likes
<?php
if ($_POST) {
return header('Location: tel://xxxxxxxxxxx');
exit();
}
?>
<form action="" method="post" name="telform">
@riaf
riaf / SpacelessHelper.php
Created March 28, 2011 07:00
Spaceless Helper for symfony 1.*
<?php
/**
* spaceless helper
*
* @author Keisuke SATO <[email protected]>
*/
function spaceless()
{
ob_start();
@riaf
riaf / gist:863507
Created March 10, 2011 03:03
カレンダーっぽい感じのあれ
<?php
function getCalendar($date) {
if ($date instanceof DateTime === false) {
$date = new DateTime($date);
}
$sdate = clone $date;
$sdate->modify('first day of');