Skip to content

Instantly share code, notes, and snippets.

@ynonp
ynonp / test.js
Created July 18, 2013 10:43
casper test poc
casper.options.verbose = true;
casper.options.logLevel = 'error';
casper.options.waitTimeout = 5000;
casper.on('error', function(err) {
this.echo('----> ERROR <----');
});
casper.test.begin('Testing errors', function(test) {
var url = 'http://www.ynonperek.com/static/test.html';
var Product = function(name, price) {
this.price = price;
this.name = name;
this.apply_discount = function(pct) {
this.name *= (1-pct);
};
};
var p1 = new Product('foo', 20);
@ynonp
ynonp / app.html
Last active December 20, 2015 08:58
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
.page { display: none }
.active.page { display: block }
</style>
</head>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<svg id="container"></svg>
<script src="http://cdnjs.cloudflare.com/ajax/libs/d3/3.0.1/d3.v3.min.js"></script>
@ynonp
ynonp / Contacts.pm
Last active May 6, 2019 15:48
advanced perl
package Contacts;
use strict;
use warnings;
use v5.16;
sub init {
my $book_ref = {};
return $book_ref;
}
sub add_contact {
@ynonp
ynonp / data.cpp
Last active December 22, 2015 14:48
void PuzzleWidget::mouseMoveEvent(QMouseEvent *event)
{
// ...
QByteArray src;
QDataStream io(&src, QIODevice::WriteOnly);
io << data;
mime->setData("myapp/data", src);
// ...
}
@ynonp
ynonp / db.cpp
Created September 11, 2013 15:48
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL", "products");
bool ok = db.open();
#include "typer.h"
#include <QDebug>
Typer::Typer(QObject *parent) :
QObject(parent)
{
m_text = "The quick brown fox jumps over the lazy dog";
m_idx = 0;
}
@ynonp
ynonp / data.js
Created September 23, 2013 06:47
(function(global, $) {
function PersonalData() {
var numRetries = 3;
var sendData = function() {
$.ajax({
url: '/api/data',
type: 'POST',
error: function(err) {
@ynonp
ynonp / test.js
Created September 23, 2013 07:04
var testRetryCounter = 0;
var assert = chai.assert;
$.ajax = function(opts) {
testRetryCounter++;
setTimeout(opts.error, 0);
};
var real_setTimeout = setTimeout;