var casper = require('casper').create();
casper.clickWhileSelector = function(selector) {
return this.then(function() {
if (this.exists(selector)) {
this.echo('found link: ' + this.getElementInfo(selector).tag);
this.click(selector);
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 casper = require("casper").create() | |
, url = casper.cli.get(0) | |
, metas = []; | |
if (!url) { | |
casper.echo('Usage: casperjs [url]').exit(); | |
} | |
casper.on('remote.message', function(msg) { | |
console.log(msg); |
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 opts = {headers: {Authorization: "Basic " + require("btoa")("test:test")}}; | |
var c = new (require("kinto-http"))("http://0.0.0.0:8888/v1", opts); | |
var schema = {"type": "object", "properties": {"n": {"type": "number"}}}; | |
var displayFields = ["n"]; | |
c.createBucket("buck") | |
.then(() => c.bucket("buck").createCollection("coll", { | |
data: {schema, displayFields} | |
})) | |
.then(() => { |
A simple CasperJS script to periodically check for a link and process accordingly.
/*jshint strict:false*/
/*global CasperError console phantom require*/
var casper = require('casper').create({
logLevel: "debug",
verbose: 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
phantom.injectJs "casper.js" | |
getLinks = -> | |
links = document.querySelectorAll "h3.r a" | |
Array::map.call links, (e) -> e.getAttribute "href" | |
links = [] | |
casper = new phantom.Casper() | |
casper.start "http://google.fr/", (self) -> |
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 page = require('webpage').create(); | |
var base = phantom.args[0]; | |
var path = phantom.args[1]; | |
var expected = phantom.args[2]; | |
page.onNavigationRequested = function(url, navigationType, navigationLocked, isMainFrame) { | |
console.log('Navigation requested: ' + navigationType + '; ' + url); | |
if (!page.testStarted) { | |
return; | |
} |
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
/** | |
* truncatable - jQuery lightweight text truncation plugin | |
* | |
* Adapted from Philip Beel's code http://theodin.co.uk/blog/development/truncatable-jquery-plugin.html | |
* | |
* Copyright (c) 2010 Nicolas Perriault (http://prendreuncafe.com/blog/) | |
* Copyright (c) 2009 Philip Beel (http://www.theodin.co.uk/) | |
* | |
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) | |
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. |
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
<!DOCTYPE html> | |
<html><meta charset="utf-8"></head> | |
<body> | |
<script> | |
window.navigator.serviceWorker.register("worker.js", {scope: "/"}) | |
.then(reg => console.log("registered", reg)) | |
.catch(err => console.error("service worker error", err)) | |
</script> | |
</body> | |
</html> |
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
Show hidden characters
{ | |
"bold_folder_labels": true, | |
"caret_style": "smooth", | |
"color_scheme": "Packages/User/Flatland Monokai (SL).tmTheme", | |
"default_encoding": "UTF-8", | |
"detect_slow_plugins": false, | |
"draw_minimap_border": false, | |
"draw_white_space": "all", | |
"ensure_newline_at_eof_on_save": true, | |
"fade_fold_buttons": 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
(defn default-hash-map [default keys] | |
(into {} (map #(hash-map % default) (seq keys)))) | |
;; user> (default-hash-map 0 [:a :b]) | |
;; {:a 0, :b 0} |