This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// インスタグラムのAPI情報 | |
define('TOKEN', 'YOUR_ACCESS_TOKEN'); | |
define('MEDIA_URL', 'https://graph.instagram.com/me/media?fields=id,caption,permalink,media_type,media_url,username&access_token=%s'); | |
// 取得する件数 | |
define('LENGTH', 10); | |
// インスタグラムからデータを取得 | |
$response = json_decode(file_get_contents(sprintf(MEDIA_URL, TOKEN)), true); | |
// 表示する件数に切り取る |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
command1() { | |
echo "executing commnad1" | |
sleep 3 | |
} | |
command2() { | |
echo "executing commnad2" | |
sleep 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 時刻を加算するにはRationalを足す。 | |
# 1分後はRational(1, 24*60) | |
# 8時間45分は525分なのでRational(525, 24*60)を加算すればよい | |
DateTime.now + Rational(525,24*60) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "faraday" | |
username = 'your name' | |
channel = 'your channel' | |
slack_token = 'your slack token' | |
icon_url = 'your icon url' | |
body = { | |
username: username, | |
channel: channel, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# WordPressのアーカイブを作成するスクリプトです。 | |
# 指定されたWordPressのバージョンにSiteGuardプラグインをいれて、アーカイブを作成します。 | |
# | |
# Usage: | |
# ./wordpress.sh version | |
# | |
# Example: | |
# ./wordpress.sh 4.1.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Usage | |
# ./entropy file | |
# echo "aaaaaaaabbbbbbbbbcc" | ./entropy | |
require 'optparse' | |
options = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str="abccddeeeeffffgggggggghhhhhhhh" | |
def entropy(str) | |
count = str.size | |
list={} | |
list.default=0 | |
str.split("").each {|c| list[c]+=1} | |
sum = 0 | |
list.each do |key, val| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text =<<TEXT | |
The example above works as intended because the five instances of the (anonymous) inner function refer to five different instances of variable j. Note that it does not work as intended if you replace let by var or if you remove the variable j and simply use the variable i in the inner function. | |
TEXT | |
result = {} | |
result.default = 0 | |
text.split(" ").map { |a| a.gsub(/\.$/, '').gsub(/\(|\)/, '').downcase }.sort.each { |b| result[b.to_sym]+=1 } | |
p result.sort {|(k1, v1), (k2, v2)| v2 <=> v1 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu | |
MAINTAINER shoyan | |
USER root | |
RUN apt-get update | |
RUN apt-get -y upgrade | |
RUN apt-get -y install build-essential | |
RUN apt-get -y install libxml2-dev | |
RUN apt-get -y install wget |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe "EmailValidator" do | |
before do | |
@validator = EmailValidator.new({:attributes => {email: ''}}) | |
@mock = double("Foo") | |
allow(@mock).to receive(:errors).and_return([]) | |
allow(@mock.errors).to receive(:[]).and_return({}) | |
allow(@mock.errors[]).to receive(:<<) |
NewerOlder