Skip to content

Instantly share code, notes, and snippets.

@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();
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 / analytics_popular_posts.html
Created April 5, 2013 09:56
custom/asides/analytics_popular_posts.html
@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 / 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 / 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 / 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 <[email protected]>
*/
class SourceFile
# 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 / DirectoryStructure
Last active September 26, 2021 20:03
Directory structure of Domain Driven Design application with Symfony2, Doctrine2.
sf2-ddd
├── app
├── bin
├── build
├── lib
├── src
│   └── __VendorPrefix
│   ├── Application
│   │   └── __DomainNameBundle
│   │   ├── Command
@satooshi
satooshi / DateTime_createFromFormat.php
Last active August 29, 2015 13:56
! in time format.
<?php
$time = '03/2014';
$dt1 = \DateTime::createFromFormat('m/Y', $time); // "2014-03-19 17:14:38"
$dt2 = \DateTime::createFromFormat('!m/Y', $time); // "2014-03-01 00:00:00"
$dt3 = \DateTime::createFromFormat('m/Y!', $time); // "1970-01-01 00:00:00"
$dt4 = \DateTime::createFromFormat('m!/Y', $time); // "2014-01-01 00:00:00"
var_dump($dt1, $dt2, $dt3, $dt4);
/*