Skip to content

Instantly share code, notes, and snippets.

View tuxdna's full-sized avatar

Saleem Ansari tuxdna

View GitHub Profile
@tuxdna
tuxdna / README.md
Last active March 10, 2023 13:02
Git clone without deep history

Git references

Git clone without deep history

Git clone without deep history make cloning faster when we only need the latest code.

With full history

First run

@tuxdna
tuxdna / output.md
Created August 27, 2018 06:30
Pivot example - stackoverflow.com/questions/52033359
$ python3 pivot-pandas.py
        date stock_code  price
0 2018-08-27        001   10.0
1 2018-08-27        002   11.0
2 2018-08-27        003   12.0
3 2018-08-27        004   13.0
4 2018-08-26        001   14.0
5 2018-08-26 002 15.0
@tuxdna
tuxdna / readme.md
Last active May 28, 2018 12:27
Learn gradle

Groovy

//System.out.println("Hello World!")
//println("Hello World!")
//
//println "Hello World!"
//

class MyClass {
@tuxdna
tuxdna / gantt_charts.ipynb
Last active March 22, 2018 12:13
GraphImporter issue
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tuxdna
tuxdna / README.md
Last active February 13, 2018 21:34
Probability problem

Given a 6 sided dice, how many number of throws are required to guarantee a 6 as output?

This solution is basically finding expectation over 1 roll, 2 rolls, 3 rolls ... and so on until infinite rolls of dice. Basically SUM( k * P(rolls=k)) for k = 1 to infinity. Now probability we get a 6 in exactly kth roll is defined as P(rolls=k) = q^(k-1) * p, where p is probability we get a 6 in kth roll, and q^(k-1) is probability we do not get a 6 in all k-1 rolls. I guess it still cannot guarantee that we will always get a 6, rather that if we roll on average of 6 times in a row, we will get definitely get a 6. Quite interesting problem indeed.

References:

@tuxdna
tuxdna / README.md
Created February 9, 2018 07:01
Why software estimation fails?
@tuxdna
tuxdna / closest_pair2d.py
Last active February 8, 2018 14:11
Some coding problems
# find closest pair of points in 2d space in O(nlogn)
import sys
import math
def euclidean_distance(p1, p2):
x1, y1 = p1
x2, y2 = p2
return math.sqrt((x2-x1)**2 + (y2 - y1)**2)
@tuxdna
tuxdna / README.md
Last active February 3, 2018 21:05
Estimating n log n via a estimation like newtons method

Estimating hard to invert functions

Works for

  • n log(n)
  • n! ( Factorial function )
$ python function_estimation.py 
@tuxdna
tuxdna / README.md
Last active March 7, 2018 10:11
Sync graph data

How to run?

Create config.py from config.py.template and fill in your AUTH token, and the target URL.

Then invoke the grpah sync:

$ python3 perform_graph_sync.py package input-file.json maven

Invoking url: http://.../api/v1/graphsync/sync_all/maven/HTTPClient%3AHTTPClient
@tuxdna
tuxdna / readme.md
Created November 26, 2017 14:07
Create portable encrypted filesystem

Create a disk file with random data

$ truncate -s 50G encrypted_backup.disk

Setup encryption for that device file

$ cryptsetup --verbose --verify-passphrase -s 512 luksFormat encrypted_backup.disk