Skip to content

Instantly share code, notes, and snippets.

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

Francklin Liu Francklin

🏠
Working from home
View GitHub Profile

Cloning specific folders of cdnjs

Due to the amount of libraries of cdnjs, the repository has a very big size. Because of this some might find it difficult or time and resource consuming to carry out normal git tasks, such as cloning and commiting.

This page is a guide to cloning only some folders of cdnjs using a sparse checkout.

  1. If you haven't already, fork cdnjs on GitHub, so you can push commits on your fork.
  2. Open a terminal in your computer (with git installed)
  3. Run git init cdnjs
  4. cd cdnjs
@gianlucaparadise
gianlucaparadise / big-repo-cloner.sh
Last active June 2, 2023 10:21
Big repo cloner - Script to clone a git repository bigger than 1GB
# Script hosted here: https://gist.github.com/gianlucaparadise/10286e0b1c5409bd1049d67640fb7c03
# A repository bigger than 1 GB can't be cloned normally.
# In order to clone it, you need to follow the instructions from:
# https://stackoverflow.com/a/53068021/6155481
# To execute:
# sh big-repo-cloner.sh <repo_uri> <repo_destination_folder> [<checkout_branch_name>]
# repo_uri and repo_destination_folder are mandatory
# checkout_branch_name is optional
@mhofman
mhofman / HAProxy-transparent-web-services-routing.md
Last active February 3, 2025 21:03
Leverage HAProxy to transparently route requests to web services identified by host name.

Web Service Fronting

Multiple Web properties on a single IP address

Hosting multiple websites on a single public IP address on the standard HTTP(S) ports is relatively easy with popular web servers like Apache, Nginx and lighttpd all supporting Virtual Hosts.
For Web Services which bundle their own HTTP server, things get more complicated, unless their HTTP stack can be shared somehow. More often than not, the application's HTTP stack listens directly on a dedicated TCP port.

Hosting multiple services on a single IP then requires using a fronting server listening on the standard HTTP port, and routing to the right backend service based on the host name or the path sent by the client.
Path based routing is cumbersome, usually requiring either the service to be aware of the path prefix, or a rewrite by the HTTP fronting server of all absolute URLs in the requests and responses.
Hostname based routing is more straightforward. The fronting server can just look at the [HTTP/1.1 Host header](https://tools

@mdemblani
mdemblani / Mysql Character Set conversion - Latin1 to UTF-8(utf8mb4).md
Last active December 16, 2024 20:30
Mysql Character Set conversion - Latin1 to UTF-8(utf8mb4)
  1. Make sure mysql-client is installed. If not, then :
    sudo apt install mysql-client
	or
    sudo apt-get install mysql-client
  1. Open php.ini

; PHP's default character set is set to UTF-8.

@davidcaste
davidcaste / inflate_body.lua
Last active November 26, 2024 14:32
Nginx config: receive a request with a gzipped body, inflate it, and pass it to a proxied server
-- Debian packages nginx-extras, lua-zlib required
ngx.ctx.max_chunk_size = tonumber(ngx.var.max_chunk_size)
ngx.ctx.max_body_size = tonumber(ngx.var.max_body_size)
function create_error_response (code, description)
local message = string.format('{"status":400,"statusReason":"Bad Request","code":%d,"exception":"","description":"%s","message":"HTTP 400 Bad Request"}', code, description)
ngx.status = ngx.HTTP_BAD_REQUEST
ngx.header.content_type = "application/json"
ngx.say(message)
os_http_be.map and os_sni_passthrough.map are both just empty files
@xeoncross
xeoncross / http_accept_language.php
Last active February 7, 2025 13:05
Parse the HTTP except language header
<?php
function prefered_language($available_languages, $http_accept_language) {
$available_languages = array_flip($available_languages);
$langs = array();
preg_match_all('~([\w-]+)(?:[^,\d]+([\d.]+))?~', strtolower($http_accept_language), $matches, PREG_SET_ORDER);
foreach($matches as $match) {
@lesstif
lesstif / tomcat-service.sh
Last active July 27, 2021 01:26
RHEL/CentOS tomcat7 init.d service script.
#!/bin/bash
#
# tomcat
#
# chkconfig: 345 96 30
# description: Start up the Tomcat servlet engine.
#
# processname: java
# pidfile: /var/run/tomcat.pid
#
@int128
int128 / git-http-backend-wrapper.cgi
Created January 17, 2013 00:54
Apache configuration for Git backend
#!/bin/sh
export GIT_PROJECT_ROOT=/home/git/repositories
export GIT_HTTP_EXPORT_ALL=1
exec /usr/libexec/git-core/git-http-backend