Skip to content

Instantly share code, notes, and snippets.

@adimiti
adimiti / exporter.py
Last active May 23, 2020 06:09
Exports notes from pdf
# source - https://stackoverflow.com/a/13748949/10982983
import poppler, os.path
def comments_export(doc):
path = 'file://%s' % os.path.realpath(doc)
doc = poppler.document_new_from_file(path, None)
pages = [doc.get_page(i) for i in range(doc.get_n_pages())]
@adimiti
adimiti / backtrack.py
Created February 17, 2020 10:27
backtrack solver in python
import numpy as np
grid = [[b for b in range(9)][::] for a in range(9)]
def possible(y,x,n):
for a in range(9):
if n == grid[a][x]: return False
if n == grid[y][a]: return False
for a in range(3):
for b in range(3):
@adimiti
adimiti / iterative.sh
Created January 8, 2020 18:36
ReadLine history
rlwrap cat begin.txt - | myprogram
@adimiti
adimiti / case.c
Created January 6, 2020 07:28
some tests with switch in C
#include <stdio.h>
int main()
{
int i;
for (i=0;i<10;i++)
{
@adimiti
adimiti / map.c
Created December 30, 2019 08:14
The simple dictionary (hashtable) data structure from Section 6.6 of The C Programming Language.
#include <string.h>
#include <malloc.h>
struct nlist { /* table entry: */
struct nlist *next; /* next entry in chain */
char *name; /* defined name */
char *defn; /* replacement text */
};
@adimiti
adimiti / dump.c
Created October 11, 2019 08:20
Dump bytes
void dump(char *buff, int length);
void dump(char *buff, int length)
{
int i;
int j;
for (i=0;i<(length + 15)/16;i++)
{
for (j=0;j<16;j++)
import sys
N = 8
msg = [[] for i in range(N)]
for i in range(N):
for j in range(N):
h = (j - i + N) % N
# k[i] += x[j] * y[h]
msg[i] += ['{}*{}'.format(j, h)]
@adimiti
adimiti / vimhacks.md
Last active July 31, 2019 07:24
hacks for vim

VIMs config hacks

##What is a .un~ file or or why does Vim in the Terminal make the .un~ file?

:set noundofile

By default this option is turned off. You have explicitly enabled the undofile option in one of the initialization files. If you want your undofiles to be stored only in a particular directory, you can point the undodir option to a directory that will contain all your aggregated undofiles.

@adimiti
adimiti / Vis.vim
Created July 16, 2019 06:12
Select lines using ranges in Vim
command! -range Vis call setpos('.', [0,<line1>,0,0]) |
\ exe "normal V" |
\ call setpos('.', [0,<line2>,0,0])
:10,12Vis
@adimiti
adimiti / cscope-to-quickfix.txt
Created July 15, 2019 07:18
How to load the cscope results into the quick-fix window.
:set cscopequickfix=s-,c-,d-,i-,t-,e-,a-
" or in short:
:set csqf=s-,c-,d-,i-,t-,e-,a-