Skip to content

Instantly share code, notes, and snippets.

@satooshi
satooshi / docker introduction
Last active December 24, 2016 05:40
docker introduction
mkdir mydockerbuild
cd mydockerbuild
vi Dockerfile
FROM library/ubuntu:16.04
RUN apt-get -y update && apt-get install -y build-essential git silversearcher-ag python libssl-dev
CMD date
docker build -t echo-date .
docker images
@satooshi
satooshi / VietnameseUnicodeNormalizationFormCAndD.php
Last active January 18, 2016 09:52
Get NFC and NFD string of Vietnamese characters.
<?php
# http://www.unicode.org/charts/PDF/U1E00.pdf
$targets = [
'aắằặấầẩậẳẵạàáâãảăẫ',
'eẽẹếềểễệèéêẻ',
'oốồổỗộờởơớỡòóôõỏọợ',
'iịìíĩỉ',
'uứừửưữựụùúũủ',
'yỳỷỹỵý'
# workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.php.ui.prefs
eclipse.preferences.version=1
cleanup.remove_trailing_whitespaces_all=true
cleanup.remove_trailing_whitespaces=true
cleanup.remove_trailing_whitespaces_ignore_empty=false
editorColorPhpdoc=\#e10071 | | true | false | false | false
editorColorKeyword=\#0000a0 | null | true | false | false | false
editorColorString=\#004000 | null | false | false | false | false
@satooshi
satooshi / coveralls.php
Created April 12, 2013 16:08
I wrote PHP library for Coveralls. https://github.com/satooshi/php-coveralls PHP script for Coveralls. clover.xml generated by PHPUnit is required to get coverage data. And repo_token for Coveralls repository is required for API access.
<?php
// data
/**
* Data represents "source_files" element of Coveralls' "json_file".
*
* @author Kitamura Satoshi <with.no.parachute@gmail.com>
*/
class SourceFile
@satooshi
satooshi / twig.sh
Created April 12, 2013 09:20
php-build plugin for twig extension. put this script into /path/to/php-build/plugins.d/twig.sh
#!/usr/bin/env bash
# PHP.next Development releases depend on current XDebug development
# snapshots.
function install_twig_master {
local source_dir="$TMP/source/twig-master"
local cwd=$(pwd)
local revision=$1
if [ -d "$source_dir" ] && [ -d "$source_dir/.git" ]; then
@satooshi
satooshi / Rakefile
Created April 10, 2013 11:25
pubsub task to notify to Hub server.
desc "notify to PuSH Hub server"
task :pubsub do
require 'net/http'
require 'uri'
hub_url = "http://satooshi.superfeedr.com" # <--- replace this with your hub
atom_url = "http://blog.satooshi.jp/atom.xml" # <--- replace this with your full feed url
resp, data = Net::HTTP.post_form(URI.parse(hub_url),
{'hub.mode' => 'publish',
'hub.url' => atom_url})
@satooshi
satooshi / atom.xml
Created April 10, 2013 11:23
atom.xml applied for PubSubHubbub protocol.
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[{{ site.title }}]]></title>
<link href="{{ site.url }}/atom.xml" rel="self"/>
<link href="{{ site.url }}/"/>
{% if site.hub_url %}<link href="{{ site.hub_url }}" rel="hub"/>{% endif %}
<updated>{{ site.time | date_to_xmlschema }}</updated>
<id>{{ site.url }}/</id>
<author>
@satooshi
satooshi / analytics_popular_posts.html
Created April 5, 2013 09:56
custom/asides/analytics_popular_posts.html
require 'flickraw'
def get_views_in_set(photoset_id)
FlickRaw.api_key = ENV["FLICKR_KEY"]
FlickRaw.shared_secret = ENV["FLICKR_SECRET"]
# flickr.photosets.getPhotos
# http://www.flickr.com/services/api/flickr.photosets.getPhotos.html
# http://www.flickr.com/services/api/explore/flickr.photosets.getPhotos
photos = flickr.photosets.getPhotos(:photoset_id => photoset_id, :extras => "views,original_format,path_alias")
@satooshi
satooshi / hatena_diary2markdown.php
Created February 28, 2013 14:48
Convert movable type text exported from hatena diary to markdown.
<?php
// decoder
function decodePost($data)
{
$lines = explode("\n", $data);
$readMeta = true;
$post = array();
$body = array();