Skip to content

Instantly share code, notes, and snippets.

View nhalstead's full-sized avatar
👨‍💻
Something. Maybe cool

Noah Halstead nhalstead

👨‍💻
Something. Maybe cool
View GitHub Profile
@davidnewhall
davidnewhall / pidfile_snippet.go
Last active July 26, 2024 13:17
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 {
@darekmydlarz
darekmydlarz / server.py
Created September 21, 2017 12:48 — forked from raelmax/server.py
Python SimpleHTTPServer com sleep
import SimpleHTTPServer
import SocketServer
from time import sleep
PORT = 5000
SLEEP_TIME = 6
class SlowHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
@gnsx
gnsx / go-smtp.go
Last active April 22, 2021 01:55
go-smtp.go
package main
import (
"fmt"
"github.com/go-gomail/gomail"
)
func main () {
fmt.Printf("Hello")
m := gomail.NewMessage()
@backsrc
backsrc / homepage.html
Created September 6, 2017 12:48
[open] Server Down Page
<!DOCTYPE html>
<html>
<head>
<title>Servers Down</title>
<link href="https://fonts.googleapis.com/css?family=Inconsolata|Roboto:400,700" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>Our servers are currently down</h1>
<p>Our servers have shut down because an unauthorised device was in access of our database,<br> We immediately shut down the server to stop anymore damage possible to the server.<br> <a href="learnmore.html" target="_blank">Learn More!</a></p>
@m2sh
m2sh / DOSpacesStorageServiceProvider.php
Last active January 17, 2024 05:03
How To Use Digitalocean Spaces as Laravel Cloud filesystems
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Filesystem;
use Storage;
daemon off;
worker_processes auto;
error_log /var/log/nginx/error.log debug;
events {
worker_connections 1024;
}
@tzmartin
tzmartin / Info.plist
Created June 24, 2017 19:31 — forked from nathankerr/Info.plist
Registering a Go app as a protocol handler under Mac OS X
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>myapp</string>
<key>CFBundleIdentifier</key>
<string>com.pocketgophers.myapp</string>
<key>CFBundleURLTypes</key>
<array>
import os
cows = os.listdir('/usr/share/cowsay/cows')
base = r"""
@commands.command(aliases=['{0}'])
async def {1}say(self, *, txt:str):
msg = await self.do_cowsay(txt, '{0}')
await self.bot.say("```\n"+msg[:1992]+"```")
"""
@bishless
bishless / wp-mailhog.php
Created June 2, 2017 23:03
Configure WordPress on Valet to use MailHog
<?php
/**
* @link
* @since 1.0.0
* @package TODO
*
* @wordpress-plugin
* Plugin Name: Use MailHog
* Description: Configure WordPress on Valet to use MailHog
* Version: 1.0.0
<?php
include("db.php");
$str=mysqli_real_escape_string($con,$_GET["str"]);
//Get data's from the Table
if(isset($str))
{