Skip to content

Instantly share code, notes, and snippets.

View roman01la's full-sized avatar
🇺🇦

Roman Liutikov roman01la

🇺🇦
View GitHub Profile
@roman01la
roman01la / nodes-num.coffee
Created January 26, 2014 03:43
Get num of HTML nodes
c = 0
check = (node) ->
if node instanceof HTMLElement || node instanceof HTMLDocument
c++
console.log(c)
for onode in node.childNodes
check(onode)
@roman01la
roman01la / monit
Created January 26, 2014 11:18
Node.js + Nginx + Varnish + Upstart + Monit
check host localhost with address 127.0.0.1
start "/sbin/start myapp"
stop "/sbin/stop myapp"
if failed port 3000 protocol HTTP
request /
with timeout 5 seconds
then restart
{
"color_scheme": "Packages/User/base16-ocean.dark (SL).tmTheme",
"ensure_newline_at_eof_on_save": true,
"font_size": 11,
"save_on_focus_lost": true,
"tab_size": 2,
"theme": "Spacegray.sublime-theme",
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true
}
function FwAjax3(host, cb) {
var req = function() {
try{ return new XMLHttpRequest();} catch(e){}
try{ return new ActiveXObject("Msxml2.XMLHTTP.6.0") }catch(e){}
try{ return new ActiveXObject("Msxml2.XMLHTTP.3.0") }catch(e){}
try{ return new ActiveXObject("Msxml2.XMLHTTP") }catch(e){}
try{ return new ActiveXObject("Microsoft.XMLHTTP") }catch(e){}
return null;
}(),
boundary = function () {
$('#header').append('<a href="/callback/call_form.php" class="call-btn" style="display:block;width:100px;height:100px;background:#666;"></a>');
$('a.call-btn').fancybox({
type: 'iframe',
width: 506,
height: 638
});
@roman01la
roman01la / sublime-plugins
Created April 14, 2014 12:29
sublime plugins
- Diff
- EditorConfig
- Emmet
- HTML-CSS-JS Prettify
- JSHint
- Local History
- Sass
- SideBarEnhancements
- SublimeLinter
- SublimeLinter-css-lint
#!/bin/bash
# Install curl if not found
if ! type "curl" > /dev/null; then
sudo apt-get update
sudo apt-get install curl -y
fi
# Install nvm
curl https://raw.githubusercontent.com/creationix/nvm/v0.7.0/install.sh | sh
@roman01la
roman01la / app.js
Last active August 29, 2015 14:04
HTTP resource JavaScript class for consuming REST API resources
import HttpResource from 'xhr';
var items = new HttpResource('/api/items');
items.query(function* (resume) {
yield items.create([
{name: 'Item #1'},
{name: 'Item #2'},
{name: 'Item #3'}
@roman01la
roman01la / web-worker-cors.js
Created September 9, 2014 17:26
Cross-origin solution for loading WebWorker
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onload = function() {
if (xhr.status === 200) {
var workerSrcBlob, workerBlobURL;
workerSrcBlob = new Blob([xhr.responseText], { type: 'text/javascript' });
workerBlobURL = window.URL.createObjectURL(workerSrcBlob);
var worker = new Worker(workerBlobURL);
@roman01la
roman01la / standard-deviation.js
Created September 22, 2014 20:21
Standard Deviation
function standardDeviation (values) {
var avg = average(values);
var squareDiffs = values.map(function (value) {
var diff = value - avg,
sqrDiff = diff * diff;
return sqrDiff;