Skip to content

Instantly share code, notes, and snippets.

View jbalatero's full-sized avatar
🏠
Working from home

Jim Well Balatero jbalatero

🏠
Working from home
View GitHub Profile
@Jiab77
Jiab77 / real-time-php-fpm-status.md
Last active May 5, 2024 16:13
Real-time PHP-FPM Status

Real-time PHP-FPM Status

This gist will explain you how to enable an undocumented feature of PHP-FPM which will give a real-time performance stats.

Everybody knows the famous phpinfo() and the page it generates, right? Then the real-time PHP-FPM status page design is very similar.

image

Some informations from the top are not displayed to avoid security issues.

Enable PHP-FPM Status

@Nedson202
Nedson202 / NetworkDetector.jsx
Last active February 23, 2022 00:11
Higher order component that watches for changes in network connection
import React, { Component } from 'react';
export default function (ComposedComponent) {
class NetworkDetector extends Component {
state = {
isDisconnected: false
}
componentDidMount() {
this.handleConnectionChange();
@JacobJohansen
JacobJohansen / AuthyToOtherAuthenticator.md
Created October 20, 2017 15:12 — forked from gboudreau/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy

Generating Authy passwords on other authenticators


There is an increasing count of applications which use Authy for two-factor authentication. However many users who aren't using Authy, have their own authenticator setup up already and do not wish to use two applications for generating passwords.

Since I use 1Password for all of my password storing/generating needs, I was looking for a solution to use Authy passwords on that. I couldn't find any completely working solutions, however I stumbled upon a gist by Brian Hartvigsen. His post had a neat code with it to generate QR codes (beware, through Google) for you to use on your favorite authenticator.

His method is to extract the secret keys using Authy's Google Chrome app via Developer Tools. If this was not possible, I guess people would be reverse engineering the Android app or something like that. But when I tried that code, nothing appeared on the screen. My gues

@Geoyi
Geoyi / install virtualenv ubuntu 16.04.md
Created September 16, 2017 12:19 — forked from frfahim/install virtualenv ubuntu 16.04.md
How to install virtual environment on ubuntu 16.04

How to install virtualenv:

Install pip first

sudo apt-get install python3-pip

Then install virtualenv using pip3

sudo pip3 install virtualenv 
@maheshwaghmare
maheshwaghmare / function-execution-time.php
Created August 18, 2017 06:52
PHP Calculate Function Execution Time.
<?php
// Start time.
$time_start = microtime(true);
// Execute your logic here.
// End time.
$time_end = microtime(true);
@roalcantara
roalcantara / git_push_to_remote_with_pem_auth.sh
Last active January 24, 2020 02:42
Git push to remote with pem authentication
# generate public/private keys using ssh-keygen
ssh-keygen -t rsa
# change the permissions of the .pem file so only the root user can read it
chmod 400 amazon-generated-key.pem
# copy the machine to the remote repository
ssh-copy-id -i ~/.ssh/id_rsa.pub amazon-generated-key.pem ec2-user@amazon-instance-public-dns
# or
@Dev-Dipesh
Dev-Dipesh / rabbitmq_notes.md
Last active May 28, 2024 14:58
Why RabbitMQ is better over Redis and notes on RabbitMq.

Redis is Database whereas RabbitMQ was designed as a message router or message-orientated-middleware (mom), so I'm sure if you look for benchmarks, you'll find that RabbitMQ will outperform Redis when it comes to message routing.

RabbitMQ is written in Erlang which was specifically designed by the telecom industry to route messages, you get clustering out of the box due to it being written in Erlang which means in a clustered environment, RabbitMQ will outperform Redis even further.

Furthermore, you get guaranteed delivery of messages due to the AMQP protocol, in other words, if the network drops while consuming the message, the consumer won't be able to say thanks for the message, so the consumer will drop the message and Rabbit will requeue the message, if you publish a message and the queue didn't say thanks to the publisher due to network problems or timeouts, Rabbit will drop the message and the publisher will keep on trying to publish the message. You can have publish retries with backoff policies, so

@noelboss
noelboss / git-deployment.md
Last active June 12, 2024 00:28
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

@sebmarkbage
sebmarkbage / Enhance.js
Last active January 31, 2024 18:33
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@drio
drio / producer-consumer-go.md
Last active January 6, 2024 15:00
producer consumer in go explained

Producer consumer pattern

Question: Can you write code implementing the consumer and producer pattern?

This is a classic concurrency problem where we have threads generating data to be consumed (producers) by other threads (consumers).

The implementation with POSIX threads can be a pain in the ass but it is quite straight forward in golang thanks to its concurrency constructs.