Skip to content

Instantly share code, notes, and snippets.

@korzo
korzo / index.js
Last active July 8, 2022 17:21
Reverse array benchmark
// npm i benchmark microtime
//
// https://jsben.ch/QlNfk
const suite = new (require("benchmark").Suite)();
const limit = 1000;
suite
.add("reverse", function () {
const arr = [];
for (var i = 0; i <= limit; i++) {
@korzo
korzo / extract_text.js
Created May 30, 2021 13:00
Typingclub.com extract exercise text
[...document.querySelectorAll(".token_unit").entries()].map(e => e[1].innerText).map(e => {
if(!e.trim()) {
return " ";
}
return e;
}).join("");
@korzo
korzo / Export-Chocolatey.ps1
Created August 29, 2017 04:37 — forked from alimbada/Export-Chocolatey.ps1
Export installed Chocolatey packages as chocolatey script
choco list -lo -r -y | % { $_.Split('|') | select -First 1 } | % { "choco install " + $_ + " -y" }
function convertToRoman(num) {
var first = "";
var second = "";
var third = "";
var count = "";
var placeHolder = "";
var addFirst = "";
var addSecond = "";
var answer = "";
var test = "";
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, PUT, OPTIONS, PATCH, DELETE"
Header always set Access-Control-Allow-Headers "X-Accept-Charset,X-Accept,Content-Type"
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L,E=HTTP_ORIGIN:%{HTTP:ORIGIN}]]
@korzo
korzo / 0_reuse_code.js
Created April 4, 2016 02:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@korzo
korzo / ucm_remapper.php
Created December 1, 2015 01:27
Rebuilt Joomla's ucm_content and ucm_base tables for articles
<?php
/**
* @author Federico Liva <mail@federicoliva.info>
* @copyright Copyright (C)2015 Federico Liva. All rights reserved.
* @license GNU General Public License, version 2 or later
*/
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('max_execution_time', 0);
@korzo
korzo / lastfm_export.js
Created November 29, 2015 23:27
Last FM export playlist
// http://jsbin.com/vivucuceco/edit?output
var csv = '',
link,
div;
jQuery("#thePlaylist tr").each(function(i,e){
if (i > 0) {
var as = jQuery("a", jQuery("td", e)[2]).each(function(j, el){
csv = csv + '"'+ el.innerHTML + '";"' + el.href + '"';
if (j === 0) {
csv = csv + ';';
@korzo
korzo / default.vcl
Created November 5, 2015 10:52 — forked from fevangelou/default.vcl_PREFACE.md
The perfect Varnish configuration for Joomla (& other CMS based) websites
#################################################################################
### The perfect Varnish configuration for Joomla (& other CMS based) websites ###
#################################################################################
# USE: Place the contents of this configuration inside the main
# Varnish configuration file, located in: /etc/varnish/default.vcl (root server access required - obviously)
# IMPORTANT: The following setup assumes a 2 minute cache time. You can safely increase
# this to 5 mins for less busier sites or drop it to 1 min or even 30s for high traffic sites.
" .vimrc of Bart Trojanowski
"
" You can get a more upto date version from
" http://www.jukie.net/~bart/conf/vimrc
"
" Most files sourced by this vimrc are located here:
" http://www.jukie.net/~bart/conf/vim/
"
" ---------------------------------------------------------------------------