Skip to content

Instantly share code, notes, and snippets.

View aki237's full-sized avatar

Akilan Elango aki237

  • Tuticorin
View GitHub Profile
@aki237
aki237 / Bleh.txt
Last active February 13, 2023 10:24
Tets Gist
This is a test containingg the word "up".
BEGIN MESSAGE.
KwHFhOKK1N5KU6u NIvYYl6DiJAvzg8 HfsNng19lzZeQfz ERPDbV3KQJ85TkJ
VSM2SV1JCgmjeqn OGZsdFdX3udTCKq 6Xr2MZHgg6IughO rsarZ82QlGxawV1
v8UZ4NQgzDKGk6E 7hyuw2cF0oXMaSg yyi4nkpvZMRCZjb 3hmz85JC8zYAn4w
p0iL3Vahm7cvmgg FpfuTcyunRSXT5j wslxC21.
END MESSAGE.
@aki237
aki237 / keybase.md
Last active February 8, 2022 06:20

Keybase proof

I hereby claim:

  • I am aki237 on github.
  • I am akisensei (https://keybase.io/akisensei) on keybase.
  • I have a public key ASBXK94IVDdJ3D3AGZ5ldrk03GEjabmu6mcHcFINMrSNDgo

To claim this, I am signing this object:

@aki237
aki237 / lisptoken.py
Created November 22, 2017 09:27
Tokeninzing lisp in python
#!/usr/bin/python3
class Tokenizer:
OPEN_BRACKET = '('
CLOSE_BRACKET = ')'
"""Tokenizer class is used to tokenize a lisp statement into separate symbols"""
def __init__(self, expression):
"""Class constructor used to initialize some member values"""
self.exp = expression.strip()
// import this awesome package : github.com/cheggaaa/pb
// Create a new bar with int64 content corresponding to the total file size.
bar := pb.New64(head.ContentLength)
// Refresh rate - Nanosecond is too much... Just for fun...
bar.RefreshRate = time.Nanosecond
// Show the download speed.
bar.ShowSpeed = true
// Units : B/s (autmatically switches to MB/s kB/s etc.,)
bar.Units = pb.U_BYTES
func addParts(filename string, files []string) {
// filename : filename of full file.
// files : array of filenames of parts.
// Create if not found and open mode as append..
// So writing means adding.
out, err := os.OpenFile(filename, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
// usual.
check err
func Out(file *os.File, c *sync.WaitGroup, nth int, from, size int64, written chan int64) {
// Parameters :
// + file *os.File : temp file where contents have to be written.
// + c *sync.WaitGroup : To inform the main function that this connection has ended....
// + nth int : Nth connection. Not needed. but say ou want to print nth connection failed or
// something like that.
// + from int64 : from which byte
// + size int64 : how much have to returned
// + written chan int64 : as said before used send how much have been written from various connections.
// Loop and make 50 go routines or cncurrent function calls....
for count < 50 {
// Size (in no. of bytes) that has to be requested from the server
size := int64(bpc)
// If all that left is less than itself download the rest
// This generally happens in the last connection....
if total-size < size {
size = total
}
total := head.ContentLength
// Say I want to make 50 connections.
// bpc is bytes per connection
bpc := total / 50
// Get the filename....
outfile := path.Base(url)
// Create a directory for our temp sections.
err = os.Mkdir(filepath.Join("/tmp/", outfile), 0755)
// We need a URL to be downloaded.
if len(os.Args) < 2 {
fmt.Println("One more commandline argument needed. (url)")
return
}
// assign it to a variable.
url := os.Args[1]
// I'm not checking the URL passed for validity or url query parameters.