Skip to content

Instantly share code, notes, and snippets.

View iammateus's full-sized avatar
🎯
Focusing

Mateus Soares iammateus

🎯
Focusing
View GitHub Profile
@tuananh
tuananh / check-mime-type-from-base64-string-node.js
Created April 7, 2018 14:33
Check mime type from base64 string in Node.js
const fileType = require('file-type')
const base64String = 'iVBORw0KGgoAAAANSUhEUgAAAC0AAAAtCAYAAAA6GuKaAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAhOAAAITgBRZYxYAAAABxpRE9UAAAAAgAAAAAAAAAXAAAAKAAAABcAAAAWAAABW85tpoQAAAEnSURBVGgF7JbLDYMwDIYZoSN0pI7QUdikI+QESAXJozACR6SCRO2IHIBgnIRHKhUpQsSO/fFjnCRJwDWAun3exbOvsldX5oBjYAaQH/nTuoC0fkv7Kn8gnGIAOXhjUxTHj8BhFSXBUQfCGmh9p3iHwLdFcUdQ2BPWEgsoj4OG665Ug5igsSSZKLaTvaF86zQCS1dm6U4wji+YpQK8pcvYERyTsd3DKRblX1IxM9cpPH9poeJjDTupcmQJbdb42CXO+umkwjRsV0HF4EjVAmKDtZqpwQcElarm7WfdgGhnihy6nqgdu8pGzInaOBl6+PH+7AZIeFdabTomChecBcbm0cfa2PryloC6b1+9XW9Bzu16e8dJmBsif4YkckBrff+hz/pqP6n0FwAA//85LScuAAAA+0lEQVTV1u0NgyAQBuAboSN0pI7QUdykI/ALSaoJozgCP5tUE8tL0FiQSNNWORM/IEQfLucB9U09cjuJGxhetmjNLNqahlbeOKHhpeddXTmh4aVRixMnNLyEw6IFE7hwYFyGtr5wQMM5oz28Kxluwd0b2KOLjnYU5WkGNtKl1mw9GaP7Q6mzhZvC0sTAFWGXHaXVbVeXl8DUc9/IqoxoyyplXO0/enl3y/WqbKPzuIh/GOFwHj7H9/o5TXYOh9Cw7avKv8uh3qwSISynjQKPlemXPynel1w4clC5Y/ARC/92kyV2wYaTwjYROegrzVb6aIzD+Hl7Gb4ws/0Cqd8IYgt7isgAAAAASUVORK5CYII='
const mimeInfo = fileType(Buffer.from(ba

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?

@joncardasis
joncardasis / Storing-Images-On-Github.md
Last active May 19, 2024 20:11
Storing Images and Demos in your Repo

Storing Images and Demos in your Repo

In this quick walkthough you'll learn how to create a separate branch in your repo to house your screenshots and demo gifs for use in your master's readme.

How to

1. Clone a fresh copy of your repo

In order to prevent any loss of work it is best to clone the repo in a separate location to complete this task.

2. Create a new branch

Create a new branch in your repo by using git checkout --orphan assets

Github Two-Factor Authentication (2FA) for Brazil via SMS

The Github doesn't provide country code for Brazil (+55). To add this option, just run the code below in your console. The option Brazil +55 will be the first on the list, already selected:


🇧🇷 [pt-BR]

Autenticação em dois fatores (2FA) do GitHub para o Brasil via SMS

@danharper
danharper / gulpfile.js
Last active April 11, 2024 08:31
New ES6 project with Babel, Browserify & Gulp
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var watchify = require('watchify');
var babel = require('babelify');
function compile(watch) {
var bundler = watchify(browserify('./src/index.js', { debug: true }).transform(babel));
@tmarshall
tmarshall / aws-sns-example.js
Last active October 30, 2022 06:12
aws-sdk sns example, in Node.js
var AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: '{AWS_KEY}',
secretAccessKey: '{AWS_SECRET}',
region: '{SNS_REGION}'
});
var sns = new AWS.SNS();
@crtr0
crtr0 / client.js
Created June 8, 2012 17:02
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});