Skip to content

Instantly share code, notes, and snippets.

View PriitParmakson's full-sized avatar

Priit Parmakson PriitParmakson

  • Tallinn, Estonia
View GitHub Profile
@adisbladis
adisbladis / pkijs-decode-pem-node.js
Created May 10, 2018 03:04
Minimal example of loading a PEM certificate using pkijs (in nodejs)
#!/usr/bin/env node
// Minimal example of loading a PEM certificate using pkijs (in node)
// babel-polyfill needs to be loaded for pkijs
// It uses webcrypto which needs browser shims
require('babel-polyfill')
const Pkijs = require('pkijs')
const Asn1js = require('asn1js')
const FS = require('fs')
@wolfgangmeyers
wolfgangmeyers / golang-test-count.sh
Created October 21, 2016 20:28
How to count the number of running tests for a go project
go test ./... -v | grep -c RUN
@alexislagante
alexislagante / lcs.js
Created November 2, 2015 15:53
Longest common subsequence in Javascript
function LCS(s1, s2) {
var result = [];
for (var i=0; i<=s1.length; i++) {
result.push([]);
for (var j=0; j<=s2.length; j++) {
var currValue = 0;
if (i==0 || j==0) {
currValue = 0;
} else if (s1.charAt(i-1) == s2.charAt(j-1)) {
currValue = result[i-1][j-1] + 1;
@roryokane
roryokane / 1 – myers (default) algorithm.diff
Last active March 25, 2024 03:02
Comparison between Git diff algorithms: myers (default) vs. patience (example favors patience)
diff --git a/file.c b/file.c
index 6faa5a3..e3af329 100644
--- a/file.c
+++ b/file.c
@@ -1,26 +1,25 @@
#include <stdio.h>
-// Frobs foo heartily
-int frobnitz(int foo)
+int fib(int n)
@bobspace
bobspace / css_colors.js
Last active June 24, 2024 13:46
All of the CSS Color names in a big javascript object.
// CSS Color Names
// Compiled by @bobspace.
//
// A javascript object containing all of the color names listed in the CSS Spec.
// This used to be a big array, but the hex values are useful too, so now it's an object.
// If you need the names as an array use Object.keys, but you already knew that!
//
// The full list can be found here: https://www.w3schools.com/cssref/css_colors.asp
// Use it as you please, 'cuz you can't, like, own a color, man.
@andris9
andris9 / nodejs_idcard.js
Created August 8, 2011 19:51
Node.js + ID kaart
var https = require('https'),
fs = require('fs'),
utillib = require('util');
var options = {
key: fs.readFileSync('private_key.pem'),
cert: fs.readFileSync('certificate.pem'),
ca: [
fs.readFileSync('ESTEID-SK 2007.PEM.cer'),
fs.readFileSync('ESTEID-SK.PEM.cer'),
@andrei-m
andrei-m / levenshtein.js
Last active July 11, 2024 13:01
Levenshtein distance between two given strings implemented in JavaScript and usable as a Node.js module
/*
Copyright (c) 2011 Andrei Mackenzie
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE