Skip to content

Instantly share code, notes, and snippets.

@lv10
lv10 / Build VIM with python3
Last active November 25, 2023 23:42
Install Vim 8 with Python, Python 3 support on Ubuntu 20.04
# make sure you don't have any soon to be forgotten version of vim installed
$ sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-gui-common
# Install Deps
$ sudo apt-get install build-essential cmake
$ sudo apt-get install python3-dev
#Optional: so vim can be uninstalled again via `dpkg -r vim`
$ sudo apt-get install checkinstall
@lv10
lv10 / search_dict_key.py
Created December 20, 2018 16:02
Python Search key in a Nested Dictionaries
def _recursive_key_path(dictionary, key_to_find, key_path=[]):
if key_to_find in key_path:
return key_path
else:
for key, value in dictionary.items():
if key == key_to_find:
key_path.append(key)
return recursive(value, key_to_find, key_path)
if isinstance(value, dict):
key_path.append(key)
@lv10
lv10 / combinations.c
Created December 8, 2015 22:29
Recursive Combinations Fomula implementation in C c(n,k)=c(n-1,k)+c(n-1,k-1)
/*
*
* Recursive Combinations Fomula implementation in C
* c(n,k)=c(n-1,k)+c(n-1,k-1)
*
* */
long combine ( int n, int r )
{
if ( (n==r) || (r==0) || (n==0) )
@lv10
lv10 / gist:d9a94f6a949e65a9323a
Last active August 29, 2015 14:02
Delete duplicates from a table without primary key SQL
DELETE FROM claim_rates
WHERE ctid IN (SELECT
ctid
FROM (SELECT
ctid,
ROW_NUMBER()
OVER (
PARTITION BY claim_tag, rate_type, pricing_record_id
ORDER BY claim_tag, rate_type, pricing_record_id) AS rnum
FROM claim_rates) t
@lv10
lv10 / gist:8547663
Created January 21, 2014 20:24
Fetch Paper Names and Page Sizes for a Printer - Obj-C/C
// ================================
// COPrinterPaperSizes.h
// ================================
#import <Foundation/Foundation.h>
#define PAPER_NAME @"paper_name"
#define PAPER_SIZE @"paper_size"
@interface COPrinterPaperSizes: NSObject