Skip to content

Instantly share code, notes, and snippets.

@kizdolf
kizdolf / display ms
Created July 10, 2015 15:01
milliseconds to something like 0h23m4s
function msWell(ms) {
return ~~((ms/1000)/3600)+'h'+~~(((ms/1000)%3600)/60)+'m'+~~((ms/1000)%60)+'s';
}
@kizdolf
kizdolf / bookmarks.json
Created September 9, 2015 07:24
some links
[
{
"url" : "https://github.com/nvbn/thefuck",
"title" : " nvbn/thefuck · GitHub",
},
{
"name" : "php",
"links" : [
{
"url" : "https://stackoverflow.com/questions/16496554/can-php-detect-4-byte-encoded-utf8-chars",
@kizdolf
kizdolf / easyKonami.js
Last active December 9, 2017 09:25
Konami code js, jQuery
var winner = ()=>{/*do what ever you want*/};
var konami = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65],
i = 0,
l = konami.length - 1;
(document).keyup(function(e){
i = (konami[i] == e.keyCode) ? ((i == l) ? 0 && winner() : i + 1) : 0;
});
@kizdolf
kizdolf / highlight.js
Created February 25, 2016 18:43 — forked from jonraasch/highlight.js
Live on-page text highlighting
/*
highlight v3 !! Modified by Jon Raasch (http://jonraasch.com) to fix IE6 bug !!
Highlights arbitrary terms.
<http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>
MIT license.
'use strict';
var fs = require('fs'),
readline = require('readline');
var ass_to_vtt = (file_in, file_out, cb)=>{
var order = [],
gotOrder = false;
fs.writeFileSync(file_out, 'WEBVTT\n\n');
readline.createInterface({
request.post(this.props.url)
.attach('file', file, file.name)
.on('progress', function(e){
var elem = {name: file.name, pct: parseInt(e.percent).toString() + '%'};
var current = this.state.uploading;
current[file.name] = elem;
this.setState({ uploading: current });
}.bind(this))
.on('error', function(err){
var current = this.state.uploading;
gource \
-s .06 \
-1280x720 \
--auto-skip-seconds .1 \
--seconds-per-day 0.1 \
--multi-sampling \
--stop-at-end \
--key \
--highlight-users \
--hide mouse,progress \
'use strict';
// Declare app level module which depends on views, and components
angular.module('appName', [
...
'appName.socket'
])
// just launch node on this file.
/*
There is a lot to do here.
TODO:
-youtube-dl fail to write thumbnail to mp3 file. We need to do it by hand.
- display is ugly as fuck. SO: first create a data structure around spawned
processes. Including playlist rank, track rank, track intel, playlist intel.
Then build a "lib" to retrieve what's the outuput is talking about and insert it into
correct data structure.
then on events trigger display on correc data structure.
@kizdolf
kizdolf / jsonb_recursive_merge.sql
Created September 1, 2022 14:51
jsonb_recursive_merge
-- from https://medium.com/hootsuite-engineering/recursively-merging-jsonb-in-postgresql-efd787c9fad7
-- with unique array values merge
CREATE OR REPLACE FUNCTION jsonb_recursive_merge(A jsonb, B jsonb)
RETURNS jsonb LANGUAGE SQL AS $$
SELECT
jsonb_object_agg(
coalesce(ka, kb),
CASE
WHEN va isnull THEN vb