Skip to content

Instantly share code, notes, and snippets.

View aliharis's full-sized avatar
💀

haris aliharis

💀
View GitHub Profile
@aliharis
aliharis / main.go
Created January 25, 2024 19:59
Reverse proxy in Go
package main
import (
"net/http"
"net/http/httputil"
"net/url"
)
func main() {
// Parse the target URL
@aliharis
aliharis / delete_stale_branches.sh
Created January 21, 2024 09:10
Delete stale branches on your machine
#!/bin/bash
# Update the local repository and prune remote-tracking branches
git fetch --prune
# Loop over each local branch and check if it has a remote tracking branch
for branch in $(git branch -vv | grep ': gone]' | awk '{print $1}'); do
echo "Deleting local branch: $branch"
git branch -d "$branch"
done
@aliharis
aliharis / README.md
Created July 27, 2020 21:04 — forked from arikfr/README.md
Setting up HTTPS with LetsEncrypt for Redash Docker Deployment
  1. Make sure the domain you picked points at the IP of your Redash server.
  2. Switch to the root user (sudo su).
  3. Create a folder named nginx in /opt/redash.
  4. Create in the nginx folder two additional folders: certs and certs-data.
  5. Create the file /opt/redash/nginx/nginx.conf and place the following in it: (replace example.redashapp.com with your domain name)
    upstream redash {
        server redash:5000;
    }
    
@aliharis
aliharis / MPG.php
Last active April 2, 2020 09:59
MPG.php
<?php
/**
* Maldives Payment Gateway Integration
* @author haris
*/
class MPG
{
private $version;
@aliharis
aliharis / set_cookiejar.go
Created March 15, 2020 22:57 — forked from HugoPresents/set_cookiejar.go
golang set cookieJar example
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/http/cookiejar"
"net/url"
"strings"
)
@aliharis
aliharis / php80.sh
Last active October 26, 2023 11:14
Installing PHP 8.1 on Ubuntu 20.04
# PHP 8.1
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get -y install php8.1-cli
# Composer
cd ~
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
@aliharis
aliharis / gist:1821ee2f4b62f40fcf306ea22d5da837
Last active September 13, 2020 13:34
statamic nginx config
server {
listen 80;
root /var/www/cms/public;
index index.php index.html index.htm;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$args;
@aliharis
aliharis / slugify.js
Created March 16, 2017 15:04 — forked from mathewbyrne/slugify.js
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@aliharis
aliharis / read.sh
Created April 17, 2016 14:58
Read a text file line by line
#!/bin/bash
while IFS='' read -r line || [[ -n "$line" ]]; do
wget $line
done < "$1"
@aliharis
aliharis / CharacterReplace.java
Created March 11, 2016 09:19
Function for replacing the nth occurrence of a character in nth line. Results: http://oi63.tinypic.com/2wm17ig.jpg
package javaapplication1;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.regex.Matcher;