Skip to content

Instantly share code, notes, and snippets.

View felipekm's full-sized avatar
🦈

Felipe Kautzmann felipekm

🦈
View GitHub Profile
@getify
getify / 1.md
Last active July 3, 2022 12:29
Part 2 of 2, of "In defense of blocks for local scopes", from https://gist.github.com/getify/712d994419326b53cabe20138161908b

In defense of blocks for local scopes (Part 2)

Some have leveled the criticism that "part 1" of this post is unnecessarily contriving a problem that doesn't really exist in "good code" -- if you really need to narrow a scope of some declarations in a function, then that function is too complex already and that bigger problem is what you need to fix.

Just to be extra clear: if a chunk of code is already reasonable to make a function, that's not the sort of code I'm talking about in either of these blog posts. If it's being called multiple times, or if it's completely independent and makes sense as its own logical chunk, make it a function. I'm talking about a different sort of code, a set of a few statements related to each other, that declare one or more variables, but which logically still belong inside another function. That's the context here.

OK, let's stop talking about this stuff abstractly.

A Real Example

What Hiring Should Look Like

This is definitely not the first time I've written about this topic, but I haven't written formally about it in quite awhile. So I want to revisit why I think technical-position interviewing is so poorly designed, and lay out what I think would be a better process.

I'm just one guy, with a bunch of strong opinions and a bunch of flaws. So take these suggestions with a grain of salt. I'm sure there's a lot of talented, passionate folks with other thoughts, and some are probably a lot more interesting and useful than my own.

But at the same time, I hope you'll set aside the assumptions and status quo of how interviewing is always done. Just because you were hired a certain way, and even if you liked it, doesn't mean that it's a good interview process to repeat.

If you're happy with the way technical interviewing currently works at your company, fine. Just stop, don't read any further. I'm not going to spend any effort trying to convince you otherwise.

@felipekm
felipekm / startec2.py
Created November 18, 2019 14:22
start ec2 instance python
import boto3
# defines ec2
ec2 = boto3.resource('ec2')
# lambda handler
def lambda_handler(event, context):
# builds an array filter to get EC2 instances with TAG `LIGAR`
arrOffInstancesFilter = [
@jsanta
jsanta / mem-monitor.sh
Created July 13, 2018 19:26
Script to restart PM2 procceses if memory exceeds limit
#!/bin/bash
memtotal=$(free | grep Mem | awk '{ print $2 }')
memuse=$(free | grep Mem | awk '{ print $3 }')
let "memusepercent = $memuse * 100 / $memtotal "
let "memtolerance = $memtotal * 0.9 "
echo "MemTotal: $memtotal (Usage tolerance: $memtolerance )"
echo "MemUsed: $memuse ($memusepercent %)"
if [ $memuse -ge $memtolerance ]; then
echo "Memory use over 90%"
@bashtoni
bashtoni / gist:995c0683bb18fd19eaefdc296a9401d8
Created July 4, 2018 10:48
Find ARN for ACM certificate for a given domain name
aws acm us-east-1 list-certificates --query CertificateSummaryList[].[CertificateArn,DomainName] \
--output text | grep example.com | cut -f1
@felipekm
felipekm / rhel-nodejs-config.sh
Last active July 22, 2020 19:30
RHEL NodeJS Server Pre Config
# NGINX | GIT
sudo yum install -y nginx git
# Install the current version of node version manager (nvm) by typing the following at the command line to install version 33.6
# currently using v0.35.2
curl -o- https://raw.githubusercontent.com/creationix/nvm/{VERSION}/install.sh | bash
# Activate nvm by typing the following at the command line.
. ~/.nvm/nvm.sh
@quangnd
quangnd / reduceExamples.js
Last active November 24, 2023 19:57
Some examples about reduce() in Javascript
//Example 1 - Calculate average value of an array (transform array into a single number)
var scores = [89, 76, 47, 95]
var initialValue = 0
var reducer = function (accumulator, item) {
return accumulator + item
}
var total = scores.reduce(reducer, initialValue)
var average = total / scores.length
/*Explain about function

This is a proposal for a lightning talk at the Reactive 2016 conference. If you like this, star the Gist.


Thinking metrics on React applications

In regular websites, it is common to send multiple events to track user clicks. Single Page Applications change the way you look at metrics. This is a talk about a simple pattern we created at Globo.com to manage a metrics layer for http://globoplay.globo.com. The talk will cover how to track user flow using Google Analytics and other services. We solved the challenge of tying metrics and components, keeping information across pages and having global data. Also some React, React Router and React Side Effects concepts like context, higher order components, history state will be covered.

'use strict';
const Module = require('module');
const originalCompile = Module.prototype._compile;
const nohook = function (content, filename, done) {
return done(content);
};
let currentHook = nohook;