Skip to content

Instantly share code, notes, and snippets.

View ansrivas's full-sized avatar

Ankur Srivastava ansrivas

View GitHub Profile
@ansrivas
ansrivas / sshFix.go
Created June 29, 2018 16:02
Fix ssh directory permissions
package main
import (
"log"
"os"
"os/user"
"path/filepath"
"strings"
"time"
)

$ vim /etc/profile.d/envvars.sh

export SCALA_ENV="prod"
export SPARK_HOME="/home/sparkuser/spark"
export PATH=$PATH:$SPARK_HOME
@ansrivas
ansrivas / static_vars.md
Created May 14, 2018 14:16
all static variables in a class
class Test(object):
    one = 1
    two = 2
print([k for k,v in Test.__dict__.items() if not k.startswith("__")])```
@ansrivas
ansrivas / tqmd.py
Created April 19, 2018 00:34
simulate sleep with tqdm
from time import sleep
from tqdm import trange
for i in trange(remaining.seconds, leave=True):
sleep(1)
# time.sleep(remaining.seconds)
@ansrivas
ansrivas / .gitignore
Created March 1, 2018 13:58
ignore all files except this .gitignore
# Ignore everything in this directory
*
# Except this file
!.gitignore
@ansrivas
ansrivas / subclasses.md
Last active February 26, 2018 12:15
Python subclassing explained
  1. Case1:

    Define Base.init(self)

class Base(object):
    def __init__(self):
        self.anattribute = 23
class Derived(Base):
    def __init__(self):
 Base.__init__(self)
043448c231e45ef9424e9c9a01d34b54adb06e6c27a3b67401767f35b231776f527c8c09411b24bde5703f44bd3a20889f10df9f2713154d27b61dddfc373e0541
@ansrivas
ansrivas / bootable.md
Created February 6, 2018 10:05
Create bootable usb with dd
  • Check lsblk to confirm the correct usb device ann use the group for eg. if the device is /dev/sdd1 then use /dev/sdd as the group

  • sudo dd bs=4M if=/home/user/Downloads/Fedora-Workstation-Live-x86_64-27-1.6.iso of=/dev/sdd conv=fdatasync

@ansrivas
ansrivas / delete_older_files.md
Last active January 15, 2018 15:52
Using find to delete files older than sometime

delete files older than 7 days

find ./ -type f -mtime +7 -exec rm -f {} \;
-mtime +n means strictly greater than, -mtime -n means strictly less than

@ansrivas
ansrivas / git.txt
Last active March 23, 2018 15:00
git revert stuff
# Make a steemit out of it
# Delete unwanted commits from your branch
git reset --hard last_working_commit_you_want
git push origin master/your-branch --force
# Revert a commit to a previous version
git revert --no-commit b6ce5d5