Skip to content

Instantly share code, notes, and snippets.

@ntomka
ntomka / serviceWorker.js
Created November 19, 2017 14:17
Service Workers summary by @Lacika1981
import { request } from "http";
// check whether browser supports serviceWrokers
if (!navigator.serviceWorker) {
return;
}
// Register a serviceWorker
navigator
.serviceWorker
@ntomka
ntomka / empty
Created March 4, 2015 12:14
Empty Linux kernel memory cache & buffers
free -m && sync && echo 3 > /proc/sys/vm/drop_caches && free -m
@ntomka
ntomka / split_string
Last active April 30, 2023 00:28
MySQL SPLIT_STRING function
-- use this as a stored function
CREATE FUNCTION SPLIT_STRING(str VARCHAR(255), delim VARCHAR(12), pos INT)
RETURNS VARCHAR(255)
DETERMINISTIC
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(str, delim, pos),
LENGTH(SUBSTRING_INDEX(str, delim, pos-1)) + 1),
delim, '');
@ntomka
ntomka / sanitizer.php
Last active August 29, 2015 14:00
String sanitizer function
<?php
/**
* Sanitize a string. PHP 5.3 or lower version.
*
* See requirements here: http://www.php.net/manual/en/iconv.requirements.php
*
* @param string $str string to sanitize
* @param array $replace special strings/characters to be replaced with space
* @param string $delimiter delimeter character insteand of whitespaces
@ntomka
ntomka / Roar.css
Last active December 15, 2015 09:19 — forked from sunng87/Roar.css
Make roar works with mootools 1.4.x
.roar-body
{
position: absolute;
font: 12px/14px "Lucida Grande", Arial, Helvetica, Verdana, sans-serif;
color: #fff;
text-align: left;
z-index: 999;
}
.roar