Skip to content

Instantly share code, notes, and snippets.

View beekalam's full-sized avatar
🐝
Focusing

Mohammad Reza Mansouri beekalam

🐝
Focusing
View GitHub Profile
(ns enjure.router.internal.radix-tree
(:require [clojure.string :as string])
(:require [clojure.pprint :refer [pprint]]))
(defn ->prefixtree
"Creates a prefix (radix) tree root"
[data prefix]
{:children prefix
  𝛌_____𝛌     
 ( o   o )
 (  =𝛌=  )
 (        )
 (         )
 (          )))))))))))
function TrieNode() {
this.children = {};
this.endOfWord = false;
}
function Trie() {
this.root = new TrieNode();
}
Trie.prototype.insert = function (word) {
(ns clojure-playground.trie3
(:require [clojure.pprint :refer [pprint]])
(:require [clojure.test :refer [is]]))
(defn insert-str-in-trie
[trie the-string]
(let [str-seq (map str the-string)]
(loop [remaining-chars str-seq
@beekalam
beekalam / run.sh
Created September 22, 2022 09:52 — forked from mahmoud-eskandari/README.md
SSH Tunnel as systemd service
systemctl enable ssht
systemctl start ssht
# Status
systemctl status ssht

save images as tar.gz:

docker save <image_name_1> <image_name_2> | gzip > images.tgz

then restore images (e.g on a target system):

@beekalam
beekalam / .customrc.sh
Created March 31, 2022 09:57 — forked from HackingGate/.customrc.sh
git incremental clone
#####
alias pc4=proxychains4
#####
git_incremental_clone()
{
REPO=$1
DIR=$2
git clone --recurse-submodules $REPO $DIR --depth=1
cd $DIR
@beekalam
beekalam / minifier.php
Created March 20, 2022 08:54
laravel minifier middleware
<?php
// @snippet.laravel
class Minifier
{
    /**
    * Handle an incoming request.
    *
    * @param \Illuminate\Http\Request $request
@beekalam
beekalam / method-src.php
Created March 20, 2022 08:51
get method source
<?php
// @snippet.reflection
public static function getMethodSource(\ReflectionMethod $method): string
{
    $path  = $method->getFileName();
    $lines = @file($path);
    $from  = $method->getStartLine();
    $to    = $method->getEndLine();
    $len   = $to - $from + 1;
    return implode(array_slice($lines, $from - 1, $len));
@beekalam
beekalam / function-src.php
Created March 20, 2022 08:48
get function source
<?php
// @snippet.reflection
function get_func_body($func,$print=false){
$func = new \ReflectionFunction($func);
$filename = $func->getFileName();
$start_line = $func->getStartLine() - 1; // it's actually - 1, otherwise you wont get the function() block
$end_line = $func->getEndLine();
$length = $end_line - $start_line;
$source = file($filename);