Get it from the App Store.
In XCode's Preferences > Downloads you can install command line tools.
# Fix the encoding of a string to ensure it's valid UTF-8 by assuming | |
# the string is valid utf-8 but incorrectly marked. Changes the marker | |
# to UTF-8 then strips any invalid bytes | |
# | |
# It'd be nice if force_encoding had an option to strip invalid bytes in a | |
# single step. Until that's possible, the ugly round trip through UTF-16 is | |
# required. | |
# | |
# non strings are left untouched. | |
# |
#!/usr/bin/env ruby | |
rss = '.+?Rss:\s+(\d+)' | |
share = '.+?Shared_Clean:\s+(\d+)' | |
share << '.+?Shared_Dirty:\s+(\d+)' | |
priv = '.+?Private_Clean:\s+(\d+)' | |
priv << '.+?Private_Dirty:\s+(\d+)' | |
MEM_REGEXP = /\[heap\]#{rss}#{share}#{priv}/m | |
def mem_usage_linux |
# build a dummy http handler that extends the default handler | |
# that outputs the request body before making the request (via super) | |
# then check the response body | |
# req is a AWS::Core::Http::Request object | |
# resp is a AWS::Core::Http::Response object | |
default_handler = AWS.config.http_handler | |
debug_handler = AWS::Core::Http::Handler.new(default_handler) do |req,resp| | |
puts "REQUEST BODY: #{req.body}" | |
super(req,resp) |
# coding: binary | |
# IRC <-> Campfire bridge, set IRC password to SUBDOMAIN:TOKEN and connect to localhost:6667 | |
# Remove special chars/spaces from channel names (ie "Foo Bar" becomes #FooBar). Only tested with LimeChat. | |
# gem install excon && gem install yajl-ruby -v "< 2.0" | |
%w[socket thread uri excon yajl yajl/http_stream].each { |lib| require lib } | |
Thread.abort_on_exception = true | |
[:INT, :TERM].each { |sig| trap(sig) { exit } } | |
server = TCPServer.new('127.0.0.1', 6667) | |
loop do |
# Ruby Thread Pool | |
# ================ | |
# A thread pool is useful when you wish to do some work in a thread, but do | |
# not know how much work you will be doing in advance. Spawning one thread | |
# for each task is potentially expensive, as threads are not free. | |
# | |
# In this case, it might be more beneficial to start a predefined set of | |
# threads and then hand off work to them as it becomes available. This is | |
# the pure essence of what a thread pool is: an array of threads, all just | |
# waiting to do some work for you! |
require 'thread' | |
class Worker | |
def initialize(count = 1) | |
@queue, @closing, @threads, @mutex = Queue.new, false, [], Mutex.new | |
add_worker(count) | |
end | |
def add_worker(count = 1) | |
@mutex.synchronize do |
(The MIT License) | |
Copyright (c) 2012-2020 Myron Marston | |
Permission is hereby granted, free of charge, to any person obtaining | |
a copy of this software and associated documentation files (the | |
"Software"), to deal in the Software without restriction, including | |
without limitation the rights to use, copy, modify, merge, publish, | |
distribute, sublicense, and/or sell copies of the Software, and to | |
permit persons to whom the Software is furnished to do so, subject to |
gem 'sidekiq' | |
gem 'octokit' |
require 'json' | |
require 'fileutils' | |
require 'faraday' | |
email, pass, dir = ARGV | |
if !(email && pass) | |
puts "Pass your CoTweet email/password:" | |
puts | |
puts " $ ruby #{$0} [email protected] sekretpassword [/path/to/dump]" |