Skip to content

Instantly share code, notes, and snippets.

View tanvirraj's full-sized avatar
🚢
coding

Tanvir Raj tanvirraj

🚢
coding
View GitHub Profile
@mgerring
mgerring / actions.py
Created September 5, 2012 22:04
"Export to CSV" action for django admin
import unicodecsv
from django.http import HttpResponse
def export_as_csv_action(description="Export selected objects as CSV file",
fields=None, exclude=None, header=True):
"""
This function returns an export csv action
'fields' and 'exclude' work like in django ModelForm
'header' is whether or not to output the column names as the first row
"""
@rsms
rsms / cgroup2-cpu-limit.sh
Last active December 1, 2022 04:08
Example of limiting how much CPU a process can use in linux with cgroup2
#!/bin/sh
set -e
# Documentation and guides:
# https://docs.kernel.org/admin-guide/cgroup-v2.html
# https://lore.kernel.org/lkml/20160812221742.GA24736@cmpxchg.org/T/
# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/managing_monitoring_and_updating_the_kernel/using-cgroups-v2-to-control-distribution-of-cpu-time-for-applications_managing-monitoring-and-updating-the-kernel
# remove if already exists
[ -e /sys/fs/cgroup/test1 ] && rmdir /sys/fs/cgroup/test1
@danielgross
danielgross / screenshot2pdf.py
Created November 19, 2022 15:41
Take screenshots of websites and place into PDF
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from PIL import Image
import io
import time
import os
import sys
import numpy as np
from fpdf import FPDF

Welcome to the wacky world of almost 30 years of web

All of the following values for the <script type=" ••• "> will cause inline or external JavaScript to execute:

Value Note
"" The default value of script.type (eg: no type attribute present)
"text/javascript" The official JavaScript MIME type
"application/javascript" Legacy MIME type from when semantics mattered
"text/x-javascript" Legacy MIME type from before JavaScript was accepted as a valid MIME type
@jacob-ebey
jacob-ebey / deferred-overview.md
Last active September 11, 2023 09:10
Deferred Overview

Remix Deferred

Remix Deferred is currently implemented on top of React's Suspense model but is not limited to React. This will be a quick dive into how "promise over the wire" is accomplished.

SSR + Hydration

It isn't rocket science, but a quick recap of how frameworks such as react do SSR:

  1. Load data
  2. Render the app
@dscape
dscape / The-Innovators-Dilemma-Summary.md
Created February 22, 2011 21:02
Notes on The Innovator’s Dilemma: When New Technologies Cause Great Firms to Fail

Notes on The Innovator’s Dilemma: When New Technologies Cause Great Firms to Fail

  • Book by: Clayton M. Christensen, Cambridge, Massachusetts: Harvard Business School Press, 1997
  • Prepared by: B.B. McBreen. See [PDF][1] (more readable but it's not plain text)

Summary

  1. Market progress is separate from technology progress. Customers do not always know what they need.
  2. Innovation requires resource allocation which is extraordinarily difficult for disruptive technologies.
  3. Disruptive technology needs a new market. Old customers are less relevant. Disruptive technology is a marketing problem, not a technological one.
@phpfour
phpfour / git-revert.md
Created January 17, 2024 14:19
How to use git to revert a committed file to an earlier version

To revert a committed file to an earlier version using Git, you can use the git checkout command. Here's how you can do it:

git checkout {{commit_hash}} -- {{file_path}}

Replace {{commit_hash}} with the hash of the commit you want to revert to, and {{file_path}} with the path to the file you want to revert.

For example, if you want to revert the file script.js to an earlier version with the commit hash abc123, you would run:

@swyxio
swyxio / 1.md
Last active February 8, 2024 22:30
Learn In Public - 7 opinions for your tech career

2019 update: this essay has been updated on my personal site, together with a followup on how to get started

2020 update: I'm now writing a book with updated versions of all these essays and 35 other chapters!!!!

1. Learn in public

If there's a golden rule, it's this one, so I put it first. All the other rules are more or less elaborations of this rule #1.

You already know that you will never be done learning. But most people "learn in private", and lurk. They consume content without creating any themselves. Again, that's fine, but we're here to talk about being in the top quintile. What you do here is to have a habit of creating learning exhaust. Write blogs and tutorials and cheatsheets. Speak at meetups and conferences. Ask and answer things on Stackoverflow or Reddit. (Avoid the walled gardens like Slack and Discourse, they're not public). Make Youtube videos

@gaearon
gaearon / prepack-gentle-intro-1.md
Last active February 13, 2024 14:30
A Gentle Introduction to Prepack, Part 1

Note:

When this guide is more complete, the plan is to move it into Prepack documentation.
For now I put it out as a gist to gather initial feedback.

A Gentle Introduction to Prepack (Part 1)

If you're building JavaScript apps, you might already be familiar with some tools that compile JavaScript code to equivalent JavaScript code:

  • Babel lets you use newer JavaScript language features, and outputs equivalent code that targets older JavaScript engines.