Skip to content

Instantly share code, notes, and snippets.

View anru's full-sized avatar

Andrey Rublev anru

View GitHub Profile
@anru
anru / foo-error.js
Last active January 12, 2021 03:00
js error
function foo() {
throw new Error('foo')
}
foo.createApp();
@anru
anru / machine.js
Last active March 12, 2020 11:22
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
struct Foo {
string: String,
state: i32,
}
// immutable borring N
// mutable - 1 EXCLUSIVE
/**
* Generated parser in Rust.
*
* ./bin/syntax -g examples/calc.rs.g -m lalr1 -o lib.rs
*
* use syntax::Parser;
*
* let parser = Parser::new();
*
* println!("{:?}", parser.parse("2 + 2 * 2")); // 6
@anru
anru / app.js
Last active February 14, 2019 10:33
cookies
console.log('cookies:', document.cookie)
@anru
anru / greet.go
Last active October 21, 2018 07:56
http-ehlo
package main
import (
"fmt"
"net/http"
"regexp"
)
func main() {
reg := regexp.MustCompile("^/greeting/([a-z]+)$")
@anru
anru / if-as-expr.js
Last active October 29, 2018 07:27
if as description
const s = `This ${ Math.random() > 0.5 ? 'abc' : `Hello ${ 'inner backtick' + ' str' } !` } is .`
const value = if (s.length > 14) {
a
} else {
b
}
@anru
anru / babelify.js
Last active August 29, 2015 14:22
babelify
var blacklist = [
'es6.arrowFunctions', // supported
'es6.blockScoping', // supported
'es6.constants', // supported
'es6.forOf', // supported
//'es6.modules', // supported
'regenerator'
];
try {
@anru
anru / rsvgtest.js
Created December 15, 2014 05:08
stress testing for rsvg
var gulp = require('gulp');
var rsvg = require('gulp-rsvg');
var through = require('through2');
var pot = gulp.pot;
var N = 110;
var C = 2;
gulp.task('st', function(cb) {