Skip to content

Instantly share code, notes, and snippets.

@bsodhi
bsodhi / dblp2pubs.js
Created April 22, 2023 09:24
Generates publications list in plain HTML from DBLP XML profile.
/**
* Functions that you can include in your web page to generate a list of
* publications from your DBLP profile.
*
* Example usage:
* <html><body onload="getPublicationsList('https://dblp.org/pid/43/10009.xml', '#pubs-list')">
* <h2>Articles</h2><div id="pubs-list">Loading...</div>
* </body></html>
*
*/
@bsodhi
bsodhi / scrape_pdf.py
Created November 17, 2022 09:57
Scaping PDF files
"""
Written with a lot of help from StackOverflow community
and Python API documentation -- greatly appreciated!
"""
import sys
import requests
import urllib3
import concurrent.futures
from bs4 import BeautifulSoup
from datetime import datetime as DT
@bsodhi
bsodhi / read.java
Created March 6, 2022 04:02 — forked from r0xsh/read.java
Android: Read file contents from Uri
public static byte[] readUri(Context context, Uri uri) throws IOException {
ParcelFileDescriptor pdf = context.getContentResolver().openFileDescriptor(uri, "r");
assert pdf != null;
assert pdf.getStatSize() <= Integer.MAX_VALUE;
byte[] data = new byte[(int) pdf.getStatSize()];
FileDescriptor fd = pdf.getFileDescriptor();
FileInputStream fileStream = new FileInputStream(fd);
fileStream.read(data);
from multiprocessing import Process, JoinableQueue, Value, Lock
import time
import logging
from abc import ABC, abstractmethod
class Runnable(ABC):
"""Abstract base class for tasks that can be submitted for
execution to the {Parrun} executor.
@bsodhi
bsodhi / extract_xml_nodes_data.c
Last active October 24, 2020 06:04
Extracting XML node's text using XPath API in C
/**
* This code is adapted from the sample available at:
* http://xmlsoft.org/tutorial/apd.html.
*
* Compile using the following command on linux/Mac:
* gcc -lxml2 extract_xml_nodes_data.c -o xml_prog
*/
#include <libxml/parser.h>
#include <libxml/xpath.h>
@bsodhi
bsodhi / local_socket_client_server.c
Created October 20, 2020 05:24
A socket based client-server in C
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdbool.h>
#include <pthread.h>
#include <sys/un.h>
#include <stddef.h>
@bsodhi
bsodhi / function_lookup_and_invocation.c
Created July 27, 2020 06:44
Dynamic function invocation in C using table lookup
/**
* When the function to be invoked is determined via a table lookup,
* following is one of the ways to invoke a dyamically loaded function in C.
* Help taken from: https://stackoverflow.com/a/1120834
*/
#include <stdio.h>
#include <string.h>
/**
* These should come from the header file of the respective service
@bsodhi
bsodhi / face_recognition_installation.md
Created July 26, 2020 14:55
Installing ageitgey/face_recognition on RPi buster

Installing face recognition on RaspberryPi 3 Buster

I assume that you have Raspbian 10 (Buster) installed on your RPi3, and are able to get to the shell in your RPi3. Once you are at the shell, do the following to install face_recognition:

  1. sudo apt-get update

  2. sudo apt-get upgrade

  3. sudo apt-get install build-essential cmake gfortran git wget curl graphicsmagick libgraphicsmagick1-dev libatlas-base-dev libavcodec-dev libavformat-dev libboost-all-dev libgtk2.0-dev libjpeg-dev liblapack-dev libswscale-dev pkg-config python3-dev python3-numpy python3-pip zip libjasper-dev libqtgui4 python3-pyqt5 libqt4-test libhdf5-dev libhdf5-serial-dev

  4. pip3 install opencv-python==3.4.6.27

@bsodhi
bsodhi / mysqlclient_installing.md
Last active February 22, 2020 16:00
Installing mysqlclient on macOS Mojave

Installing mysqlclient Python module on macOS Mojave requires mysql-client and SSL library to be available on the host. Following steps can be performed to achieve this:

  1. Install openssl using brew install openssl
  2. The above step should result in the openssl libraries to be placed in /usr/local/opt/openssl/lib/. You need to add that path to LIBRARY_PATH. export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
  3. Install mysql-client using brew install mysql-client This should place the mysql-client binaries under /usr/local/Cellar/mysql-client/
  4. Add location of mysql-client to the PATH. For example,
@bsodhi
bsodhi / myurl
Last active September 5, 2019 11:52
http://172.26.2.12:8000/add_dev