Skip to content

Instantly share code, notes, and snippets.

View NV's full-sized avatar

Nikita Vasilyev NV

View GitHub Profile
(async function() {
let compressed_array_buffer = await compress("Hello");
console.info("compressed_array_buffer", compressed_array_buffer);
let text_decoder = new TextDecoder("utf-8", {fatal: true});
// TypeError: Failed to execute 'decode' on 'TextDecoder': The encoded data was not valid.
let compressed_text = text_decoder.decode(compressed_array_buffer);
console.info("GZIP", compressed_text);
@NV
NV / README.markdown
Last active March 1, 2024 11:26
AWS script to sync files with Amazon s3 and invalidate CloudFront paths that have been synced. I can't believe the AWS CLI doesn't do that in one command!

AWS s3 sync and CloudFront invalidation script

This is a scrappy script I put together to invalidate AWS CloudFront paths that have been uploaded to AWS S3.

Problem

If you host a static website on Amazon S3 and CloudFront, you need to create a CloudFront cache invalidation every time you upload files to Amazon S3.

@NV
NV / isLikelyMinified.js.carbide.md
Created August 24, 2016 23:42
isLikelyMinified.js

isLikelyMinified.js

@NV
NV / index.js
Created September 25, 2014 21:25
requirebin sketch
// example using the raf module from npm. try changing some values!
var BitterSet = require("bitterset");
var s = new BitterSet();
s.set(30);
document.body.textContent += s.store.join(', ') + '\n';
s.clear(30);
s.set(31);
document.body.textContent += s.store.join(', ') + '\n';
@NV
NV / index.js
Created September 25, 2014 14:38
requirebin sketch
// example using the raf module from npm. try changing some values!
var BitSet = require("bitterset");
var s = new BitSet();
for (var i = 0; i <= 13; i++) {
s.set(i);
}
log(s.get(0));
log(s.store);
@NV
NV / index.js
Last active August 29, 2015 14:06
requirebin sketch
// example using the raf module from npm. try changing some values!
var BitSet = require("bitset");
var s = new BitSet();
for (var i = 0; i <= 13; i++) {
s.set(i);
}
log(s.get(0));
log(s.store);
@NV
NV / converter.js
Last active May 18, 2021 09:22
Angular.js temperature converter sample app http://bl.ocks.org/NV/5291cc85b1f04e4be988
var app = angular.module('converter', []);
app.controller('MainController', function($scope) {
$scope.a = 0;
});
app.directive('converter', function(converters) {
return {
require: 'ngModel',
link: function(scope, element, attr, ngModel) {
@NV
NV / c2f.html
Created May 16, 2014 01:16
Meteor temperature converter sample app. http://temperature.meteor.com
<head>
<title>Temperature converter</title>
</head>
<body>
{{> c2f}}
</body>
<template name="c2f">
<input type="number" value="{{celsius}}" id="c">℃ ⟷
@NV
NV / TemperatureConverter.js
Last active October 7, 2016 05:45
React.js temperature converter sample app http://bl.ocks.org/NV/193d039f286bf56f9c01
/**
* @jsx React.DOM
*/
function c2f(c) {
return 9 / 5 * parseFloat(c) + 32;
}
function f2c(f) {
return 5 / 9 * (f - 32);
}

Keybase proof

I hereby claim:

  • I am NV on github.
  • I am NV (https://keybase.io/NV) on keybase.
  • I have a public key whose fingerprint is BBE6 E287 4B13 807B 8C85 FCE4 E175 B4CA D090 60CC

To claim this, I am signing this object: