Skip to content

Instantly share code, notes, and snippets.

View prat0318's full-sized avatar
💭
Ubering on.

Prateek Agarwal prat0318

💭
Ubering on.
View GitHub Profile
@pirate
pirate / alfred-clipboard.sh
Last active December 5, 2023 18:12
Script to manage searching, backing up, and collecting infinite clipboard history from the Alfred Clipboard History on macOS.
#!/usr/bin/env bash
# This is a script that provides infinite history to get around Alfred's 3-month limit.
# It works by regularly backing up and appending the items in the alfred db to a
# sqlite database in the user's home folder. It also provides search functionality.
# https://www.alfredforum.com/topic/10969-keep-clipboard-history-forever/?tab=comments#comment-68859
# https://www.reddit.com/r/Alfred/comments/cde29x/script_to_manage_searching_backing_up_and/
# Example Usage:
# alfred-clipboard.sh backup
@sahilsk
sahilsk / kafka-cheat-sheet.md
Last active April 12, 2024 01:27 — forked from filipefigcorreia/kafka-cheat-sheet.md
Apache Kafka Cheat Sheet

Kafka Cheat Sheet

Display Topic Information

$ kafka-topics.sh --describe --zookeeper localhost:2181 --topic beacon
Topic:beacon	PartitionCount:6	ReplicationFactor:1	Configs:
	Topic: beacon	Partition: 0	Leader: 1	Replicas: 1	Isr: 1
	Topic: beacon	Partition: 1	Leader: 1	Replicas: 1	Isr: 1
import jenkins.model.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.plugins.credentials.impl.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
import org.jenkinsci.plugins.plaincredentials.*
import org.jenkinsci.plugins.plaincredentials.impl.*
import hudson.util.Secret
import hudson.plugins.sshslaves.*
@prat0318
prat0318 / permutations.py
Created December 16, 2013 05:48
Find all permutations
def print_permutations(str):
if(len(str) == 1): return [str]
perms = print_permutations(str[1:])
return [x[0:i]+str[0]+x[i:] for x in perms for i in range(len(x)+1)]
print print_permutations("abc")
@prat0318
prat0318 / next.py
Last active December 28, 2015 13:39
next greater in array
def next_greater(arr):
while(not is_rev_sorted(arr)):
for i in reversed(range(len(arr) - 1)):
if arr[i] < arr[i+1]: break
for j in reversed(range(len(arr))):
if arr[i] < arr[j]: break
swap(arr, i, j)
yield reverse(arr, i+1)
def swap(arr, i, j): arr[i], arr[j] = arr[j], arr[i]
@prat0318
prat0318 / lcs.py
Created November 17, 2013 04:12
sub optimal longest common substring
def longest_common_prefix(str1, str2):
result = ''
for i in range(len(str1)):
if(len(str2) > i and str1[i] == str2[i]):
result = result + str1[i]
else:
break
return result
def longest_common_substring(str1, str2):
def findOdd(arr):
index = 0
count = 1
last_char = arr[index]
while(index < len(arr)):
if(arr[index] != last_char):
break
count+=1
index+=1
count2 = 1
@prat0318
prat0318 / paren_matching.py
Last active December 27, 2015 05:39
Usage: paren(0,4,'')
#Usage: paren(0,4,'')
def paren(sum,remaining,str):
if sum < 0:
return
if remaining == 0:
print str+')'*sum
return
paren(sum+1,remaining-1,str+'(')
paren(sum-1,remaining,str+')')