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
//PhantomJS http://phantomjs.org/ based web crawler Anton Ivanov anton.al.ivanov@gmail.com 2012 | |
//UPDATE: This gist has been made into a Node.js module and now can be installed with "npm install js-crawler" | |
//the Node.js version does not use Phantom.JS, but the API available to the client is similar to the present gist | |
(function(host) { | |
function Crawler() { | |
this.visitedURLs = {}; | |
}; | |
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
#Utility replaces all tabs in the source files | |
#Usage: ruby replace_tabs.rb /home/anton/github_workspace/jfunk/src java | |
require 'find' | |
$source_file_default_ext = "java" | |
$tab_default_replacement = " " * 4 | |
def replace_tabs(dir, ext, replacement) | |
Find.find(dir) do |file_path| |
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
#Downloads all the mp3 episode recordings from JavaScript Jabber http://javascriptjabber.com | |
#Assumes that the system 'wget' command is available which is the case on Linux | |
#Episodes will be downloaded to /home/user/JSJabber | |
require 'net/http' | |
def get(uri) | |
response = Net::HTTP.get_response(URI.parse(uri)) | |
if response.code == "301" | |
response = Net::HTTP.get_response(URI.parse(response.header['location'])) | |
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
require 'rubygems' | |
require 'couchrest' | |
require 'couchrest_model' | |
require 'json' | |
server = CouchRest.new | |
class JobOpening < CouchRest::Model::Base | |
use_database "job_openings" |
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
function functionName(func) { | |
var match = func.toString().match(/function\s+([^(?:\()\s]*)/); | |
return match ? match[1] : ""; | |
} | |
/* | |
* Tests | |
*/ | |
var func1 = function(x, y) { |
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
var spawn = require('child_process').spawn; | |
function spawnProcess(dir, cmd) { | |
return (process.platform.toLowerCase().indexOf("win") >= 0) | |
? spawnWindowsProcess(dir, cmd) | |
: spawnLinuxProcess(dir, cmd); | |
} | |
function spawnWindowsProcess(dir, cmd) { | |
return spawn("cmd.exe", ["/c", cmd], {cwd: dir}); |
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
/* | |
* Bulk download of Coursera videos with wget. | |
* | |
* Copyright (c) 2014 Anton Ivanov [email protected] | |
* | |
* 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 |
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
/* | |
* Enhances 'require' from RequireJS with Promises API while preserving its original semantics. | |
*/ | |
(function() { | |
if (!Promise || !require) { | |
return; | |
} |
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
if (!Function.prototype.asMethod) { | |
Function.prototype.asMethod = function() { | |
var self = this; | |
return function(first) { | |
var rest = [].slice.call(arguments, 1); | |
return self.apply(first, rest); | |
} | |
}; |
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
from selenium import webdriver | |
driver = webdriver.Firefox() | |
driver.get("http://www.google.com") | |
driver.quit() |