Skip to content

Instantly share code, notes, and snippets.

View w0rm's full-sized avatar
🧘
ヨガの呼吸

Andrey Kuzmin w0rm

🧘
ヨガの呼吸
View GitHub Profile
@w0rm
w0rm / index.html
Last active August 27, 2018 19:40
Buffer construction (https://jsbench.github.io/#00c5236cfdf645df5656c3e680fd2da6) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Buffer construction</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@w0rm
w0rm / internet.sh
Created June 12, 2017 05:38
Check for the Internet connection
#!/bin/bash
# Usage: HOST=public_gateway_ip_here ./internet.sh
CONNECTED=30
DISCONNECTED=0
INTERVAL=$DISCONNECTED
while sleep $INTERVAL
do
LOSS=$(ping -c 10 -s 14 $HOST|grep packet|awk '{print $7}'|cut -d'.' -f1)
echo "$LOSS packets lost"
@w0rm
w0rm / stencil-test-separate.elm
Last active January 5, 2017 18:58
Explains the issue with a separate stencil test
module Main exposing (..)
import Math.Vector3 exposing (..)
import WebGL exposing (Shader, Mesh)
import WebGL.Settings exposing (Setting)
import WebGL.Settings.StencilTest as StencilTest
import Html exposing (Html)
import Html.Attributes exposing (width, height)
(-1,1,1) +================+ (1,1,1)
/| /|
/ | | / |
(-1,1,-1)+================+ (1,1,-1)
| | | / | |
| | |/ | |
| | +-------|->|
(-1,-1,1|) +--(0,0,0)----|--+ (1,-1,1)
| / | /
|/ |/
@w0rm
w0rm / state.js
Created May 16, 2016 12:29 — forked from WebReflection/state.js
Prototypal inheritance used to define states.
/*! (c) 2016 Andrea Giammarchi - MIT Style License */
// simple state-like objects handler
// based on prototypal inheritance
function State() {'use strict';}
// States are serializable dictionaries
// toJSON and toString are the only reserved keywords
// every other name can be used as name (included __proto__)
@w0rm
w0rm / index.html
Created February 9, 2016 23:00
Trigger elm-reactor build before loading elm.js
<script>
var img = new Image();
img.onerror = function () {
var script = document.createElement('script');
script.src = 'elm.js';
script.onload = function () {
Elm.fullscreen(Elm.Main, {
locationHash: window.location.hash,
windowDimensions: [window.innerWidth, window.innerHeight]
})
@w0rm
w0rm / gist:36ff0b4399a414384690
Created May 25, 2015 09:50
Unhandled gulp-postcss errors don't end up in console if not manually catched
var Stream = require('stream')
var gulp = require('gulp')
var postcss = require('gulp-postcss')
function errorStream () {
var stream = new Stream.Transform({ objectMode: true })
stream._transform = function (file, encoding, cb) {
cb(new Error('unhandled exception!'))
}
return stream
@w0rm
w0rm / svgstore.html
Created August 6, 2014 15:26
Load combined svg file into body
<html>
<body>
<!-- load combined svg file (with symbols) into body-->
<script>
(function (doc) {
var scripts = doc.getElementsByTagName('script')
var script = scripts[scripts.length - 1]
var xhr = new XMLHttpRequest()
xhr.onload = function () {
@w0rm
w0rm / background-borders.scss
Last active August 29, 2015 14:01
Draw borders with linear gradients, supports width of 0.5px for retina screens
// This mixin is used to ease workaround explained in this article
// http://n12v.com/css-retina-and-physical-pixels/
// Creates linear gradient for specified border
@function border-gradient($side, $color: currentColor, $width: 0.5px) {
@if $side == top {
@return linear-gradient(180deg, $color, $color 50%, transparent 50%) top left / 100% #{$width * 2} no-repeat;
} @else if $side == bottom {
@return linear-gradient(0, $color, $color 50%, transparent 50%) bottom right / 100% #{$width * 2} no-repeat;
@w0rm
w0rm / analytics.js
Created April 8, 2014 21:20
Wrap universal analytics in requirejs module
define(function() {
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
window.ga('create', 'UA-XXXXXXXX-X')
return {