Skip to content

Instantly share code, notes, and snippets.

View kengos's full-sized avatar

Kengo Suzuki kengos

  • Hamamatsu Japan
View GitHub Profile
@bshamric
bshamric / cache.js
Last active January 24, 2021 12:08
I like phantomjs, but it doesn't directly support getting images from webpages without requesting them separately like in casperjs. I went through QTNetworking code in the phantomjs repo until I figured out where the cache was. To use this, have all three files in the same directory. Then modify test.js for whatever you need. Call phantom js wit…
var fs = require('fs');
//this is the path that QTNetwork classes uses for caching files for it's http client
//the path should be the one that has 16 folders labeled 0,1,2,3,...,F
exports.cachePath = '/path/to/phantomjs/cache/data/folder';
//this is the extension used for files in the cache path
exports.cacheExtension = "d";
//the resources that are to be saved
@namakesugi
namakesugi / levenshtein_distance.rb
Created December 24, 2011 15:59
LevenshteinDistance
# coding: utf-8
class LevenshteinDistance
def self.analyze(str1, str2, options = {})
_options = {:insert_cost => 1, :delete_cost => 1, :replace_cost => 1}.merge(options)
# remove Line feed code
x = str1.chomp
y = str2.chomp
return 0 if x == y