Skip to content

Instantly share code, notes, and snippets.

@mapyo
mapyo / matome_img.php
Last active December 11, 2015 19:28
まともサイトの画像&リンクをとって来て、htmlファイルにまとめてしまうやつ。
<?php
//URLは画像とリンクを取得したいURLを入れてください。
$url="http://matome.naver.jp/odai/2127242472660703301";
$res=@file_get_contents($url);
while($res){
$data=getData($res);
for($i=0; $i<count($data["span"]); $i++){
echo "<a href='" . $data["span"][$i]->a["href"] . "'>\n";
echo "<img src='".$data["image"][$i]["src"]."'>\n";
@mapyo
mapyo / gist:6075465
Created July 24, 2013 23:10
隣の人のソースをforkして公開用に結構いろいろいじったbot
# coding: utf-8
require 'date'
require 'cinch'
class HogehogeBot
include Cinch::Plugin
@@reviewer="誰かな"
@mapyo
mapyo / error.txt
Created July 3, 2014 00:57
scalaをvimのquickrunで実行した時のエラーとその解決方法。
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Error occurred during initialization of VM
java.nio.charset.IllegalCharsetNameException:
at java.nio.charset.Charset.checkName(Charset.java:273)
at java.nio.charset.Charset.lookup2(Charset.java:458)
at java.nio.charset.Charset.lookup(Charset.java:437)
at java.nio.charset.Charset.defaultCharset(Charset.java:579)
at sun.nio.cs.StreamEncoder.forOutputStreamWriter(StreamEncoder.java:37)
at java.io.OutputStreamWriter.<init>(OutputStreamWriter.java:94)
at java.io.PrintStream.<init>(PrintStream.java:100)
@mapyo
mapyo / rbenv
Created September 13, 2014 00:11
rbenvをシステムワイドにインストールするpuppet書いた
class dev::rbenv {
file { ['/usr/local/rbenv',
'/usr/local/rbenv/plugins',
'/usr/local/rbenv/shims',
'/usr/local/rbenv/versions']:
ensure => directory,
owner => 'vagrant',
group => 'vagrant',
mode => '0775',
require 'date'
require 'cinch'
START_TIME = Time.now
$count = 0
class KasumiBot
include Cinch::Plugin
timer 60, method: :check
@mapyo
mapyo / gist:21c686b31a3ccd674649
Created October 27, 2014 23:55
rbenv.shを/etc/profile.dに置いて、それをsourceコマンドで読み込ませる。
file { 'rbenv/profile.d/rbenv.sh':
path => '/etc/profile.d/rbenv.sh',
content => '## rbenv setting
export RBENV_ROOT="/usr/local/rbenv"
export PATH="/usr/local/rbenv/bin:$PATH"
eval "$(rbenv init -)"
',
require => Exec['clone rbenv']
}
~>
@mapyo
mapyo / Guzzle3PasswordGrantSample.php
Created November 1, 2014 16:15
Resource Owner Password Credentials Grant を Guzzle3を使って書いたサンプルです。
<?php
require 'vendor/autoload.php';
use Guzzle\Http\Client;
use CommerceGuys\Guzzle\Plugin\Oauth2\GrantType\PasswordCredentials;
$settings = parse_ini_file('config/settings.ini');
# Resource Owner Password Credentials Grant
$oauth2Client = new Client($settings['base_url'] . '/oauth/token');
@mapyo
mapyo / guzzle3PasswordGrantSample2.php
Created November 1, 2014 16:51
Guzzleのoauth2のプラグインを使わずに書いたやつ。
<?php
require 'vendor/autoload.php';
use Guzzle\Http\Client;
$settings = parse_ini_file('config/settings.ini');
# Resource Owner Password Credentials Grant
$client = new Client($settings['base_url']);
$params = array(
@mapyo
mapyo / Guzzle3Test2.php
Created November 3, 2014 08:21
Guzzle3のgetとputのサンプル
<?php
require 'vendor/autoload.php';
use Guzzle\Http\Client;
$settings = parse_ini_file('config/settings.ini');
$client = new Client($settings['base_url']);
$client->setDefaultOption('headers',
array(
@mapyo
mapyo / file0.php
Created November 3, 2014 13:27
Guzzle3でgetしたりputしたりする ref: http://qiita.com/mapyo/items/c609b9cbaaeb46bc69cf
<?php
require 'vendor/autoload.php';
use Guzzle\Http\Client;
$settings = parse_ini_file('config/settings.ini');
$client = new Client($settings['base_url']);
$client->setDefaultOption('headers',
array(