Skip to content

Instantly share code, notes, and snippets.

View jcubic's full-sized avatar
🎯
Focusing

Jakub T. Jankiewicz jcubic

🎯
Focusing
View GitHub Profile
@jcubic
jcubic / example.js
Last active April 3, 2024 12:28
Simple S-Expression (lisp) paser in JavaScript
console.log(parse(`(define (square x)
"Function calculate square of a number"
(* x x))`)[0].toString());
// ==> (define (square x) "funkcja square wywołanie (square 10) zwraca 100" (* x x))
@jcubic
jcubic / index.html
Created December 21, 2023 16:03
CSS-in-JS that supports strict CSP - PoC
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Security-Policy" content="script-src code.jquery.com 'nonce-2726c7f26c'; style-src 'nonce-2726c7f26c'" />
<title></title>
<meta name="Description" content=""/>
<link rel="shortcut icon" href=""/>
<!--[if IE]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
@jcubic
jcubic / mail.py
Created April 3, 2023 09:43
Script that sends spoofed emails
#!/usr/bin/env python
from smtplib import SMTP_SSL as SMTP
from email.mime.text import MIMEText
from optparse import OptionParser
from email.Utils import formatdate
import sys
if __name__ == '__main__':
@jcubic
jcubic / index.html
Last active November 19, 2022 00:11
Server-Sent Events with Service worker issue
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
</head>
<body>
<button id="sse_start" disabled>Start</button>
<button id="sse_stop" disabled>Stop</button>
<pre id="output">Loading Service Worker</pre>
<script>
@jcubic
jcubic / cdn.md
Last active April 21, 2024 14:43
How to setup a literally free CDN
@jcubic
jcubic / sw.js
Created November 8, 2021 19:09
service worker for serving files from BrowserFS
/**@license
* ___ ___ _____ __ __ _ _____ _ _
* / __|_ _|_ _| \ \ / /__| |__ |_ _|__ _ _ _ __ (_)_ _ __ _| |
* | (_ || | | | \ \/\/ / -_) '_ \ | |/ -_) '_| ' \| | ' \/ _` | |
* \___|___| |_| \_/\_/\___|_.__/ |_|\___|_| |_|_|_|_|_||_\__,_|_|
*
* this is service worker and it's part of GIT Web terminal
*
* Copyright (c) 2018 Jakub Jankiewicz <http://jcubic.pl/me>
* Released under the MIT license
@jcubic
jcubic / bookmark.js
Last active February 17, 2021 19:38
16colo.rs Terminal ANSI rendering Bookmarklet
javascript:(function(next) {
/**
* Bookmarklet that will create terminal with ANSI rendering
* on 16colo.rs website (individual ANSI file)
*
* Copyright (C) Jakub T. Jankiewicz <https://jcubic.pl>
* Released under MIT license
*/
if (window.jQuery) {
return next(window.jQuery);
@jcubic
jcubic / onRender.js
Last active July 1, 2021 14:57
onRender jquery plugin
// ---------------------------------------------------------------------------
// :: execute callback function when shiny output element is modified
// :: the callback can be called multiple times if you use option onTime: false
// :: you can also use check option with function that will be check if
// :: before executing callback and removing observer
// ---------------------------------------------------------------------------
$.fn.onRender = function(callback, options) {
if (this.length === 0) {
throw new Error("Element doesn't exists! Try to wait until it's added to DOM.");
}
@jcubic
jcubic / SVGMatrix.js
Created April 29, 2020 17:34
SVGMatrix
/*
3x3 2D Matrix
[a c e]
[b d f]
[0 0 1]
*/
var DOMException = require('domexception');
@jcubic
jcubic / r-shell.js
Last active April 8, 2024 00:33
JavaScript bookmark that can be used to open interactive R shell in shiny app
javascript:(function($) {
var handlers = [];
if (typeof Shiny !== 'undefined') {
Shiny.addCustomMessageHandler("__EVAL__", function(data) {
handlers.forEach(function(handler) {
handler(data);
});
});
}
var index = 0;