Skip to content

Instantly share code, notes, and snippets.

View bzhr's full-sized avatar
💜
Upbeat-ing

Bozhidar Hristov bzhr

💜
Upbeat-ing
View GitHub Profile
@jackiekazil
jackiekazil / rounding_decimals.md
Last active January 17, 2024 12:29
How do I round to 2 decimals in python?

How do I round to 2 decimals?

In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.

All the examples use demical types, except for the original value, which is automatically casted as a float.

To set the context of what we are working with, let's start with an original value.

Original Value

@staltz
staltz / introrx.md
Last active June 18, 2024 06:15
The introduction to Reactive Programming you've been missing
@d0c-s4vage
d0c-s4vage / flask_sqlalchemy_historify.py
Last active March 15, 2021 16:28
Flask SQLAlchemy Historify
# I used this code directly in my models.py - it expects a `db` variable to be
# present in the globals.
#
# I also used Flask-JWT in the application that used this code. If you're not using
# Flask-JWT, you should modify `get_current_username` to not check for a current
# user using Flask-JWT.
def historify(cls):
"""
Create a new history table for the provided database model (``cls``),

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@jessejanderson
jessejanderson / the_abcs_of_otp.md
Last active March 13, 2024 11:23
The ABCs of OTP

Music for working, programming, reading, …

…sleeping, meditating, yoga, after hour…. Mostly ambient, drone, (neo-)classical, dub, minimal techno, deep house, micro house, downtempo, slo-mo house, ketapop, schneckno, jetlagdisco, post-rock, lowfi hip hop…

Please feel free to comment your recommendations.

@codediodeio
codediodeio / index.js
Created June 28, 2017 15:54
Firebase Cloud Functions image thumbnail generator using Sharp for 4x faster resizing
const functions = require('firebase-functions');
const gcs = require('@google-cloud/storage')();
const sharp = require('sharp')
const _ = require('lodash');
const path = require('path');
const os = require('os');
exports.generateThumbnail = functions.storage.object('uploads/{imageId}').onChange(event => {
const object = event.data; // The Storage object.
@ynonp
ynonp / discourse_discussion.jsx
Created January 8, 2018 07:14
Embedding discourse comments in React
import React from 'react';
import PropTypes from 'prop-types';
export default class DiscussionBox extends React.Component {
static propTypes = {
discourseUrl: PropTypes.string.isRequired,
discourseEmbedUrl: PropTypes.string.isRequired,
};

Visual Studio Code shortcuts I use often

Navigation

Sidebar:

  • Cmd-Shift-F: search
  • Cmd-Shift-E: files

Navigating in current editor: