layout: post title: "Qiita APIで自動投稿" date: 2013-01-23 23:41 comments: true published: true qiita: tags: - name: ruby versions:
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 | |
require 'csv' | |
class Level | |
attr_reader :key, :parent, :bytesize, :total_bytesize, :children | |
def initialize parent, key, bytesize = 0 | |
@parent = parent | |
@key = key |
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 | |
IMAGE=${IMAGE:-alpine:3.7} | |
TARGET_VOLUME=$1 | |
if [ -z ${TARGET_VOLUME} ]; then | |
echo "Usage $0 <volume name>" | |
exit 1 | |
fi |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 | |
require 'uri' | |
require 'net/http' | |
require 'cgi' | |
require 'nokogiri' | |
EM_URL = URI.parse('http://encodemaniax.com') | |
def build_query data, charset='utf-8' |
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
target_pid = ARGV[0].to_i | |
target_yo_user = ARGV[1].upcase | |
threshold_cpu = (ARGV[2] || 50).to_i | |
sampling_times = (ARGV[3] || 3).to_i | |
sleep_sec = (ARGV[4] || 1).to_i | |
puts "watching #{target_pid}..." | |
puts " - Target YO User: #{target_yo_user}" | |
puts " - Threshold of CPU Usage: #{threshold_cpu}%" | |
puts " - Sampling times: #{sampling_times}" | |
puts " - Sleep Seconds: #{sleep_sec}s" |
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
yo="curl -X POST -d username=$USERNAME -d api_token=$APITOKEN https://api.justyo.co/yo/" | |
until nslookup rubygems.org && nslookup bb-m.rubygems.org && $yo; do echo "fail..."; sleep 1; done |
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
RSpec.configure do |config| | |
next unless ENV['BENCHMARK'] == '1' | |
benchmarks = [] | |
metadata_keys = %i[ file_path line_number described_class ] | |
info_keys = %i[ type ] + metadata_keys + %i[ full_description ] | |
log_file = Rails.root.join('log', 'rspec_benchmark.csv') | |
config.before(:suite) do | |
CSV.open(log_file, "wb") do |csv| | |
csv << info_keys + %i[ utime stime cutime cstime real] | |
end |
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
module Capturable | |
EXCLUDE_METHODS = [:class, :send, :respond_to?, :capture_methods, :__send__, :__id__] | |
def self.included(base) | |
base.class_eval do | |
def self.capture_methods options={} | |
method_list = options[:method_list] | |
exclude_methods = options[:exclude_methods] || [] | |
exclude_regexp = options[:exclude_regexp] || /\A_/ | |
source_root = case options[:source_root] |
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
task("pre:compile", function(event,logger) { | |
var wrench = require("wrench"), | |
fs = require("fs"), | |
jade = require("jade"), | |
view_root = event.dir.views, | |
path = require("path"), | |
coffee = require("coffee-script"); | |
event.alloyConfig.xml = []; | |
event.alloyConfig.coffee = { home: [], resources: [] }; |
NewerOlder