Skip to content

Instantly share code, notes, and snippets.

View vzool's full-sized avatar
🎯
Focusing

Abdelaziz Elrashed vzool

🎯
Focusing
View GitHub Profile
@vzool
vzool / pidfile_snippet.go
Created September 16, 2019 16:09 — forked from davidnewhall/pidfile_snippet.go
How to write a PID file in Golang.
// Write a pid file, but first make sure it doesn't exist with a running pid.
func writePidFile(pidFile string) error {
// Read in the pid file as a slice of bytes.
if piddata, err := ioutil.ReadFile(pidFile); err == nil {
// Convert the file contents to an integer.
if pid, err := strconv.Atoi(string(piddata)); err == nil {
// Look for the pid in the process list.
if process, err := os.FindProcess(pid); err == nil {
// Send the process a signal zero kill.
if err := process.Signal(syscall.Signal(0)); err == nil {
@vzool
vzool / nexus_births.go
Last active March 16, 2019 09:13
Nexus Births
package main
import (
"fmt"
"sort"
"strconv"
"strings"
)
func main() {
@vzool
vzool / gitlab-webhook-push.php
Created February 20, 2019 06:56 — forked from pitchart/gitlab-webhook-push.php
A simple php script to manage gitlab push webhook
<?php
/**
* GitLab Web Hook
* See https://gitlab.com/kpobococ/gitlab-webhook
*
* This script should be placed within the web root of your desired deploy
* location. The GitLab repository should then be configured to call it for the
* "Push events" trigger via the Web Hooks settings page.
*
* Each time this script is called, it executes a hook shell script and logs all
import base64
import random as r
MAX_VALUE = 256 * 9
private_key = int(r.random() * MAX_VALUE)
public_key = MAX_VALUE - private_key
shared_key = MAX_VALUE
print("Public Key: %d" % public_key)
@vzool
vzool / a_phar.md
Created November 14, 2018 19:11
Create a PHP Phar file

Create a PHP Phar file

Run: php create-phar.php

app.phar successfully created

Start a phar file

Run: php app.phar

@vzool
vzool / publish-chronicle.php
Created October 18, 2018 22:00
Publish Client to chronicle
<?php
$root = \dirname(__DIR__);
/** @psalm-suppress UnresolvableInclude */
require_once $root . '/cli-autoload.php';
use GuzzleHttp\Client;
use ParagonIE\Sapient\Sapient;
use ParagonIE\Chronicle\Chronicle;
use ParagonIE\ConstantTime\Base64UrlSafe;
@vzool
vzool / git.alias.sh
Last active February 12, 2022 09:34
Alias to push all branches to all remotes with just `git pushall`
#/bin/bash
git config --global alias.pushall '!git remote | xargs -L1 git push --all'
@vzool
vzool / gist:cb226889f39ba0e3729f4e0a9de4623d
Created August 3, 2018 16:05 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
chmod 700 ~/.ssh
chmod 600 ~/.ssh/*
chmod 644 ~/.ssh/*.pub
@vzool
vzool / Synology-Diskstation-Git.md
Created June 20, 2018 11:04 — forked from walkerjeffd/Synology-Diskstation-Git.md
Instructions for setting up git server on Synology Diskstation

Configure Synology NAS as Git Server

Instructions for setting up a git server on a Synology NAS with Diskstation. Specifically, I am using a DS414 with DSM 5.0.

Set Up User and Folder

  • Create user gituser via Diskstation interface (with File Station and WebDAV privilages)
  • Add new shared folder called git (located at /volume1/git) with read/write access for gituser and admin. This folder will hold all the repos.
  • Install Git Server package via Diskstation