Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@wojtekmaj
wojtekmaj / .gitignore
Last active April 23, 2024 13:08
How to upgrade Yarn to Yarn Modern (v4 at the moment) seamlessly
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
@flarn2006
flarn2006 / ScreenTint.cs
Created February 4, 2016 04:12
Screen tinting code for C#
// Created by flarn2006 <flarn2006@gmail.com>
// Licensed under MIT License
using System;
using System.Runtime.InteropServices;
namespace YourNamespaceHere //TODO: change me
{
static class ScreenTint
{
// Uncompressed version of
// https://gist.github.com/munificent/b1bcd969063da3e6c298be070a22b604
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#include <stdbool.h> // 2008-2019
const int HEIGHT = 40;
const int WIDTH = 80;
@zec4o
zec4o / postman-api-testing.md
Last active April 23, 2024 13:05
Testes Automatizados de API com Postman
@mike-lawrence
mike-lawrence / helper_functions.r
Last active April 23, 2024 13:03
Stan vs LME4 for hiearchical within-subjects designs with binomial outcomes
#' Installs any packages not already installed
#' @examples
#' \dontrun{
#' install_if_missing(c('tidyverse','github.com/stan-dev/cmdstanr'))
#' }
install_if_missing = function(pkgs){
missing_pkgs = NULL
for(this_pkg in pkgs){
@ZucchiniZe
ZucchiniZe / list-files-in-dir.clj
Created February 15, 2016 10:00
simple clojure function to recursively list files in directories.
(let [directory (clojure.java.io/file "/path/to/list")
dir? #(.isDirectory %)]
(map #(.getPath %)
(filter (comp not dir?)
(tree-seq dir? #(.listFiles %) directory))))
@luismts
luismts / GitCommitBestPractices.md
Last active April 23, 2024 13:02
Git Tips and Git Commit Best Practices

Git Commit Best Practices

Basic Rules

Commit Related Changes

A commit should be a wrapper for related changes. For example, fixing two different bugs should produce two separate commits. Small commits make it easier for other developers to understand the changes and roll them back if something went wrong. With tools like the staging area and the ability to stage only parts of a file, Git makes it easy to create very granular commits.

Commit Often

Committing often keeps your commits small and, again, helps you commit only related changes. Moreover, it allows you to share your code more frequently with others. That way it‘s easier for everyone to integrate changes regularly and avoid having merge conflicts. Having large commits and sharing them infrequently, in contrast, makes it hard to solve conflicts.

@alexbruno
alexbruno / valid.cnpj.ts
Last active April 23, 2024 13:02
Validação de CNPJ
// Regex para validação de string no formato CNPJ
export const regexCNPJ = /^\d{2}.\d{3}.\d{3}\/\d{4}-\d{2}$/
// Método de validação
// Referência: https://pt.wikipedia.org/wiki/Cadastro_Nacional_da_Pessoa_Jur%C3%ADdica
export function validCNPJ(value: string | number | number[] = '') {
if (!value) return false
// Aceita receber o valor como string, número ou array com todos os dígitos
const isString = typeof value === 'string'
@xgp
xgp / Dockerfile
Last active April 23, 2024 13:01
Keycloak 17 example using JGroups JDBC_PING discovery protocol for Infinispan
FROM quay.io/keycloak/keycloak:17.0.0 as builder
ENV KC_METRICS_ENABLED=true
ENV KC_FEATURES=preview
ENV KC_DB=postgres
ENV KC_HTTP_RELATIVE_PATH=/auth
# specify the custom cache config file here
ENV KC_CACHE_CONFIG_FILE=cache-ispn-jdbc-ping.xml
# copy the custom cache config file into the keycloak conf dir
@Immolare
Immolare / merge-zip-files-to-folder-script.php
Last active April 23, 2024 13:01
Merge files from zip archive to a destination folder
const ZIP_FILEPATH = '/path';
const ZIP_FILENAME = 'archive.zip';
const ZIP_SUBDIRNAME = 'subdir'; // Folder inside archive
const ZIP_MAINDIRNAME = "maindir"; // Target folder containing files
/* If small archive folder use PHP. Note, on some big archives it doesn't extract all subfolders and files */
function mergeFromZipPHP()
{
$zip = new ZipArchive; // need to be isntalled on server
$zipPath = self::ZIP_FILEPATH.'/'.self::ZIP_FILENAME;