As websites become more JavaScript heavy, it's harder to automate things like screenshotting for archival purposes. I've seen examples and suggestions to use PhantomJS for visual testing/archiving of websites, but have run into issues such as the non-rendering of webfonts. I've never tried out Selenium until today...and while I'm not thinking about performance implications yet, Selenium seems far more accurate than PhantomJS...which makes sense since it actually opens a real browser. And it's not too hard to script to do complex interactions: here's an [example of how to log in to Twitter, write a tweet, upload an image, and send a tweet via Selenium and DOM element selection](https://gist.github.com/dannguyen/8a6fa49253c1d6a0eb92
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
var express = require('./') | |
var app = express(); | |
app.use(function(req, res, next){ | |
if (req.is('text/*')) { | |
req.text = ''; | |
req.setEncoding('utf8'); | |
req.on('data', function(chunk){ req.text += chunk }); | |
req.on('end', next); |
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
/// <summary> | |
/// This class is the base for all classes that neds to be bound to | |
/// eg: this.set(ref this._FIELD, value); | |
/// </summary> | |
public class BindableClassBase : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged; | |
/// <summary> | |
/// Sets a property, then fires the PropertChanged Event |
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
/// <summary> | |
/// A command whose sole purpose is to relay its functionality | |
/// to other objects by invoking delegates. | |
/// The default return value for the CanExecute method is 'true'. | |
/// <see cref="RaiseCanExecuteChanged"/> needs to be called whenever | |
/// <see cref="CanExecute"/> is expected to return a different value. | |
/// </summary> | |
public class RelayCommand : ICommand | |
{ | |
private readonly Action _execute; |
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
/* | |
Start from the end of the array | |
If I come across a non zero, | |
move it to before the last known | |
location of a non zero number | |
*/ | |
void rearrangeArray(int[] nums) | |
{ | |
int lastNonZero = nums.length - 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
// These two need to be declared outside the try/catch | |
// so that they can be closed in the finally block. | |
HttpURLConnection urlConnection = null; | |
BufferedReader reader = null; | |
// Will contain the raw JSON response as a string. | |
String forecastJsonStr = null; | |
try { | |
// Construct the URL for the OpenWeatherMap query |
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
// https://superuser.com/questions/480646/how-can-i-delete-all-web-history-that-matches-a-specific-query-in-google-chrome | |
// Visit -> [chrome://history-frame/] to clear all history | |
// Visit -> [chrome://history-frame/#q=SEARCH_TERM] to clear all history with SEARCH_TERM | |
function remove() { | |
var inputs = document.getElementsByTagName('input'); | |
try { | |
for (var i = 0; i < inputs.length; ++i) { | |
if (inputs[i].type == "checkbox"){ | |
inputs[i].checked = true; |
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
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating | |
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel | |
// MIT license | |
(function() { | |
var lastTime = 0; | |
var vendors = ['ms', 'moz', 'webkit', 'o']; |
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 node | |
// Verify the most famous MD5 collision example in JavaScript, using nothing but | |
// built-in Node modules. | |
var crypto = require('crypto'); | |
var ucs2encode = require('punycode').ucs2.encode; | |
var assert = require('assert'); | |
var md5 = function(string) { |