Skip to content

Instantly share code, notes, and snippets.

@arsonus
arsonus / html-editors.md
Created January 30, 2017 09:28 — forked from manigandham/rich-text-html-editors.md
List of rich text / HTML editors
@arsonus
arsonus / galera-mysqlnd_ms.md
Created March 24, 2017 00:36 — forked from denji/galera-mysqlnd_ms.md
Clustered DB Replication

php module mysqlnd_ms

mysqlnd_ms.enable = On
mysqlnd_ms.config_file = /etc/mysqlnd_ms_plugin.ini
mysqlnd_ms.multi_master = On
mysqlnd_ms.collect_statistics = On
mysqlnd_ms.force_config_usage = On
@arsonus
arsonus / timeout.php
Created April 9, 2017 11:06 — forked from avalanche123/timeout.php
timeouts in php
<?php
class TimeoutException extends RuntimeException {}
class Timeout
{
private $active;
public function set($seconds)
{
@arsonus
arsonus / create-cluster
Created April 14, 2017 01:38 — forked from diegopacheco/create-cluster
Redis Create Cluster
#!/bin/bash
# Settings
PORT=30000
TIMEOUT=2000
NODES=3
REPLICAS=2
# You may want to put the above config parameters into config.sh in order to
# override the defaults without modifying this script.
@arsonus
arsonus / gist:7724667345d1b26aa17bb7e906803494
Created November 1, 2017 00:55 — forked from BastinRobin/gist:0cca0e267408e361062a8681d0cc556d
Javacript: Set or Update a URL/QueryString Parameter, and update URL using HTML history.replaceState()
// Explicitly save/update a url parameter using HTML5's replaceState().
function updateQueryStringParam(param, value) {
baseUrl = [location.protocol, '//', location.host, location.pathname].join('');
urlQueryString = document.location.search;
var newParam = key + '=' + value,
params = '?' + newParam;
// If the "search" string exists, then build params from it
if (urlQueryString) {
keyRegex = new RegExp('([\?&])' + key + '[^&]*');
<?php
/*
|--------------------------------------------------------------------------
| Return a Collection of Objects
|--------------------------------------------------------------------------
*/
// collection of all users
$sql = "select * from users";
// takes the form field value and returns true on valid number
function valid_credit_card(value) {
// accept only digits, dashes or spaces
if (/[^0-9-\s]+/.test(value)) return false;
// The Luhn Algorithm. It's so pretty.
var nCheck = 0, nDigit = 0, bEven = false;
value = value.replace(/\D/g, "");
for (var n = value.length - 1; n >= 0; n--) {
@arsonus
arsonus / scrollTop.js
Created November 24, 2017 01:17 — forked from alizhdanov/scrollTop.js
pure javascript scrollTop function
function scrollTo(element, to, duration) {
if (duration < 0) return;
var difference = to - element.scrollTop;
var perTick = difference / duration * 2;
setTimeout(function() {
element.scrollTop = element.scrollTop + perTick;
scrollTo(element, to, duration - 2);
}, 10);
}
@arsonus
arsonus / Object.create.js
Created February 6, 2018 21:21 — forked from jonathantneal/Object.create.js
Object.create: useless extras edition
// Object.create
Object.create = function create(prototype, properties) {
var
isFunction = typeof prototype === 'function',
name = isFunction && Function.prototype.toString.call(prototype).match(/^function\s+(\w*)/)[1] || 'Object',
object;
if (!isFunction && typeof prototype !== 'object') {
throw new Error('Object prototype may only be an Object or null');
}
@arsonus
arsonus / mediaquery.js
Created February 6, 2018 21:21 — forked from jonathantneal/mediaquery.js
Media Queries for everybody
(function () {
var
documentElement = document.documentElement,
viewportFontSize, viewportHeight, viewportIsPortrait, viewportMax, viewportMin, viewportWidth;
function getViewportFontSize() {
var
body = documentElement.appendChild(document.createElement('body')),
iframe = document.createElement('iframe'),
iframeDocument;