Skip to content

Instantly share code, notes, and snippets.

@Snarp
Snarp / tumblr_client_quick_yaml_archive.rb
Created March 8, 2017 18:09
Simple Tumblr backup client using tumblr_client and saving in YAML format, created as an example.
require 'tumblr_client'
require 'fileutils'
require 'yaml'
@client = Tumblr::Client.new({
:consumer_key => "FILL",
:consumer_secret => "THESE",
:oauth_token => "FIELDS",
:oauth_token_secret => "IN"
})
@Snarp
Snarp / sinatra_tumblr_omniauth_example.rb
Created October 1, 2016 01:58
Example of how to use Omniauth to access the Tumblr API in Sinatra.
gem 'sinatra', '~> 1.4.7'
require 'sinatra'
gem 'omniauth-tumblr', '~> 1.2'
require 'omniauth-tumblr'
gem 'tumblr_client', '~> 0.8.5'
require 'tumblr_client'
require 'yaml'
# omniauth-tumblr + tumblr_client + sinatra Example
@Snarp
Snarp / tungle_client.rb
Created July 20, 2016 09:29
Ruby module for backing up/archiving public Tumblr data.
require 'typhoeus'
require 'json'
module TungleClient
EXAMPLE_API_KEY = 'fuiKNFp9vQFvjLNvx4sUwti4Yb5yGutBN4Xh10LXZhhRKjWlV4'
BASE_BLOG_URL = 'https://api.tumblr.com/v2/blog'
BASE_TAG_URL = 'https://api.tumblr.com/v2/tagged'
# NOTE: ssl_verifypeer is turned off here due to eternal font of Windows
@Snarp
Snarp / watir_firefox_mobile_example.rb
Created May 18, 2016 19:22
Working example of how to load the mobile version of a site using watir-webdriver 0.9.1, selenium-webdriver 2.53.0, webdriver-user-agent 7.4, and Firefox 46.0.1. (Version numbers important because Firefox.)
require 'watir-webdriver'
require 'webdriver-user-agent'
# Works as of:
# - watir-webdriver 0.9.1
# - webdriver-user-agent 7.4
# - selenium-webdriver 2.53.0
# - Firefox 46.0.1
# Creates new Firefox profile to bypass Firefox's chronic profile glitches.
@Snarp
Snarp / keypress_toggle_writer.au3
Created May 11, 2016 20:13
AutoIt script which types one line from Kafka's Metamorphosis and then presses enter every 3 seconds; toggle-able using Pause/Break.
#include <FileConstants.au3>
; Pause/Break to "turn on" and "turn off".
; While turned on, writes one line from the text file defined by $FILENAME and then presses "Enter" every $SLEEPFOR millseconds.
; Defaults = Kafka's Metamorphosis, 3 seconds.
;
; If you have never needed to do this, don't worry about it. Just don't worry about it.
Global Const $FILENAME = "metamorphosis.txt"
Global Const $SLEEPFOR = 3000
@Snarp
Snarp / sinatra_tumblr_oauth_example.rb
Last active April 2, 2016 04:04
Example of how to use OAuth to access the Tumblr API in Sinatra.
gem 'sinatra', '~> 1.4.7'
require 'sinatra'
gem 'oauth', '~> 0.5.1'
require 'oauth'
gem 'tumblr_client', '~> 0.8.5'
require 'tumblr_client'
# This is an example of how to use OAuth to access the Tumblr API in Sinatra.
# Based on dcesteri's Twitter example:
# https://github.com/dcestari/sinatra-twitter-oauth-sample