Skip to content

Instantly share code, notes, and snippets.

@nikhilweee
nikhilweee / statement-to-excel.py
Last active March 29, 2024 10:50
Convert HDFC Bank Credit Card statements from PDF to Excel
# This script is designed to convert bank statements from pdf to excel.
#
# It has been tweaked on HDFC Bank Credit Card statements,
# but in theory you can use it on any PDF document.
#
# The script depends on camelot-py,
# which can be installed using pip
#
# pip install "camelot-py[cv]"
const express = require('express');
const app = express();
// Application
app.get('/', function(req, res) {
if (process.env.NODE_ENV === 'development') {
for (var key in require.cache) {
delete require.cache[key];
}
}
@kuzetsa
kuzetsa / ntp.conf
Last active January 14, 2023 04:29
this configuration is what I'm using for OpenVZ
# OpenVZ is cheap, but the clock is disciplined by host
server 127.127.1.0 minpoll 3 maxpoll 3 prefer
fudge 127.127.1.0 stratum 1
# ntp_adjtime: Operation not permitted
disable kernel
rlimit memlock 128
mru maxmem 6912 maxage 32 initalloc 1 initmem 64 incalloc 256 incmem 64
@fab1an
fab1an / GeoJsonMapLayer.js
Last active January 10, 2022 03:50
React / Leaflet combination
export default class GeoJsonMapLayer extends React.Component {
render() {
return (
<div>
</div>
);
}
componentWillUnmount() {
if (this.layer) {
@Rich-Harris
Rich-Harris / service-workers.md
Last active May 6, 2024 22:10
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

Red [Needs: View]
L: charset "ABCDEFGHI"
N: charset "123456789"
D: union N charset "0"
p: []
repeat y 9 [
repeat x 9 [
col: either x = 1 [#"^(2028)"][#"A" + (x - 2)]

Broken Promises

Technical Decision

Eliminate all promises from application.

TL;DR

The Promise API is the source of many confusing errors in our application, using node style callbacks eliminates the issue without reducing code quality.

export const GoogleApi = function(opts) {
opts = opts || {}
const apiKey = opts.apiKey;
const libraries = opts.libraries || [];
const client = opts.client;
const URL = 'https://maps.googleapis.com/maps/api/js';
const googleVersion = '3.22';
let script = null;
if (typeof Promise === 'undefined') {
require.ensure([], (require) => {
require('imports?this=>window!es6-promise')
})
}
if (typeof fetch === 'undefined') {
require.ensure([], (require) => {
require('imports?self=>window!whatwg-fetch')
})