Skip to content

Instantly share code, notes, and snippets.

View knibals's full-sized avatar

Oumar Fall knibals

View GitHub Profile
@knibals
knibals / redirectExample.go
Created August 16, 2017 09:18 — forked from jaymecd/redirectExample.go
How to redirect HTTP to HTTPS with a golang webserver.
package main
import (
"net/http"
)
func redirect(w http.ResponseWriter, req *http.Request) {
http.Redirect(w, req,
"https://" + req.Host + req.URL.String(),
http.StatusMovedPermanently)
}
@knibals
knibals / redirectExample.go
Created August 16, 2017 09:18 — forked from d-schmidt/redirectExample.go
How to redirect HTTP to HTTPS with a golang webserver.
package main
import (
"net/http"
"log"
)
func redirect(w http.ResponseWriter, req *http.Request) {
// remove/add not default ports from req.Host
target := "https://" + req.Host + req.URL.Path
if len(req.URL.RawQuery) > 0 {
@knibals
knibals / gist:f0da59599b2b249cf37325cfad604640
Created August 22, 2017 15:19 — forked from mtibben/gist:7078931
sublime-phpcs cheatsheet

sublime-phpcs cheatsheet

Install dependencies

brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
brew install php53 php-cs-fixer php-md php-code-sniffer
php-cs-fixer self-update
@knibals
knibals / php-cs-fixer-pre-commit.php
Created October 22, 2017 17:44 — forked from mardix/php-cs-fixer-pre-commit.php
A pre-commit hook to make PHP code PSR-2 compliant, check for syntax error
#!/usr/bin/php
<?php
/**
* .git/hooks/pre-commit
*
* This pre-commit hooks will check for PHP error (lint), and make sure the code
* is PSR compliant.
*
* Dependecy: PHP-CS-Fixer (https://github.com/fabpot/PHP-CS-Fixer)
*
@knibals
knibals / composer.json
Created October 22, 2017 17:45 — forked from Glutnix/composer.json
Checking PSR-2 validation with PHPCS using a pre-commit git hook.
{
"require-dev": {
"squizlabs/php_codesniffer": "2.0.*@dev"
},
"scripts": {
"post-install-cmd": [
"bash contrib/setup.sh"
]
}
}
@knibals
knibals / git-pre-receive-hook.sh
Created October 31, 2017 15:46 — forked from caniszczyk/git-pre-receive-hook.sh
A reasonable git pre-receive-hook
#!/bin/sh
#
# For each ref, validate the commit.
#
# - It disallows deleting branches without a /.
# - It disallows non fast-forward on branches without a /.
# - It disallows deleting tags without a /.
# - It disallows unannotated tags to be pushed.
@knibals
knibals / docker-image-size.sh
Created May 11, 2018 12:16 — forked from andyrbell/docker-image-size.sh
Sort docker images by size desc
#!/bin/sh
docker images --format '{{.Size}}\t{{.Repository}}\t{{.Tag}}\t{{.ID}}' | sed 's/ //' | sort -h -r
@knibals
knibals / GitConfigHttpProxy.md
Created September 28, 2018 10:09 — forked from evantoli/GitConfigHttpProxy.md
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:

---
layout: post
section-type: post
title: Casually using a Proxy with Bash on Ubuntu on Windows
category: Win10
tags: [microsoft, canonical, windows, windows 10, bash, ubuntu, proxy, session, logon, enterprise, company, network]
---
With the **Microsoft Windows 10 Anniversary Update (1607)** we also got an integrated *Linux Subsystem* and the so called [Bash on Ubuntu on Windows], providing us with a familiar Bash shell and Linux environment in which you can run most Linux command-line tools, directly on Windows, **unmodified**, without needing an entire Linux virtual machine.
As I'm using my Surface Pro 4 within our company network as well as at home, I need to use a proxy-server only occasionally and wanted an easy method to switch it within the Bash.
@knibals
knibals / drupal_nginx_config
Created January 4, 2020 00:42
The Nginx virtualhost for Drupal sites
server {
server_name example.com;
root /var/www/drupal8;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {