Skip to content

Instantly share code, notes, and snippets.

@ynonp
ynonp / fixtures.js
Created October 23, 2013 08:57
A small library for handling fixtures in Mocha unit tests
function Fixtures(opts) {
var self = this;
opts = opts || {};
self.base = opts.base ? opts.base : "";
self._cache = {};
self.fixture_id = opts.fixture_id || "fixture";
self.el;
return {
var assert = chai.assert;
describe('Sinon', function() {
describe('spies', function() {
it('should keep count', function() {
// fill code here
spy();
spy();
spy();
@ynonp
ynonp / karma.conf.js
Created October 9, 2013 18:53
Karma config file that can serve static HTML fixtures
// Karma configuration
// Generated on Sun Sep 22 2013 11:31:34 GMT+0300 (IDT)
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
preprocessors: {
var testRetryCounter = 0;
var assert = chai.assert;
$.ajax = function(opts) {
testRetryCounter++;
setTimeout(opts.error, 0);
};
describe('Data', function() {
describe('#sendData()', function() {
@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;
@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) {
#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 / db.cpp
Created September 11, 2013 15:48
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL", "products");
bool ok = db.open();
@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 / 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 {