Skip to content

Instantly share code, notes, and snippets.

🔥
This is fine.

Gaurav Kamath st0le

Block or report user

Report or block st0le

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View popcount.py
def popcount(n):
c = 0
while n != 0:
c += n % 2
n //= 2
return c
def popcount_range_naive(n):
return sum(map(popcount, range(n + 1)))
View keybase.md

Keybase proof

I hereby claim:

  • I am ST0LE on github.
  • I am gauravkamath (https://keybase.io/gauravkamath) on keybase.
  • I have a public key whose fingerprint is AC20 EC1E 4274 DA5F 32E4 4704 B9C9 97B3 05BE A391

To claim this, I am signing this object:

@st0le
st0le / Find-FirstItem.ps1
Last active Mar 22, 2018
Simple Utility Function
View Find-FirstItem.ps1
Function Find-FirstItem {
[CmdletBinding()]
[Alias("ffi")]
param(
[Parameter(Mandatory, Position = 0)]
[ValidateNotNullOrEmpty()]
[string] $Filter
)
Get-ChildItem -Recurse -Filter $Filter | Select-Object -First 1 -ExpandProperty FullName
}
View Systray.cs
using System;
using System.Drawing;
using System.Windows.Forms;
namespace MyTrayApp
{
public class SysTrayApp : Form
{
[STAThread]
public static void Main()
@st0le
st0le / MediaKeys.ahk
Created Nov 14, 2017
Add MediaKey shortcuts to normal keyboard
View MediaKeys.ahk
; ^ = Ctrl
; volume up
^Numpad8::Volume_Up
; volume down
^Numpad2::Volume_Down
; volume mute
^Numpad0::Volume_Mute
@st0le
st0le / autoexec.cfg
Last active Jul 16, 2017
autoexec.cfg
View autoexec.cfg
alias +jumpthrow "+jump;-attack"
alias -jumpthrow "-jump"
bind mouse3 +jumpthrow
bind mouse5 +voicerecord
alias +fwdjumpthrow "+forward;+jump;-attack"
alias -fwdjumpthrow "-forward;-jump"
bind capslock +fwdjumpthrow
exec buyscript;
alias +djump "+jump; +duck"
alias -djump "-jump; -duck"
View dsalgo.md

Distributed Circular linked list sum

You are given a circular linked list whose nodes are distributed. Every node has next pointer and a method send(integer). A node can talk to its next node only. Different instances of same �threads are running in the nodes. How would you implement the run method of the thread class so that each node prints the sum of complete linked list.


Distributed binary tree sum

You are given a binary tree where each node has an integer value, a left, right and parent pointer. Every node is an independent distributed system where a thread is running in each node. You can talk to other node only by one method called "send(node, data)". And a node can call "send" only to its children or parent. How will you design the system so that all the nodes know the total sum of values of all the nodes in the binary tree and report them asynchronously.


Distributed doubly linked list sum

You are given a doubly linked list whose nodes are distributed. Every node has n

View huffman.py
from collections import Counter
from heapq import heapify, heappop, heappush
s = input()
c = Counter(s)
pq = [(c[k], k, None, None) for k in c]
codes = {}
heapify(pq)
while len(pq) > 1:
r = heappop(pq)
View list_dupes.py
import hashlib, os
unique = dict()
for filename in os.listdir('.'):
if os.path.isfile(filename):
filehash = hashlib.md5(open(filename, 'rb').read()).hexdigest()
if filehash not in unique:
unique[filehash] = filename
else:
print (filename + ' is a duplicate of ' + unique[filehash])
@st0le
st0le / wallhaven.py
Created Feb 28, 2017 — forked from avamsi/wallhaven.py
Python script to download wallpapers from wallhaven.
View wallhaven.py
from bs4 import BeautifulSoup
from itertools import count
import requests
url = 'http://alpha.wallhaven.cc/search?categories=101&sorting=favorites&order=desc&page='
jpg = 'http://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-%s.jpg'
png = 'http://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-%s.png'
status = '\r[page {:0>3}] [image {:0>2}|24] [{:.<24}]'.format
You can’t perform that action at this time.