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
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.1.0/d3.min.js"></script>
@petersirka
petersirka / nginx.conf
Created July 15, 2016 09:32
Nginx configuration
worker_processes auto;
events {
use epoll;
worker_connections 1024;
multi_accept on;
}
http {
limit_req_zone $binary_remote_addr zone=ddos:10m rate=50r/s;
const Exec = require('child_process').exec;
var cmd = 'ps aux | grep "mysql" | grep -v "grep" | awk {\'print $2\'}';
Exec(cmd, function(err, response) {
var pid = response.trim();
cmd = 'ps -p {0} -o %cpu,rss,etime'.format(pid);
console.log(cmd);
Exec(cmd, function(err, response) {
console.log('---> POSLAT SIROVI:', arguments);
});
@petersirka
petersirka / controller.js
Created December 12, 2016 12:32
Total.js: A workflow and controller with implementation of reCAPTCHA.
exports.install = function() {
F.route('/api/signup/', json_signup, ['*SignUp', 'post']);
};
function json_signup() {
var self = this;
self.$async(self.callback(), 1).$workflow('recaptcha').$save().$workflow('notify');
}
require('total.js').http('debug');
var util = require('util');
var EventEmitter = require('events');
// jen na test
var WSCONTROLLER = {
send: function(data){ console.log(data)}
}
@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') {
@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 / 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 / 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 / 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)');