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 / module.js
Last active September 3, 2018 08:32
Module definition function with namespace and dependencies
// -----------------------------------------------------------------------------
// 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 June 25, 2021 10:30
Upload SSL Certificate to DirectAdmin controlled domains
#!/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 February 4, 2018 18:23
Simple HTTP server for static files
#!/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 January 24, 2018 09:13
Monkey patch for jQuery css to handle custom properties aka css variables
$.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 June 28, 2022 16:36
POC for Emscripten Async code + jQuery Terminal
emcc -o main.html -s FETCH=1 -s NO_EXIT_RUNTIME=0 main.c
@jcubic
jcubic / .htaccess
Last active December 22, 2017 11:10
Simple url shortener in php and sqlite
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule (.*) /index.php?$1
@jcubic
jcubic / shell.php
Last active March 28, 2023 18:51
Simple jQuery Terminal based php shell
<?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 October 22, 2017 09:25
Create sqlite data base from git repo commits
#!/usr/bin/env python
import git
import json
import sqlite3
import re
import os
import os.path
def log(repo):
@jcubic
jcubic / file-explorer.html
Last active November 30, 2022 22:26
File Explorer in jQuery UI dialog with Editor
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>File Explorer using jQuery UI</title>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
<script src="jquery.filebrowser/js/jquery.filebrowser-src.js"></script>
<script src="json-rpc/json-rpc.js"></script>
@jcubic
jcubic / ReflectService.java
Last active August 9, 2017 20:55
ReflectService plugin
package com.example.package;
import android.content.Context;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.io.PrintWriter;