This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias cdprojects='cd ~/Projects' | |
alias pyc-remove='find . -name "*.pyc" -exec rm -rf {} \;' | |
timestamp2date() { | |
date -d@$1 | |
} | |
alias ts2date=timestamp2date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(root){ | |
root.getScript = function(url) { | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = url; | |
document.head.appendChild(script); | |
} | |
}(window)); | |
getScript('http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | |
} | |
} |