Skip to content

Instantly share code, notes, and snippets.

@vordan
vordan / format-money.js
Last active December 12, 2021 10:42
Format Money Number
Number.prototype.formatMoney = function(c, d, t){
c = isNaN(c = Math.abs(c)) ? 2 : c;
d = d == undefined ? "." : d;
t = t == undefined ? "," : t;
var n = this;
var s = n < 0 ? "-" : "";
var i = String(parseInt(n = Math.abs(Number(n) || 0).toFixed(c)));
var j = (j = i.length) > 3 ? j % 3 : 0;
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
@vordan
vordan / long-polling.html
Created November 20, 2021 08:43 — forked from kixxauth/long-polling.html
A Node.js http long polling server for HTTP streaming.
<!DOCTYPE html>
<html>
<style type="text/css">
body {
font-size: 18px;
background: #000;
color: #fff;
}
#container {
width: 600px;
@vordan
vordan / osticket-disable-api-ip-validation.php
Last active October 8, 2021 16:51
OSTicket API - completely disable IP validation for API key
OSTicket API Key
How to completely disable IP validation
========================================
Open the file /include/class.api.php
The solution is to remove the three references to: $_SERVER['REMOTE_ADDR']
That then completely disables any IP validation however the API key will still be validated.
You will still need to attach an IP to the API key in the admin panel - just use 99.99.99.99
@vordan
vordan / breakpoints.css
Last active June 27, 2021 09:33
CSS Screen size breakpoints
breakpoints({
wide: [ '1281px', '1680px' ],
normal: [ '961px', '1280px' ],
narrow: [ '841px', '960px' ],
narrower: [ '737px', '840px' ],
mobile: [ null, '736px' ]
});
@vordan
vordan / validMKPhone.js
Last active April 30, 2021 16:30
RegEx za makedonski telefonski broevi
$.fn.validMKPhone = function() {
// https://regex101.com/r/GelZQf/1
let $input = $(this);
let mk_phone_regexp = new RegExp(/[0][237][0-9]{0,1}[\-\ ]\d{3,4}[\-\ ]\d{3}/);
return mk_phone_regexp.test($input.val());
}
@vordan
vordan / refresh-win.sh
Created April 12, 2021 11:04
Refresh Browser from Geany (F1)
aw=`xdotool getactivewindow`;xdotool search --name '10.' windowactivate key ctrl+r;xdotool windowactivate $aw;
@vordan
vordan / mysql-remote.sh
Created November 17, 2020 13:03
Allow remote connection to MySQL
1. Edit the config file
vi /etc/mysql/mysql.conf.d/mysqld.cnf
Change
bind-address = 127.0.0.1
to
bind-address = 0.0.0.0
2. Restart mysql
systemctl restart mysql
@vordan
vordan / mysql.cnf
Last active August 20, 2018 10:27
[Упис на празни датуми во MySQL v5.6+] #mysql #admin #linux
Во MySQL верзија 5.6 и поголеми (со Ubuntu 16.04 доаѓа v5.7+) има проблем со упис на *празни* датуми во датумски полиња каде што е наведено дека полето е "not null".
Уписите од Infomatrix и другите апликации, паѓаат со порака дека не е дозволена вредност '' (празен стринг) во датумско поле.
Ова *мора* да се направи на секоја нова инсталација каде што доаѓа MySQL v5.6 и поголема
Отвори
/etc/mysql/mysql.conf.d/mysqld.cnf
Во одделот [mysqld] додади:
sql_mode = NO_ENGINE_SUBSTITUTION
@vordan
vordan / posledna-cena-od-promet.sql
Last active April 18, 2018 09:25
Bara posledna cena za artikal vo tabela so ceni po datumi
-- ------------------------------------------------------------------
-- Bara posledna cena za artikal vo tabela so ceni po datumi
-- ------------------------------------------------------------------
select
temp_promet.*
from temp_promet
inner join (
select
artikal_id as artikal_id,
max(datum_ddo) as max_datum_ddo,
@vordan
vordan / openvpn on ubuntu server 12.04
Created March 28, 2018 09:35
Install OpenVPN on ubuntu server 12.04
Since 2018 openvpn no longer works on ubuntu server 12.04 with out-of-the-box apt-get install.
First you need the following dependencies:
apt-get install libpkcs11-helper1
apt-get install liblzo2-2
then run:
apt-get install openvpn