Skip to content

Instantly share code, notes, and snippets.

Avatar

Jakub T. Jankiewicz jcubic

View GitHub Profile
View SVGMatrix.js
/*
3x3 2D Matrix
[a c e]
[b d f]
[0 0 1]
*/
var DOMException = require('domexception');
@jcubic
jcubic / r-shell.js
Last active May 17, 2020
JavaScript bookmark that can be used to open interactive R shell in shiny app
View r-shell.js
javascript:(function($) {
var handlers = [];
if (typeof Shiny !== 'undefined') {
Shiny.addCustomMessageHandler("__EVAL__", function(data) {
handlers.forEach(function(handler) {
handler(data);
});
});
}
var index = 0;
@jcubic
jcubic / module.js
Last active Sep 3, 2018
Module definition function with namespace and dependencies
View module.js
// -----------------------------------------------------------------------------
// Copyright (c) 2018 Jakub Jankiewicz
// Released under MIT license
//
// generic namespace generator the constructor should declare private functions
// and variables and return public api, the module is created when all dependecies
// are resolved (all modules are created)
//
// @param namespace dot separated namespace that will be added to window object
// @param dependencies array of string (dependencies) can be empty array
@jcubic
jcubic / cert
Last active Jun 21, 2020
Upload SSL Certificate to DirectAdmin controlled domains
View cert
#!/bin/bash
output=$(mktemp);
sudo certbot certonly --manual --expand --manual-public-ip-logging-ok \
--preferred-challenges http -n \
-d <LIST OF COMMA SEPARATED DOMAINS AND SUBDOMAINS>\
--manual-auth-hook ./cert.py --agree-tos --email <EMAIL ADRESS> 2>&1 | tee $output
grep "Certificate not yet due for renewal" $output > /dev/null || \
@jcubic
jcubic / server.py
Created Feb 4, 2018
Simple HTTP server for static files
View server.py
#!/usr/bin/python
import socket
import re
import os
import threading
header_re = re.compile(r"(GET|POST) ([^ ]+) HTTP/", re.I)
def status(code):
@jcubic
jcubic / css.js
Created Jan 24, 2018
Monkey patch for jQuery css to handle custom properties aka css variables
View css.js
$.fn.css = (function(css) {
return function fn(key, value) {
var self = this;
if (arguments.length == 1 && $.isPlainObject(arguments[0])) {
var data = arguments[0];
Object.keys(data).forEach(function(key) {
fn.call(self, key, data[key]);
});
} else if (key.match(/^\s*--/)) {
if (typeof value === 'undefined') {
@jcubic
jcubic / compile
Last active Jun 24, 2020
POC for Emscripten Async code + jQuery Terminal
View compile
emcc -o main.html -s FETCH=1 -s NO_EXIT_RUNTIME=0 main.c
@jcubic
jcubic / .htaccess
Last active Dec 22, 2017
Simple url shortener in php and sqlite
View .htaccess
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule (.*) /index.php?$1
@jcubic
jcubic / shell.php
Created Dec 18, 2017
Simple jQuery Terminal based php shell
View shell.php
<?php
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
$_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' && isset($_POST['cmd'])) {
system($_POST['cmd']);
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
@jcubic
jcubic / git_sqllite.py
Created Oct 22, 2017
Create sqlite data base from git repo commits
View git_sqllite.py
#!/usr/bin/env python
import git
import json
import sqlite3
import re
import os
import os.path
def log(repo):
You can’t perform that action at this time.