Skip to content

Instantly share code, notes, and snippets.

View maciejjankowski's full-sized avatar
🦍
hu!

Maciej Jankowski maciejjankowski

🦍
hu!
View GitHub Profile
@maciejjankowski
maciejjankowski / gist:ffded8e03a1f3459ce2f
Last active August 29, 2015 14:07
using casperView to see what is going on with your script
var casper = require('casper').create({
viewPortSize : {
width: 1024,
height: 768
},
onStepComplete : function(arg){
show(); // THIS IS FOR CAPTURING SCREENSHOTS AFTER A STEP IS COMPLETE
},
pageSettings : {
// loadImages: false // speeds up
@maciejjankowski
maciejjankowski / tabelajzin.js
Last active November 2, 2015 13:36
this is how you converts array of arrays into tables
function tabelajzing(a){
return ["<tr>\n<th>",
a.map(function (e, i) {
return e.join("</th>\n<td>")
}).join("</td></tr>\n<tr>\n<th>"),
"</td>\n</tr>\n"
].join("")
}
var yourHtml = function () {
@maciejjankowski
maciejjankowski / download table to excel csv.js
Last active December 30, 2021 18:47
download table to excel csv.js. Charset MUST be UTF-16LE - this is the only solution that worked with Excel on Mac
function exportTableToCSV($table, filename) {
var $rows = $table.find('tr:has(td,th)'),
// Temporary delimiter characters unlikely to be typed by keyboard
// This is to avoid accidentally splitting the actual contents
tmpColDelim = String.fromCharCode(11), // vertical tab character
tmpRowDelim = String.fromCharCode(0), // null character
// actual delimiter characters for CSV format
(function(){
var msgs = document.querySelectorAll('swx-message');
var mLen = msgs.length;
var out = []
for (let i=0; i<mLen; i++){
let r = [];
let m = msgs[i];
let user = (m.querySelector('.tileName') && m.querySelector('.tileName').innerText.trim()) || '-';
let timestamp = (m.querySelector('[data-bind^="text: setBottom"]') && m.querySelector('[data-bind^="text: setBottom"]').innerText.trim()) || '';
let content = m.querySelector('.content').innerText.trim().replace(/\n/g,'\\n') || '';
@maciejjankowski
maciejjankowski / qlizing-sequelize
Created November 28, 2017 12:45
GraphQL-izing sequelization
var sequelize={literal:()=>'',INTEGER:'INTEGER', STRING:'STRING', 'DATE':'DATE', 'DATEONLY': 'DATEONLY'};
var t={'STRING':'graphql.GraphQLString', 'INTEGER':'graphql.GraphQLInt', 'DATE':'graphqlDate.GraphQLDateTime', 'DATEONLY':'graphqlDate.GraphQLDateTime'};
var ql=(x)=>'{'+Object.keys(x).map(k=>(`${k} : { type : ${t[x[k].type]}, resolve(o){return o.${k}}}`)).join(',')+'}'
@maciejjankowski
maciejjankowski / python-touchviz-osc.pl
Last active January 30, 2018 08:54
python osc touchviz
import argparse
import random
import time
from itertools import chain
from pythonosc import osc_message_builder
from pythonosc import udp_client
# add easing iterators https://gist.github.com/th0ma5w/9883420
@maciejjankowski
maciejjankowski / refactorings.py
Last active January 9, 2019 12:23
Refactoring exercises
# https://github.com/RefactoringGuru/refactoring-examples/tree/master/simple/python
# 1
def disabilityAmount():
if seniority < 2:
return 0
if monthsDisabled > 12:
return 0
if isPartTime:
return 0
@maciejjankowski
maciejjankowski / microgranny sox convert sample rate.sh
Last active May 15, 2019 21:57
convert sample rate command line sox
for file in *
do
if [ ! -d "$file" ] && [ ! "$file" == 'convert.sh' ] ; then
sox $file -b 16 -c 1 -r 48k "converted/$file"
fi
done
@maciejjankowski
maciejjankowski / bookmarklet.js
Created September 27, 2019 21:05
github bookmarking bookmarklet
const month = new Date().toDateString().split(' ')[1];
const year = new Date().toDateString().split(' ')[3];
if (location.href.indexOf(`github.com/maciejjankowski/${year}/wiki`) > -1) {
const searchToken = '# Worth checking:\n';
const textarea = document.querySelector('#gollum-editor-body');
const textIndex = textarea.value.indexOf(searchToken);
const textLength = searchToken.length;
textarea.value =
textarea.value.slice(0, textIndex + textLength) +
@maciejjankowski
maciejjankowski / bookmarklet.js
Last active May 12, 2020 08:09
github bookmark bookmarklet
const month = new Date().toDateString().split(' ')[1];
const year = new Date().toDateString().split(' ')[3];
if (location.href.indexOf(`github.com/maciejjankowski/${year}/wiki`) > -1) {
const searchToken = '# Worth checking:\n';
const textarea = document.querySelector('#gollum-editor-body');
const textIndex = textarea.value.indexOf(searchToken);
const textLength = searchToken.length;
textarea.value =
textarea.value.slice(0, textIndex + textLength) +
prompt() +