Skip to content

Instantly share code, notes, and snippets.

View st0le's full-sized avatar
💭
nohello

Gaurav Kamath st0le

💭
nohello
View GitHub Profile
#!/bin/sh
branch="$(git rev-parse --abbrev-ref HEAD)"
if [ "$branch" = "master" ]; then
echo "You can't commit directly to master branch"
exit 1
fi
@st0le
st0le / gist:c6964eb3efdfa043e1df325acb34fa6b
Created July 11, 2022 19:27
Build Rust projects without installing rust. (use a docker container)
FROM rust:latest
RUN apt update && apt upgrade -y
RUN apt install -y g++-mingw-w64-x86-64
RUN rustup target add x86_64-pc-windows-gnu
RUN rustup toolchain install stable-x86_64-pc-windows-gnu
WORKDIR /app
using System;
using System.Net;
using System.Net.NetworkInformation;
class Program
{
static void Main(string[] args)
{
foreach ( NetworkInterface netif in NetworkInterface.GetAllNetworkInterfaces() )
{
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <arpa/inet.h>
int main(int argc, char **argv)
{
if (argc < 2)
def is_match(text, pattern):
assert text != None
assert pattern != None
assert isinstance(text, str)
assert isinstance(pattern, str)
T, P = len(text), len(pattern)
def _is_match(ti, pi):
if pi == P:
@st0le
st0le / proto.py
Last active September 10, 2021 21:12
from sys import argv
print(len(argv))
print(argv)
@st0le
st0le / git-complete.ps1
Last active February 11, 2021 06:47
Lightweight git autocompletion.
# Basic Autocompleter for git
# Covers most usecases
Register-ArgumentCompleter -CommandName "git" -Native -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
$cmd = $commandAst.ToString() -split " "
# order is based on "popularity"
$supportedCommands = @("checkout", "add", "commit", "branch", "status", "pull", "push", "merge", "log", "stash")
$comps = @()
@st0le
st0le / killall.ps1
Created May 20, 2020 18:33 — forked from ReubenBond/killall.ps1
killall cmd for PowerShell with completion
# In a PS terminal, type "code $profile" and put this in there
function killall {
param(
[ArgumentCompleter(
{
param($cmd, $param, $values)
get-process |
? { $_.Name.StartsWith($values, [StringComparison]::OrdinalIgnoreCase) } |
Sort -Unique Name |
@st0le
st0le / PlaysTvDownloader.ps1
Last active January 5, 2020 09:01
Downloads all public videos of a user
# Copy and paste this in a Powershell window. Enter the userId at the prompt. Follow instruction below to get your userId
# download all PlaysTv videos of a user
# To find the user id, navigate to the your profile while logged in (IMPORTANT!)
# View source of the page, In the <html> tag there's data-conf attribute.
# The json in there will have the user id under [login_user.id]
function Safe-Title {
param (
$Description,
$EpochMilliseconds
@st0le
st0le / DraculaMod
Last active August 23, 2019 00:18
Windows Terminal Theme
{
"background": "#282A36",
"black": "#21222C",
"blue": "#F1FA8C",
"brightBlack": "#6272A4",
"brightBlue": "#D6ACFF",
"brightCyan": "#A4FFFF",
"brightGreen": "#69FF94",
"brightPurple": "#FF92DF",
"brightRed": "#FF6E6E",