This file contains 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
## just some ways to check if a url exists | |
# method 1 - from Simone Carletti | |
require "net/http" | |
url = URI.parse("http://www.google.com/") | |
req = Net::HTTP.new(url.host, url.port) | |
res = req.request_head(url.path) | |
# method 2 - from some kid on the internet | |
require 'open-uri' |
This file contains 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
// this is a rudimentary attempt to implement a slideshow that doesn't saturate downloads with every image upon page load; instead the first slide is embedded in the HTML and loads with the page immediately, the second upon DOM ready, and subsequent upon the advance of each slide; additionally a progress indicator is displayed and slideshow paused if the next slide is still downloading thus preventing displaying partially downloaded images, or missing images entirely | |
var slides = [ // this is an array of the html representing each slide to display, in reverse order starting with the second slide (the first should be in the HTML page, see below); this markup may contain anything (e.g. li, div, captions) and should have corresponding css, but the first img tag is assumed to be the main image which we monitor for its download state | |
'<img src="/path/to/file4.jpg">', | |
'<img src="/path/to/file3.jpg">', | |
'<img src="/path/to/file2.jpg">', | |
]; | |
// callback functions | |
function loadedSlide(){ |
This file contains 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 'rubygems' | |
require 'feedzirra' | |
require 'whenever' | |
=begin | |
Simple script to auto download new torrents from an RSS feed. | |
You can then utilize whenever and create a cronjob to run the | |
script at a specified interval. | |
=end |
This file contains 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
# Author: Joona Lehtomäki <joona.lehtomaki@gmail.com> | |
# Updated: 13.11.2011 | |
# Version: 0.0.1 | |
if (!require("rgdal")) { | |
install.packages("rgdal") | |
} | |
if (!require("raster")) { | |
install.packages("raster") |
This file contains 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
// ==UserScript== | |
// @name LinkBucks.com - Auto redirect | |
// @namespace samleb.github.com | |
// @description Redirect to target URL skipping countdown. | |
// @include http*://*.linkbucks.com/ | |
// ==/UserScript== | |
(function() { | |
var REGEXP = /TargetUrl\s*=\s*([^;\n]*)/, | |
urlLiteral = document.body.innerHTML.match(REGEXP)[1], |
This file contains 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/ruby | |
# script to compare and see what lines are in file1 but not file2 | |
f1 = File.open('file1.txt') | |
f2 = File.open('file2.txt') | |
file1lines = f1.readlines | |
file2lines = f2.readlines |
This file contains 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 "rubygems" | |
require "json" | |
require "net/http" | |
require "uri" | |
uri = URI.parse("http://api.sejmometr.pl/posiedzenia/BZfWZ/projekty") | |
http = Net::HTTP.new(uri.host, uri.port) | |
request = Net::HTTP::Get.new(uri.request_uri) |
This file contains 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 'activesupport' | |
require 'feedzirra' | |
feed = Feedzirra::Parser::RSS.new | |
feed.feed_url = "http://feeds.feedburner.com/gizmodobr?format=xml" # URL from my database | |
feed.last_modified = Time.utc(2012, 1, 1) # Feed from my database | |
entry = Feedzirra::Parser::RSSEntry.new | |
entry.url = "http://feedproxy.google.com/~r/gizmodobr/~3/5YLB2D-K49w/story01.htm" # Last entry URL on my database |
This file contains 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
# Plotting the output of FactoMineR's PCA using ggplot2 | |
# | |
# load libraries | |
library(FactoMineR) | |
library(ggplot2) | |
library(scales) | |
library(grid) | |
library(plyr) | |
library(gridExtra) | |
# |
This file contains 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 | |
# An HTTP/HTTPS/FTP file downloader library/CLI based upon MiniPortile's | |
# HTTP implementation. | |
# | |
# Author: Jon Maken | |
# License: 3-clause BSD | |
# Revision: 2012-03-25 23:01:19 -0600 | |
require 'net/http' | |
require 'net/https' if RUBY_VERSION < '1.9' |