Skip to content

Instantly share code, notes, and snippets.

@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 {
<!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 / 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>
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 / 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';
@ynonp
ynonp / mainwindow.cpp
Created July 13, 2013 18:07
QListWidget itemActivated signal example
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QObject::connect(ui->listWidget, SIGNAL(itemActivated(QListWidgetItem*)),
/**
* Namespaces in JavaScript are defined using objects
* We'll start from the global object and define nested
* namespaces within.
*
* All namespaces are accessible from every other JS file using
* their fully qualified name starting from global.
* i.e. global.myapp.data.number = 5;
*/
@ynonp
ynonp / Contacts.pm
Last active December 18, 2015 15:19
use strict;
use warnings;
use v5.14;
package Contacts;
sub init {
my %data;
return \%data;
}
{
"name": "day12",
"version": "0.0.1",
"private": true,
"dependencies": {
"express" : "*"
}
}