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 / 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 / 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;
@nepsilon
nepsilon / how-to-git-patch-diff.md
Last active May 10, 2024 06:53
How to generate and apply patches with git? — First published in fullweb.io issue #33

How to generate and apply patches with git?

It sometimes happen you need change code on a machine from which you cannot push to the repo. You’re ready to copy/paste what diff outputs to your local working copy.

You think there must be a better way to proceed and you’re right. It’s a simple 2 steps process:

1. Generate the patch:

git diff &gt; some-changes.patch
@bramus
bramus / paginationsequence.php
Last active February 2, 2023 16:01
Pagination Sequence Generator
<?php
/**
* Generate a sequence of numbers for use in a pagination system, the clever way.
* @author Bramus Van Damme <bramus@bram.us>
*
* The algorithm always returns the same amount of items in the sequence,
* indepdendent of the position of the current page.
*
* Example rows generated:
@lovasoa
lovasoa / node-walk.es6
Last active May 10, 2024 05:30
Walk through a directory recursively in node.js.
// ES6 version using asynchronous iterators, compatible with node v10.0+
const fs = require("fs");
const path = require("path");
async function* walk(dir) {
for await (const d of await fs.promises.opendir(dir)) {
const entry = path.join(dir, d.name);
if (d.isDirectory()) yield* walk(entry);
else if (d.isFile()) yield entry;