Skip to content

Instantly share code, notes, and snippets.

@abmohan
abmohan / function.py
Created June 26, 2023 06:31 — forked from petrprikryl/function.py
Django table function
#############################
# Table Functions
#############################
'''
CREATE OR REPLACE FUNCTION get_user(INTEGER DEFAULT NULL, VARCHAR DEFAULT NULL)
RETURNS TABLE(
id INTEGER,
user_id INTEGER,
one_id INTEGER,
username VARCHAR,

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

@abmohan
abmohan / latency.txt
Created November 21, 2020 04:51 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@abmohan
abmohan / pip-save.sh
Last active November 14, 2020 01:59
pip install and save dependencies (i.e. Python equivalent of `npm install --save`)
# pip install and save to (and sort + dedupe) requirements.txt
function pip-save {
# loop through all listed requirements
for var in "$@"
do
# attempt to install it
pip install $var
# add it to the requirements.txt file
pip freeze | grep -i "^$var=" >> requirements.txt
@abmohan
abmohan / test_file_upload.py
Created July 1, 2020 05:15 — forked from rverton/test_file_upload.py
Test file upload with flask (Python3)
from io import BytesIO
def test_file_upload(client):
data = {
'field': 'value',
'file': (BytesIO(b'FILE CONTENT'), 'test.csv')
}
rv = client.post('/upload', buffered=True,
@abmohan
abmohan / Output
Created July 1, 2020 05:15 — forked from DazWorrall/Output
Testing file upload handling in Flask
in upload handler
in file close
..
----------------------------------------------------------------------
Ran 2 tests in 0.021s
OK
@abmohan
abmohan / 01-directory-structure.md
Created December 3, 2017 15:29 — forked from tracker1/01-directory-structure.md
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

Directories

  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used
@abmohan
abmohan / app.component.ts
Created April 3, 2017 02:27 — forked from Hotell/app.component.ts
@ngrx/store integration with ngMetadata/Angular 1
import { Store } from 'ngrx-one/store';
import { INCREMENT, DECREMENT, RESET } from './counter';
interface AppState {
counter: number;
}
@Component({
selector: 'my-app',
template: `
@abmohan
abmohan / clojure.md
Created January 26, 2017 01:55
Setting Up Clojure on OS X

Setting Up Clojure on OS X

I spent a lot of time trying to find a pretty optimal (for me) setup for Clojure… at the same time I was trying to dive in and learn it. This is never optimal; you shouldn't be fighting the environment while trying to learn something.

I feel like I went through a lot of pain searching Google, StackOverflow, blogs, and other sites for random tidbits of information and instructions.

This is a comprehensive "what I learned and what I ended up doing" that will hopefully be of use to others and act as a journal for myself if I ever have to do it again. I want to be very step-by-step and explain what's happening (and why) at each step.

I appreciate the effort you've put into documenting this, but there are a number of inaccuracies here that need to be addressed. We get

@abmohan
abmohan / CLAM_Client_DigitalOcean.md
Last active May 19, 2019 13:19
Set up a cloud CLAM Coin Digging/Mining Client on Ubuntu

Cloud CLAM Digger/Miner on Ubuntu

CLAMs are awesome!

Proof of stake, rather than proof of work, allows for everyone who's chipped in to receive a piece of the pie.

Follow the steps below to set up your own cloud CLAM digger (i.e. the equivalent of a bitcoin miner) on Digital Ocean

Setting up Digital Ocean