Skip to content

Instantly share code, notes, and snippets.

View maeharin's full-sized avatar

Hidenori Maehara maeharin

View GitHub Profile
@maeharin
maeharin / cmd_twitter.php
Created April 20, 2012 03:13
view twitter time line at command line (witten by php)
#!/usr/local/bin/php
<?php
$user_id = $argv[1];
if ($user_id) {
$url = 'https://twitter.com/statuses/user_timeline.json?id=' . $user_id;
$tweet = file_get_contents($url);
$tweet = json_decode($tweet);
foreach($tweet as $v) {
echo $v->text . "\n";
@maeharin
maeharin / cmd_yahoo.php
Created April 20, 2012 03:25
view yahoo japan daily news at command line (written by PHP)
#!/usr/local/bin/php
<?php
$url = 'http://rss.dailynews.yahoo.co.jp/fc/rss.xml';
$rss = simplexml_load_file($url);
foreach ($rss->channel->item as $v) {
echo $v->title . "\n";
}
@maeharin
maeharin / show_fb_public_info.html
Created April 22, 2012 13:58
show facebook user's public information (javascript/jQuery)
<html>
<div id="hoge"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
var user_id = 'zuck'; //facebook id
var url = 'https://graph.facebook.com/' + user_id + '?callback=?';
var additional_html;
$.getJSON(url, function (res) {
for(var i in res) {
additional_html += i + ':' + res[i] + '<br>';
@maeharin
maeharin / show_fb_picture.html
Created April 22, 2012 14:32
show picture of another gender facebook friends (javascript.jQuery)
<html lang="ja">
<head>
<script src="http://connect.facebook.net/ja_JP/all.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head>
<body>
<div id="start_section"></div>
<div id="friend_section"></div>
<div id="fb-root"></div>
<script type="text/javascript">
@maeharin
maeharin / show_fb_me.html
Created April 23, 2012 14:06
show facebook user's basic information (javascript/jQuery)
<html lang="ja">
<head>
<script src="http://connect.facebook.net/ja_JP/all.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head>
<body>
<div id="start_section"></div>
<div id="friend_section"></div>
<div id="fb-root"></div>
<script type="text/javascript">
@maeharin
maeharin / practice.py
Created May 11, 2012 10:11
Ruby/Python基礎練習
# -*- coding: utf-8 -*-
#バージョンは、Python 2.7.1
# スカラー
number1 = 3
number2 = 4
result = number1 + number2
print result
# 配列
@maeharin
maeharin / practice.pl
Created May 12, 2012 08:10
perl基礎文法練習(途中)
#perl基礎文法練習(途中)
use strict;
use warnings;
#スカラー
my $number1 = 3;
my $number2 = 4;
my $result = $number1 + $number2;
print $result . "\n";
@maeharin
maeharin / gist:2717784
Created May 17, 2012 09:38
rbenvを使い、ruby1.9.2とrails3.2.3をインストールした

rbenvを使い、ruby1.9.2とrails3.2.3をインストールした

[参考]インストール前の自分の状態

  • Mac OS X 10.7.4
  • デフォルトのruby1.8.7が入っている
  • rails 3.0.8を入れてある
  • rvmでのインストールを試みたが、はまったので、あきらめた

参照したサイト

http://www.oiax.jp/rails/zakkan/rails_3_1_installation_on_macosx.html

@maeharin
maeharin / 00_code_reading.rb
Created November 28, 2012 23:18
Ruby_ソースコードリーディングの武器
# 前提 
# Ruby 1.9.2
# -*- coding: utf-8 -*-
require 'open-uri'
require 'json'
query = "猫 instagr.am"
url = URI.escape("http://search.twitter.com/search.json?q=#{query}&include_entities=true")
res = open(url).read
json = JSON.parse(res)