Skip to content

Instantly share code, notes, and snippets.

View arcolife's full-sized avatar

Archit Sharma arcolife

View GitHub Profile
@spranesh
spranesh / dispatch.py
Created May 21, 2011 09:43
Dynamic Dispatch in Python
def Analyse(obj):
""" Dynamic Dispatch based on object's class type.
This will call the AnalyseClassName
Example: if obj is of type Let, then call AnalyseLet,
if it is of type IfElse call AnalyseIfElse
"""
# Get obj's class name
class_name = obj.__class__.__name__
# Create the function name as a string
@jordanorelli
jordanorelli / client.go
Created May 7, 2012 17:16
rpc server example in go
package main
import (
"bufio"
"log"
"net/rpc"
"os"
)
func main() {
@m14t
m14t / fix_github_https_repo.sh
Created July 5, 2012 21:57
Convert HTTPS github clones to use SSH
#/bin/bash
#-- Script to automate https://help.github.com/articles/why-is-git-always-asking-for-my-password
REPO_URL=`git remote -v | grep -m1 '^origin' | sed -Ene's#.*(https://[^[:space:]]*).*#\1#p'`
if [ -z "$REPO_URL" ]; then
echo "-- ERROR: Could not identify Repo url."
echo " It is possible this repo is already using SSH instead of HTTPS."
exit
fi
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@grenade
grenade / 01-generate-ed25519-ssh-key.sh
Last active May 2, 2024 23:15
generate ed25519 ssh and gpg/pgp keys and set file permissions for ssh keys and config
#!/bin/bash
# generate new personal ed25519 ssh key
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "rob thijssen <rthijssen@gmail.com>"
# generate new host cert authority (host_ca) ed25519 ssh key
# used for signing host keys and creating host certs
ssh-keygen -t ed25519 -f manta_host_ca -C manta.network
eval "$(ssh-agent -s)"
@sloria
sloria / bobp-python.md
Last active May 12, 2024 06:54
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@clemsos
clemsos / csv_to_elastic_search_bulk_insert.py
Last active February 27, 2024 10:15
Elastic Search : index large csv files with Python Pandas
from pyelasticsearch import ElasticSearch
import pandas as pd
from time import time
root_path="/home/clemsos/Dev/mitras/"
raw_data_path=root_path+"data/"
csv_filename="week10.csv"
t0=time()
@kirelagin
kirelagin / tor-change-exitnode
Last active April 23, 2024 10:23
Shell script to force Tor exit node change
#!/bin/sh
###
#
# Change Tor exit node
#
# Sometimes when using Tor you'd like to change the IP address that
# servers see when you connect (that is, change your Tor exit node).
# This happens automatically from time to time, but this shell script
# lets you force it.
#
@ipoddubny
ipoddubny / ipconfig.md
Last active April 15, 2023 23:22
How to get public IP address from Linux shell

http

curl ifconfig.co
curl icanhazip.com
curl ifconfig.me
curl http://smart-ip.net/myip

telnet

@alfredopalhares
alfredopalhares / gist:d475257c84410c7fcca6
Last active February 15, 2024 12:15
Restoring a PDF file from chrome cache

So I was trying to do my duties as a good civilian by paying taxes of stuff you already own.

In this particular case it meant going to the website and try and generate a PDF document that would allow me to pay for said stuff. After 2 unsuccessful attempts to generate the PDF (got greeted by 500s), I finally got the PDF open on chromium (using the PDF preview) and trying to save, the browser crashed..

I then quickly reboot chromium and tried to generate the PDF again, only to find out that I can't, the website only allows you to generate the document and download once, this is a critical document used as prof and means to pay your taxes. It doesn't really make much sense that you only can download it once, but such is the way of life.

I've been suffering from this bug for quite a while, but it never affected me in this way.

The file wasn't on ~/Downloads, so I've tried browsing chrome://cache and after a while I found the PDF HTTP request, w