Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
#divWithBackground {
width: 256px;
height: 256px;
background: url('http://js-for.ninja/img/article1/sprite.jpg') 0 -256px;
System.config({
baseURL: "/",
defaultJSExtensions: true,
transpiler: "babel",
babelOptions: {
"optional": [
"runtime",
"optimisation.modules.system"
]
},
@OrKoN
OrKoN / application.controller.js
Last active October 27, 2015 10:00
Post Demo
import Ember from 'ember';
import { formatDate, formatPhone } from '../format-macros';
export default Ember.Controller.extend({
localeService: Ember.inject.service('locale'),
formattedPhone: formatPhone('model.phone'),
formattedDate: formatDate('model.date', 'L')
});
@OrKoN
OrKoN / index.html
Created December 15, 2015 10:59 — forked from RubaXa/index.html
String#includes vs. String#indexOf vs. RegExp (http://jsbench.github.io/#a4612afd0cd26e911ee8) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>String#includes vs. String#indexOf vs. RegExp</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>
@OrKoN
OrKoN / permutations.js
Last active November 28, 2017 21:15
Generation of permutations in lexicographic order (JavaScript, NodeJS)
// The MIT License (MIT)
// Copyright (c) 2015 Oleksii Rudenko
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@OrKoN
OrKoN / sort.js
Last active December 16, 2018 14:19
some sort algorithms
// The MIT License (MIT)
// Copyright (c) 2017 Oleksii Rudenko
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@OrKoN
OrKoN / server.js
Last active February 25, 2019 13:00
Simple server with synchronization of request processing
/**
* WARNING: don't use the code in production, it only works for a single process instance and does not work in cluster mode.
*/
const express = require('express');
const app = express();
let nextRequestId = 1; // request counter
let nextPaymentId = 1; // payment counter
@OrKoN
OrKoN / decompress.js
Created May 10, 2018 20:11
Compression and Decompression challenge
// solution for https://techdevguide.withgoogle.com/paths/advanced/compress-decompression/#code-challenge
const assert = require('assert');
function isDigit(char) {
return char >= '0' && char <= '9';
}
function isOpeningBrace(char) {
return char === '[';
@OrKoN
OrKoN / indexAt.go
Last active April 7, 2019 09:23
String index of a substring with start index
import "strings"
func indexAt(str, substr string, start int) int {
idx := strings.Index(str[start:], substr)
if idx == -1 {
return idx
}
return idx + start
}
@OrKoN
OrKoN / index.js
Last active July 24, 2019 08:20
Autonomous LumberJack
var c = document.getElementById('canvas_wrap').children[0];
var gl = c.getContext('webgl', { preserveDrawingBuffer: true });
function getColor(pixels, y) {
var color =
decimalToHex(pixels[y * 4], 2) +
decimalToHex(pixels[y * 4 + 1], 2) +
decimalToHex(pixels[y * 4 + 2], 2);
return color;
}