Skip to content

Instantly share code, notes, and snippets.

View petersirka's full-sized avatar
🤓
From zero to hero

Peter Širka petersirka

🤓
From zero to hero
View GitHub Profile
@petersirka
petersirka / upload.html
Created April 24, 2024 07:14
Load all files from a directory + upload
<!DOCTYPE html>
<html>
<head>
<title>Load all files from directory and upload</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=11" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<meta name="robots" content="all,follow" />
/**
* Simple XML parser
* @param {String} xml
* @return {Object}
*/
function parseXML(xml) {
var beg = -1;
var end = 0;
var tmp = 0;
require('total4');
CORS();
ROUTE('POST /*', function() {
var self = this;
switch (self.url) {
case '/api/v1/ott-dummy/heartbeat/':
case '/api/v1/ott-dummy/view/':
self.plain('OK');
//require('../index');
// CONF.table_users = 'id:uid,name:string,dtcreated:date';
// TABLE('users').find().callback(console.log);
// TABLE('users').insert({ id: UID(), name: 'Peter', dtcreated: NOW });
const DELIMITER = '\0';
const Fs = require('fs');
const Path = require('path');
@petersirka
petersirka / parser-transform.js
Created March 19, 2017 22:15
Parse transform SVG attribute
String.prototype.parseTransform = function() {
var prop = ['translate', 'matrix', 'rotate', 'skewX', 'skewY', 'scale'];
var val = this.match(/(translate|matrix|rotate|skewX|skewY|scale)\(.*?\)/g);
var obj = {};
if (val) {
for (var i = 0, length = val.length; i < length; i++) {
var item = val[i];
var index = item.indexOf('(');
var v = item.substring(index + 1, item.length - 1).split(/\,|\s/);
var n = item.substring(0, index);
@petersirka
petersirka / openplatform-signup.js
Created May 20, 2020 14:38
OpenPlatform registration
ROUTE('-POST /create/ *Create --> @create');
NEWSCHEMA('Create', function(schema) {
schema.define('gender', ['male', 'female'], true);
schema.define('reference', String);
schema.define('firstname', 'Capitalize(30)', true);
schema.define('lastname', 'Capitalize(30)', true);
schema.define('position', 'String(30)');
@petersirka
petersirka / clean-up-boot-partition-ubuntu.md
Created November 10, 2018 20:03 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@petersirka
petersirka / proxy.js
Created May 14, 2018 14:31
HTTP agent as a proxy tunel
function request_proxy(options, callback) {
var proxy = options.proxy;
proxy.path = options.uri.hostname;
proxy.headers = { host: options.uri.hostname };
if (proxy.auth)
proxy.headers['Proxy-Authorization'] = 'Basic ' + U.createBuffer(proxy.auth).toString('base64');
var req = Https.request(proxy);
@petersirka
petersirka / azure-documentdb-totaljs.js
Last active May 4, 2018 12:18
A simple REST implementation of Azure DocumentDB with help of Total.js framework
const Crypto = require('crypto');
require('total.js');
function DocumentDB(hostname, key) {
this.hostname = hostname;
this.key = key;
this.attempts = 0;
this.expiration = '10 minutes';
}
@petersirka
petersirka / jquery.transform.js
Last active March 18, 2017 17:57
jQuery SVG transform (animation) plugin
// A simple SVG animation
$.fn.transform = function(obj, duration, easing, complete) {
var REG_TRANSFORM = /\}(?=\w)/g;
var REG_ROTATE = /[-0-9\.\s]+/;
var REG_TRANSLATE = /[-0-9\.]+(\,|\s)?[-0-9\.]+/;
var REG_SCALE = /[0-9\.]+/;
var REG_SKEW = /[-0-9\.]+/;
if (typeof(easing) === 'function') {