This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "strings" | |
func indexAt(str, substr string, start int) int { | |
idx := strings.Index(str[start:], substr) | |
if idx == -1 { | |
return idx | |
} | |
return idx + start | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 === '['; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
System.config({ | |
baseURL: "/", | |
defaultJSExtensions: true, | |
transpiler: "babel", | |
babelOptions: { | |
"optional": [ | |
"runtime", | |
"optimisation.modules.system" | |
] | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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; |