Skip to content

Instantly share code, notes, and snippets.

View ThangLeQuoc's full-sized avatar
:octocat:
Keep smashing the keyboard

Thang Le Quoc ThangLeQuoc

:octocat:
Keep smashing the keyboard
View GitHub Profile
@nvtuan305
nvtuan305 / normalize_string.go
Created December 4, 2020 08:40
golang: normalize string (include Vietnamese)
package main
import (
"fmt"
"golang.org/x/text/runes"
"golang.org/x/text/transform"
"golang.org/x/text/unicode/norm"
"strings"
"unicode"
)
@Hakky54
Hakky54 / java_keytool_cheat_sheet.md
Last active June 13, 2024 06:44
Keytool Cheat Sheet - Some list of keytool commands for create, check and verify your keys

Keytool CheatSheet 🔐

Some history

This cheat sheet came into life when I started working on a tutorial of setting up one way tls and two way tls, which can be found here: GitHub - Mutual TLS SSL

Creation and importing

Generate a Java keystore and key pair

keytool -genkeypair -keyalg RSA -keysize 2048 -keystore keystore.jks -alias server -validity 3650
@t-eckert
t-eckert / flat-ui-v1.json
Last active November 17, 2022 04:09
Flat UI Color Scheme V1 implemented as Windows Terminal color scheme. https://flatuicolors.com/palette/defo
{
"background":"#000000",
"black":"#000000",
"blue":"#2980b9",
"brightBlack":"#7f8c8d",
"brightBlue":"#3498db",
"brightCyan":"#1abc9c",
"brightGreen":"#2ecc71",
"brightPurple":"#9b59b6",
"brightRed":"#e74c3c",
@iamitshri
iamitshri / Stopwatch.java
Created December 10, 2018 02:44
Using stopwatch from package org.apache.commons.lang3.time
package com.amit;
import org.apache.commons.lang3.time.StopWatch;
import lombok.extern.slf4j.Slf4j;
/**
* Hello world!
*
*/
@lmakarov
lmakarov / lambda-basic-auth.js
Created August 30, 2017 19:15
Basic HTTP Authentication for CloudFront with Lambda@Edge
'use strict';
exports.handler = (event, context, callback) => {
// Get request and request headers
const request = event.Records[0].cf.request;
const headers = request.headers;
// Configure authentication
const authUser = 'user';
const authPass = 'pass';
@roalcantara
roalcantara / elasticsearch.rb
Created March 24, 2017 14:58
Rails > Disabling elasticsearch requests durying rspec tests
# spec/support/elasticsearch.rb
RSpec.configure do |config|
config.before :each do
stub_request(:any, /localhost:9200/).to_return(body: "<html>a webpage!</html>", status: 200)
end
end
@evantoli
evantoli / GitConfigHttpProxy.md
Last active June 13, 2024 15:17
Configure Git to use a proxy

Configure Git to use a proxy

In Brief

You may need to configure a proxy server if you're having trouble cloning or fetching from a remote repository or getting an error like unable to access '...' Couldn't resolve host '...'.

Consider something like:

@anataliocs
anataliocs / CacheConfig.java
Last active September 17, 2020 10:30
Guava cache with spring boot and clear cache method
import com.google.common.cache.CacheBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.guava.GuavaCache;
import org.springframework.cache.interceptor.CacheErrorHandler;
import org.springframework.cache.interceptor.CacheResolver;
import org.springframework.cache.interceptor.KeyGenerator;
@mlanett
mlanett / rails http status codes
Last active June 14, 2024 06:07
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@liamgriffiths
liamgriffiths / cors.md
Last active February 23, 2024 13:15
How CORS works

Guide to CORS

CORS (cross origin resource sharing) is a mechanism to allow client web applications make HTTP requests to other domains. For example if you load a site from http://domainA.com and want to make a request (via xhr or img src, etc) to http://domainB.com without using CORS your web browser will try to protect you by blocking the response from the other server. This is because browsers restrict responses coming from other domains via the Same-Origin-Policy.

CORS allows the browser to use reponses from other domains. This is done by including a Access-Control headers in the server responses telling the browser that requests it is making is OK and safe to use the response.

Header Description
Access-Control-Allow-Origin: Allow requests from `` to access t