Skip to content

Instantly share code, notes, and snippets.

View ducin's full-sized avatar
🛠️
creatin' some stuff

Tomasz Ducin ducin

🛠️
creatin' some stuff
View GitHub Profile
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define("csp", [], factory);
else if(typeof exports === 'object')
exports["csp"] = factory();
else
root["csp"] = factory();
})(this, function() {
@ducin
ducin / .gitignore
Last active December 5, 2016 17:08
node_modules
@ducin
ducin / reveal.js
Created September 19, 2016 14:27
REVEAL.JS bonus
Reveal.configure({
keyboard: {
40: 'next',
38: 'prev'
}
});
@ducin
ducin / index.js
Created April 21, 2016 17:50
use `david` to check available dependency updates
var pkgPath = '<path to package.json file>';
var david = require('david'),
chalk = require('chalk'),
fs = require('fs');
var manifest = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
david.getDependencies(manifest, function (er, deps) {
console.log('\n', chalk.cyan('latest dependencies information for', manifest.name));
@ducin
ducin / .gitignore
Last active January 23, 2016 18:47
Grunt JSON-Schema-faker basic demo
node_modules/
output/
@ducin
ducin / version.cpp
Last active December 31, 2015 06:19
boost version check
#include <boost/version.hpp>
#include <iostream>
#include <iomanip>
int main()
{
std::cout << "Using Boost "
<< BOOST_VERSION / 100000 << "." // major version
<< BOOST_VERSION / 100 % 1000 << "." // minor version
<< BOOST_VERSION % 100 // patch level
@ducin
ducin / subtitles.py
Created December 6, 2013 10:44
Simple subtitles modifier (handles MicroDVD format), tested on python 2.x
import argparse
parser = argparse.ArgumentParser(description='Move subtitles in MicroDVD format.')
parser.add_argument('input_file', metavar='input_file', type=str, help='input file')
parser.add_argument('output_file', metavar='output_file', type=str, help='output file')
parser.add_argument('frames_diff', metavar='frames_diff', type=float, help='frames difference (check MicroDVD format)')
parser.add_argument('--ignore-lines', dest='ignore_lines', type=int, default=0, help='number of lines to be ignored')
args = parser.parse_args()
import re
@ducin
ducin / fork.py
Created November 3, 2013 12:38
scanning parent/child process IDs using os.fork
import os
parent_pid = os.getpid()
print "[parent] starts PID: %d" % (parent_pid, )
forked_pid = os.fork()
if forked_pid == 0:
print "[child] child process can't use os.fork() PID, since it's %d" % (forked_pid, )
print "[child] but it can reevaluate os.getpid() to get it's own PID: %d" % (os.getpid(), )
else:
@ducin
ducin / class.js
Last active December 26, 2015 08:59
JavaScript class implementation (with example PersonClass declaration)
var Class = function(base){
if (typeof base.construct !== "function")
throw new TypeError("class definition has to define 'construct' function");
return function() {
// copy all methods
for (var prop in base) {
if (base.hasOwnProperty(prop) && base[prop] !== base.construct) {
this[prop] = base[prop];
}
}
@ducin
ducin / time-server.php
Last active December 25, 2015 08:49
PHP time server (example PHP server implementation). Run the server from command line, specifying port parameter and connect to it from outside (could be any platform that is able to open a socket or just a telnet connection: `telnet localhost <port>`). The server writes back current time in RFC 2822 and immediately closes the connection.
#!/usr/bin/php -q
<?php
set_time_limit(0);
ob_implicit_flush();
if ($argc != 2)
die("Simple Time Server (C) 2013 Tomasz Ducin\n" .
"Invalid parameters passed\n" .
"Run:\n\t./time-server.php <port>\n" .