Skip to content

Instantly share code, notes, and snippets.

View patrickpissurno's full-sized avatar
🚀

Patrick Pissurno patrickpissurno

🚀
View GitHub Profile
@patrickfav
patrickfav / AesCbcExample.java
Last active May 14, 2024 05:25
Companion code to my article about AES+CBC with Encrypt-then-MAC.
package at.favre.lib.armadillo;
import org.junit.Test;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.util.Arrays;
@mrmartineau
mrmartineau / stimulus.md
Last active May 12, 2024 04:35
Stimulus cheatsheet
@morristech
morristech / DownloadFileWithRetrofit2RxJava.java
Created December 29, 2016 11:36 — forked from lsurvila/DownloadFileWithRetrofit2RxJava.java
Download file with Retrofit 2, OkHttp, Okio and RxJava
import com.squareup.okhttp.ResponseBody;
import okio.BufferedSink;
import okio.Okio;
import retrofit.Response;
import retrofit.http.GET;
import retrofit.http.Query;
import rx.Observable;
interface ApiService {
@newyankeecodeshop
newyankeecodeshop / ServingES6.md
Last active June 19, 2021 07:36
Serving ES6 to modern browsers

Background

Recently I noticed that Safari 10 for Mac/iOS had achieved 100% support for ES6. With that in mind, I began to look at the browser landscape and see how thorough the support in the other browsers. Also, how does that compare to Babel and its core-js runtime. According to an ES6 compatability table, Chrome, Firefox, and IE Edge have all surpassed what the Babel transpiler can generate in conjunction with runtime polyfills. The Babel/core-js combination achieves 71% support for ES6, which is quite a bit lower than the latest browsers provide.

It made me ask the question, "Do we need to run the babel es2015 preset anymore?", at least if our target audience is using Chrome, Firefox, or Safari.

It's clear that, for now, we can't create a site or application that only serves ES6. That will exclude users of Internet Explorer and various older browsers running on older iOS and Android devices. For example, Safari on iOS 9 has pretty mediocre ES6 support.

@kleo
kleo / android-ssh-server
Last active April 4, 2023 02:31
GNURoot Debian Jessie Android SSH Server
# GNURoot Debian Jessie Android SSH Server
# Google Play Store: https://play.google.com/store/apps/details?id=com.gnuroot.debian
# Github: https://github.com/corbinlc/GNURootDebian
# change root password
passwd
apt update
apt install -y nano
@anhldbk
anhldbk / README.md
Last active March 3, 2024 16:36
TLS client & server in NodeJS

1. Overview

This is an example of using module tls in NodeJS to create a client securely connecting to a TLS server.

It is a modified version from documentation about TLS, in which:

  • The server is a simple echo one. Clients connect to it, get the same thing back if they send anything to the server.
  • The server is a TLS-based server.
  • Clients somehow get the server's public key and use it to work securely with the server

2. Preparation

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
function telefone_validation(telefone) {
//retira todos os caracteres menos os numeros
telefone = telefone.replace(/\D/g, '');
//verifica se tem a qtde de numero correto
if (!(telefone.length >= 10 && telefone.length <= 11)) return false;
//Se tiver 11 caracteres, verificar se começa com 9 o celular
if (telefone.length == 11 && parseInt(telefone.substring(2, 3)) != 9) return false;
@kustra
kustra / HeaderFooterRecyclerViewAdapter.java
Last active March 15, 2021 03:58 — forked from mheras/HeaderFooterRecyclerViewAdapter.java
Header & footer support for RecyclerView.Adapter, with custom ViewHolder types for the content, header and footer
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
public abstract class HeaderFooterRecyclerViewAdapter<
ContentViewHolder extends RecyclerView.ViewHolder,
HeaderViewHolder extends RecyclerView.ViewHolder,
FooterViewHolder extends RecyclerView.ViewHolder>
extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@karpathy
karpathy / min-char-rnn.py
Last active May 19, 2024 16:44
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)