Skip to content

Instantly share code, notes, and snippets.

View s-c-p's full-sized avatar
🍄

S C P s-c-p

🍄
  • India
View GitHub Profile
@s-c-p
s-c-p / reducedDateRepresentation.py
Created March 26, 2017 11:52
An algorithm that assigns unique (values) hashes to all dates in an year.
import time, json
big = ["January", "March", "May", "July", "August", "October", "December"]
small = ["April", "June", "September", "November"]
class DateHasher(object):
""" duh... """
def __init__(self, dayMultiplier=12, monthMultiplier=31):
self.dayMultiplier = dayMultiplier
@s-c-p
s-c-p / 2-way-py-sqlite
Last active July 15, 2017 15:11
2 way binding for codec-like behavior connecting python and sqlite
import time
import sqlite3
import datetime
sqlite3.register_adapter(float, py2sql)
sqlite3.register_converter("pyTS", sql2py)
py2sql = lambda unix_epoch: str(datetime.datetime.fromtimestamp(unix_epoch))
sql2py = lambda strTime: datetime.datetime.timestamp(
wget http://download4.operacdn.com/ftp/pub/opera/desktop/40.0.2308.62/linux/opera-stable_40.0.2308.62_amd64.deb
sudo apt install apt-transport-https libcurl3
sudo dpkg -i opera-stable_40.0.2308.62_amd64.deb
# press yes on prompt
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt update
sudo apt install sublime-text
subl
@s-c-p
s-c-p / terminator.conf
Created October 7, 2017 01:39
Config for my terminator terminal
[global_config]
[keybindings]
[layouts]
[[default]]
[[[child1]]]
parent = window0
type = Terminal
[[[window0]]]
parent = ""
type = Window
call plug#begin('~/.vim/plugged')
Plug 'vim-airline/vim-airline'
Plug 'https://github.com/vim-python/python-syntax.git'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" https://github.com/terryma/vim-multiple-cursors.git
call plug#end()
let g:python_highlight_all=1
colorscheme brog
--understand what we are looking at
.tables
PRAGMA table_info(moz_bookmarks);
-- now take a look at the diagram connecting bookmarks and places @ http://www.forensicswiki.org/wiki/Mozilla_Firefox_3_History_File_Format
.headers on
.mode csv
.output exported-bookmarks
SELECT
bm.id, bm.type, bm.parent, bm.position, bm.title, pl.url,
import uuid
import random
import sqlite3
conn = sqlite3.connect("test.db")
cur = conn.cursor()
cur.execute("CREATE TABLE testing (uuid BLOB, information TEXT)")
# this is the best way to store uuid in sqlite, blobs, see--
# https://wtanaka.com/node/8106
localStorage.jwt = 'header.payload.signature';
let auth_fetch = function(api_url, token) {
let myHeader = new Headers();
myHeader.append('Content-Type', 'json/application');
myHeader.append('Authorization', 'Bearer ' + token);
let request = new Request(api_url,
{ method: 'GET'
"""
allows you to use switch case in python, like so
```
...
x = 5
...
...
with switch(x, locals()) as (case, default):
@case(4)