Skip to content

Instantly share code, notes, and snippets.

View bipinstha7's full-sized avatar
🎯
Focusing

Bipin Shrestha bipinstha7

🎯
Focusing
View GitHub Profile
@bipinstha7
bipinstha7 / EventComponent.js
Created April 4, 2021 10:06 — forked from hartzis/EventComponent.js
Touch Event Handling React Component
import React from 'react';
export default class EventComponent extends React.Component {
constructor(props) {
super(props);
this._onTouchStart = this._onTouchStart.bind(this);
this._onTouchMove = this._onTouchMove.bind(this);
this._onTouchEnd = this._onTouchEnd.bind(this);
@bipinstha7
bipinstha7 / random.md
Created May 28, 2021 13:56 — forked from joepie91/random.md
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@bipinstha7
bipinstha7 / app.js
Created July 12, 2021 03:56
Bree test setup for maintainer
const Bree = require('bree');
const { Worker } = require('worker_threads');
class App {
constructor() {
this.app = express();
this.routes();
this.scheduler();
}
@bipinstha7
bipinstha7 / exit_the_cloud.md
Created November 6, 2025 06:52 — forked from rameerez/exit_the_cloud.md
☁️ How I got off the cloud and migrated everything from AWS to a VPS in Hetzner

☁️ How I got off the cloud and migrated everything from AWS to a VPS in Hetzner

This is an opinionated handbook on how I migrated all my Rails apps off the cloud and into VPS.

This is how I manage real production loads for my Rails apps. It assumes:

  • Rails 7+
  • Ruby 3+
  • PostgreSQL
  • Ubuntu Server 24.04
  • Capistrano, Puma, Nginx
@bipinstha7
bipinstha7 / postgres-production-setup.sh
Created November 6, 2025 07:10 — forked from rameerez/postgres-production-setup.sh
PostgreSQL Production Server Setup - Set up a new Ubuntu Server 24.04 LTS machine to run a production Postgres server
#!/bin/bash
# This script takes a clean Ubuntu Server 24.04 LTS image and installs and configures
# everything needed to deploy a production-ready PostgreSQL server.
set -euo pipefail
# --- AESTHETICS ---
GREEN='\033[0;32m'