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
@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 / 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 / sshfs.sh
Created January 22, 2014 07:33
simple script opening/closing sshfs connection with ./sshfs.sh -o or ./sshfs.sh -c
#!/bin/bash
if [ "$1" != "" ]; then
case $1 in
-o | --open ) echo "$USER opening sshfs connection"
open your connection here
;;
-c | --close ) echo "$USER closing sshfs connection"
close your connection here
;;
@ducin
ducin / selection_sort.py
Created February 16, 2014 20:05
selection sort implementation
def selection_sort(elements):
size = len(elements)
# loop over all elements excluding last one
for i in range(size - 1):
# find the smallest value in current range
min_index, min_value = i, elements[i]
for j in range(i + 1, size):
if elements[j] < min_value:
min_index, min_value = j, elements[j]
# swap i-th element with the smallest one
@ducin
ducin / .bash_aliases
Created July 18, 2014 10:40
example bash aliases used in linux environment
alias cdprojects='cd ~/Projects'
alias pyc-remove='find . -name "*.pyc" -exec rm -rf {} \;'
timestamp2date() {
date -d@$1
}
alias ts2date=timestamp2date
@ducin
ducin / index.html
Last active March 12, 2021 06:45
sinon fake server demo
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sinon.js fakeServer demo</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/sinon.js/1.7.3/sinon-min.js"></script>
<script src="sinon-fake-server.js"></script>
</head>
<body>
@ducin
ducin / angular-ajax-spinner.html
Created March 31, 2015 14:38
angular AJAX spinner
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-mocks.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-spinner/0.6.1/angular-spinner.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/spin.js/2.0.1/spin.js"></script>
<script type="text/javascript">
var app = angular.module('myApp', ['ngMockE2E', 'angularSpinner']);
@ducin
ducin / argmapify.js
Created May 16, 2015 12:25
map positional arguments into options object
"use strict";
// run `npm install introspect` before
var introspect = require('introspect');
function generateEmail(firstName, lastName, provider) {
return firstName + "." + lastName + "@" + provider;
}
var argMapify = function(fn, argValues, context) {
@ducin
ducin / README.md
Last active April 15, 2018 15:33
JSON-Schema-faker console basic demo

JSON-Schema-faker demo

Run the following:

npm install
node run.js

to execute the demo.

@ducin
ducin / .gitignore
Last active January 23, 2016 18:47
Grunt JSON-Schema-faker basic demo
node_modules/
output/