Skip to content

Instantly share code, notes, and snippets.

@kain-jy
kain-jy / wordpress_publish_action_posting_facebook.php
Created September 27, 2011 18:58
wordpress action snipped for posting facebook page when published any post.
function post_facebook($post_ID){
$thumbnail = wp_get_attachment_image_src ( get_post_thumbnail_id ( $post_ID ));
$thumbnail = $thumbnail[0];
$permalink = get_permalink($post_ID);
$title = get_the_title($post_ID);
$ch = curl_init("https://graph.facebook.com/{FACEBOOK_PAGE_ID}/feed");
@kain-jy
kain-jy / easy_install_in_mac
Created October 26, 2011 11:35
install by easy_install in mac osx snow leopard
sudo ARCHFLAGS='-arch i386 -arch x86_64' easy_install [modules]
@kain-jy
kain-jy / gist:1414455
Created December 1, 2011 06:54
add2home iOS sample
<!DOCTYPE html>
<html>
<head>
<meta lang="ja" />
<meta charset="utf-8" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="width=device-width; height=device-height; initial-scale=1.0; maximum-scale=1.0; user-scalable=no">
<!--touch icon-->
<link rel="apple-touch-icon-precomposed" size="114x114" href="img/apple-touch-icon-114x114.png" />
<link rel="apple-touch-icon-precomposed" size="72x72" href="img/apple-touch-icon-72x72.png" />
@kain-jy
kain-jy / websocket_tornado_redis.py
Created May 28, 2012 00:43 — forked from pelletier/websocket_tornado_redis.py
adapt for newer redis and redis-py
"""
This is a simple example of WebSocket + Tornado + Redis Pub/Sub usage.
Do not forget to replace YOURSERVER by the correct value.
Keep in mind that you need the *very latest* version of your web browser.
You also need to add Jacob Kristhammar's websocket implementation to Tornado:
Grab it here:
http://gist.github.com/526746
Or clone my fork of Tornado with websocket included:
http://github.com/pelletier/tornado
Oh and the Pub/Sub protocol is only available in Redis 2.0.0:
@kain-jy
kain-jy / gist:4138784
Created November 24, 2012 07:28
[phpenv][php-build] php-fpm's init file
#! /bin/sh
#
# run as current user
# > mkdir ~/.phpenv/init
# > vim 5.3.19
#
# before, you should edit php-fpm.conf
# and comment out [www] user and group.
PHP_BASE=$HOME/.phpenv/versions/{version}
@kain-jy
kain-jy / gist:4138864
Created November 24, 2012 08:21
[rails] init script
#!/bin/sh
BASE=$HOME/app
UNICORN_PID=$BASE/tmp/pids/unicorn.pid
case "$1" in
reload)
echo "reload..."
if [ ! -r $UNICORN_PID ] ; then
echo "no pid file found. maybe is no running."
@kain-jy
kain-jy / gist:4138867
Created November 24, 2012 08:23
[rails] unicorn configure
# save config/unicorn.rb
worker_processes 2
working_directory "/home/{project_name}/app"
listen '/home/{project_name}/tmp/unicorn.sock'
stderr_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT'])
stdout_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT'])
preload_app true
@kain-jy
kain-jy / gist:4238790
Created December 8, 2012 05:33
[nginx][config] fuelphp+php-fpm
server {
listen 80;
server_name host.example.com;
charset utf-8;
access_log /var/log/nginx/host.example.access.log main;
error_log /var/log/nginx/host.example.error.log;
index index.php;
@kain-jy
kain-jy / code.py
Created April 6, 2013 11:18
[python] list結合の検証
# coding: utf-8
import profile
#from memory_profiler import profile as mprofile
from random import random
from itertools import chain
data = [[random() for j in xrange(1000)] for i in xrange(1000)]
def add(x,y):
@kain-jy
kain-jy / gist:5432459
Created April 22, 2013 04:34
php 5.4.x build-in server
<?php
if (file_exists($_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'])) return false;
else include($_SERVER['DOCUMENT_ROOT'].'/index.php');