Skip to content

Instantly share code, notes, and snippets.

View robsalasco's full-sized avatar
🏠
Working from home

Roberto Salas robsalasco

🏠
Working from home
View GitHub Profile
@murdoch
murdoch / check-uri.rb
Created August 24, 2011 16:51
Check if uri exists
## 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'
@metaspatial
metaspatial / jquery.cycle.lazy.js
Created September 21, 2011 10:29
Lazy-loading slideshow with jquery.cycle
// 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(){
@danishkhan
danishkhan / torrents_rss_downloader.rb
Created October 11, 2011 07:03
Script to automatically download torrents from an RSS feed
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
@jlehtoma
jlehtoma / wms_proto.R
Created November 13, 2011 20:01
Prototype for accessing WMS from R
# 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")
@samleb
samleb / linkbucks.user.js
Created January 17, 2012 21:40
[userscript] LinkBucks: Redirect to target URL skipping countdown
// ==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],
@rymawby
rymawby / compare_lines.rb
Created January 20, 2012 15:34
Ruby script to compare two text files - analysed what lines exist in file1 that do not in file2.
#!/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
@timsavery
timsavery / Ruby Download Parse JSON
Created January 22, 2012 15:19
Example For Downloading and Parsing JSON (Ruby)
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)
@fabianoalmeida
fabianoalmeida / gist:1675767
Created January 25, 2012 10:32
Update entries from Feedzirra
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
@benmarwick
benmarwick / ggFactoPlot.R
Created March 20, 2012 18:49
FactoMineR PCA plot with ggplot2
# Plotting the output of FactoMineR's PCA using ggplot2
#
# load libraries
library(FactoMineR)
library(ggplot2)
library(scales)
library(grid)
library(plyr)
library(gridExtra)
#
@jonforums
jonforums / download.rb
Created March 26, 2012 01:15
Ruby HTTP/HTTPS/FTP file downloader
#!/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'