Skip to content

Instantly share code, notes, and snippets.

@mdogadailo
mdogadailo / web-servers.md
Created August 30, 2017 05:35 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
<!doctype html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
</html>
var Device = {
ENV_DESKTOP: 'desktop',
ENV_PHONE: 'phone',
ENV_TABLET: 'tablet',
ENV_PORTRAIT: 'portrait',
ENV_LANDSCAPE: 'landscape',
agent: {
mobile: (/iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i.test(window.navigator.userAgent.toLowerCase())),
tablet: (/ipad|android|android\s3\.0|xoom|sch-i800|playbook|tablet|kindle/i.test(window.navigator.userAgent.toLowerCase()))
},
@mdogadailo
mdogadailo / AT-ElementsList.js
Last active December 14, 2015 00:09
Automatic build elements and variant
javascript:all={},j=0;$(".edit-delet-links a:contains('edit')").each(function(){var e,t,n;e=this.href.split("/");t=e[e.length-1];n=$(this).parents(".content-element-block").find('.edit-cell-wrap input[type="radio"]');all[t]=[];n.each(function(){all[t].push(this.value)})});config_str='<property name="maxyBox">\n <map>';proper_str="";for(i in all){j++;config_str+='\n <entry key="Box'+j+'" value="'+i+'" />';proper_str+='<property name="ListOfVar'+j+'" value="'+all[i].join(",")+'"/>\n'}config_str+="\n </map>\n</property>"; $('body').append('<div id="code_block" style="width: 500px;height: 215px;position: absolute;left: 10px;top: 10px;padding: 10px;background: #FFF;border-radius: 10px;z-index: 10000000000;"><textarea id="code" style="height: 190px;border: 1px solid #000;width: 490px;"></textarea><span id="close_at" style="text-decoration:underline; cursor:pointer">Close</span></div>');$('#close_at').one('click', function(){$('#code_block').remove();});$('#code').html(config_str+proper_str+'');void(0);
@mdogadailo
mdogadailo / gist:4985597
Last active December 13, 2015 22:38
jQuery every n element like: "nth-child(4n)", just for fun
$.fn.every = function(arg1) {
var arr = [];
if($.isNumeric(arg1)) {
$.each(this, function(idx, item) {
var newNum = idx + 1;
if(newNum % arg1 == 0) arr.push(item);
});
}
return this.pushStack(arr, "every", "");
}