Skip to content

Instantly share code, notes, and snippets.

View nehaljwani's full-sized avatar

Nehal J Wani nehaljwani

View GitHub Profile
@nehaljwani
nehaljwani / generate_directory_index_caddystyle.py
Created February 1, 2022 04:40 — forked from glowinthedark/generate_directory_index_caddystyle.py
Generate directory index (recurse subfolders with `-r` or `--recursive`). Use `-h` or `--help` for all options
#!/usr/bin/env python3
# ---
# Copyright 2020 glowinthedark
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
#
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
@nehaljwani
nehaljwani / gdb_cheetsheet.txt
Last active January 13, 2022 20:24
GDB Cheetsheet
=======================================================================================================================================
You can run gdb with --args parameter,
gdb --args executablename arg1 arg2 arg3
If you want it to run automatically, place some commands in a file (e.g. 'run') and give it as argument: -x /tmp/cmds. Optionally you can run with -batch mode.
gdb -batch -x /tmp/cmds --args executablename arg1 arg2 arg3
=======================================================================================================================================
@nehaljwani
nehaljwani / openfortivpn_inside_netns.sh
Created July 12, 2020 16:16
OpenFortiVPN Inside Linux Network Namespace
#!/bin/bash
# start openconnect tunnel and shell inside Linux network namespace
#
# this is a fork of schnouki's script, see original blog post
# https://schnouki.net/posts/2014/12/12/openvpn-for-a-single-application-on-linux/
#
# original script can be found here
# https://gist.github.com/Schnouki/fd171bcb2d8c556e8fdf
# ------------ adjust values below ------------
@nehaljwani
nehaljwani / FindStdFilesystem.cmake
Created May 31, 2020 14:49
CMake: std::filesystem / std::experimental::filesystem
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
# This is a modified version of:
# https://github.com/vector-of-bool/CMakeCM/blob/master/modules/FindFilesystem.cmake
#[=======================================================================[.rst:
FindStdFilesystem
#################
@nehaljwani
nehaljwani / liboverride.c
Created April 28, 2020 22:24
Handy LD_PRELOAD-able library to override libc functions
#define _GNU_SOURCE
#include <dirent.h>
#include <dlfcn.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <syslog.h>
#include <unistd.h>
@nehaljwani
nehaljwani / tilda-dot-rc.sh
Last active June 26, 2020 16:16
NJW's dotrc
alias urldecode='python2.7 -c "import sys, urllib as ul; \
print ul.unquote_plus(sys.argv[1])"'
aria2c_ka() {
aria2c $(urldecode $1 | grep -wo 'magnet.*')
}
cfget () {
git clone https://github.com/conda-forge/$(pwd | awk -F'/' '{print $NF}')-feedstock
}
@nehaljwani
nehaljwani / gist:ef9b162e7c3b571f6ce5c1e709c97053
Created November 21, 2018 04:00 — forked from spudbean/gist:1558257
Look of disapproval and other emoticons
ಠ_ಠ
( ͡° ͜ʖ ͡°)
¯\_(ツ)_/¯
(╯°□°)╯︵ ┻━┻
http://www.fileformat.info/convert/text/upside-down.htm
WRTTN http://wrttn.me/30dbfd/
Unicode Emoticons
@nehaljwani
nehaljwani / current_utc_time.c
Created October 1, 2018 03:39 — forked from jbenet/current_utc_time.c
work around lack of clock_gettime in os x
/*
author: jbenet
os x, compile with: gcc -o testo test.c
linux, compile with: gcc -o testo test.c -lrt
*/
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
@nehaljwani
nehaljwani / add_k8s_node.groovy
Created December 8, 2017 11:34
Jenkins System Groovy: Add k8s node
import hudson.model.Label
toProvision = 5
podLabel = Label.get('el6')
cloud = Jenkins.instance.clouds.find { it.canProvision(podLabel) }
cloud.provision(podLabel, toProvision).collect().each {
node = it.future.get()
Jenkins.instance.addNode(node)
}
@nehaljwani
nehaljwani / conda_install_windows.bat
Created November 9, 2017 03:56
Silent Install Miniconda Windows
powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://repo.continuum.io/miniconda/Miniconda3-4.3.21-Windows-x86_64.exe', 'mc3.exe') }"
start /wait "" mc3.exe /InstallationType=JustMe /AddToPath=0 /RegisterPython=0 /NoRegistry=1 /S /D=%TEMP%\mc3