Skip to content

Instantly share code, notes, and snippets.

@lvivski
lvivski / gen.js
Created March 10, 2023 06:02
Webpack Stress Test
const fs = require('fs');
const path = require('path');
const { randomBytes } = require('crypto');
function randomString(size) {
return randomBytes(size).toString('hex');
}
function randomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
@lvivski
lvivski / yubikey-reset.sh
Created May 22, 2020 18:56 — forked from pkirkovsky/yubikey-reset.sh
Utility for resetting a Yubikey to factory defaults using gpg-connect-agent. This will wipe out any stored keys and reset PINs to default values.
gpg-connect-agent <<EOF
/hex
scd serialno
scd apdu 00 20 00 81 08 40 40 40 40 40 40 40 40
scd apdu 00 20 00 81 08 40 40 40 40 40 40 40 40
scd apdu 00 20 00 81 08 40 40 40 40 40 40 40 40
scd apdu 00 20 00 81 08 40 40 40 40 40 40 40 40
scd apdu 00 20 00 83 08 40 40 40 40 40 40 40 40
scd apdu 00 20 00 83 08 40 40 40 40 40 40 40 40
scd apdu 00 20 00 83 08 40 40 40 40 40 40 40 40
Array.apply(null, Array(20)).map(function (charset) {
return function () {
return charset.charAt(Math.floor(Math.random() * charset.length))
}
}('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789')).join('')
@lvivski
lvivski / New.js
Last active December 25, 2015 05:49
This is how javascripts `new` operator works
function New(constructor) {
if (typeof constructor !== 'function') {
throw new TypeError("'"+ constructor +"' is not a constructor")
}
var obj = {}
obj.__proto__ = constructor.prototype
var res = constructor.apply(obj, [].slice.call(arguments, 1))
if (typeof res === "object") {
return res
}
@lvivski
lvivski / pr.md
Created August 29, 2013 18:52 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

ioreg -lw0 | grep \"EDID\" | sed "/[^<]*</s///" | xxd -p -r | strings -6
@lvivski
lvivski / dabblet.css
Created July 20, 2013 23:36 — forked from LeaVerou/dabblet.css
Loading animation like the one seen on http://www.freeger.com/projects/contextad/ with CSS
/**
* Loading animation like the one seen on http://www.freeger.com/projects/contextad/ with CSS
* Caveat: Not DRY. The content needs to be repeated in a data- attribute (or directly in the CSS).
*/
body {
background: #ccc51c;
min-height: 100%;
}
@lvivski
lvivski / LICENSE.txt
Last active December 16, 2015 14:59 — forked from 140bytes/LICENSE.txt
сurry.js for 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2013 Yehor Lvivski <lvivski@gmail.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@lvivski
lvivski / jquery.mini.js
Created April 19, 2013 07:19
jQuery mini
function $(selector, context) {
return (context || document).querySelector(selector)
}
$.all = function (selector, context) {
return Array.prototype.slice.call(
(context || document).querySelectorAll(selector)
)
}
@lvivski
lvivski / css-stats-ack.sh
Created October 7, 2012 09:09 — forked from pjkix/css-stats-ack.sh
shell script to generate some css file statistics
#!/bin/bash
## v1.0.6
## this script will gernerate css stats
### example output
# CSS STATS
# ----------
# Floats: 132