Skip to content

Instantly share code, notes, and snippets.

View anuragteapot's full-sized avatar
🔥
try {} catch(err) {}

Anurag Kumar anuragteapot

🔥
try {} catch(err) {}
View GitHub Profile
@anuragteapot
anuragteapot / app.js
Created May 14, 2020 17:09 — forked from joshnuss/app.js
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./permission"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
import * as Sentry from "@sentry/node";
import imagemin from "imagemin";
import mozjpeg from "imagemin-mozjpeg";
import sharp from "sharp";
import isJpg from "is-jpg";
import * as aws from "aws-sdk";
import { Upload } from "../../types/graphqlUtils";
import { generateFilename } from "./generateFilename";
export const s3 = new aws.S3({
@anuragteapot
anuragteapot / ffmpeg.md
Created December 27, 2019 00:42 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

@anuragteapot
anuragteapot / nginxproxy.md
Created October 9, 2019 20:45 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@anuragteapot
anuragteapot / mysql-docker.sh
Created September 6, 2019 22:04 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@anuragteapot
anuragteapot / ID.js
Created July 1, 2019 21:39
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`
@anuragteapot
anuragteapot / docker-help.md
Created June 12, 2019 20:38 — forked from bradtraversy/docker-help.md
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@anuragteapot
anuragteapot / gist:ecd6878801f389599cdf562acb6d01f6
Created December 13, 2018 09:45 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@anuragteapot
anuragteapot / closeConnection.php
Created November 13, 2018 15:13 — forked from bubba-h57/closeConnection.php
Easy way to close connections to the browser and continue processing on the server.
<?php
/**
* Close the connection to the browser but continue processing the operation
* @param $body
*/
public function closeConnection($body, $responseCode){
// Cause we are clever and don't want the rest of the script to be bound by a timeout.
// Set to zero so no time limit is imposed from here on out.
set_time_limit(0);
@anuragteapot
anuragteapot / snake.asm
Created November 13, 2018 04:46 — forked from PraveshKoirala/snake.asm
8086 Snake game MASM compatible
;*******************************************************************************************************************
; Snake Game By *
; HERO-DAI *
;*******************************************************************************************************************
;code is not well-commented, sorry about that, I'll try to comment it nice and well, but can't make any
;promises, Also, this code writes directly into the video memory instead of int 21H (21H is slow) except
;at some certain points (like displaying scores and the intro)
;and next time someone tells you to not use goto, ask them to code in assembly without goto... :P