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
<!-- Twitter -->
<a href="https://twitter.com/intent/tweet?text=<?php echo rawurlencode($user_wish['title']); ?>%20💯%20Sending%20you%20a%20Happy%20New%20Year%20Greetings%20🎁%20👉%20<?php echo $current_page; ?>" target="_blank">Twitter</a>
@devjj
devjj / freenas-backblazeb2.md
Last active April 6, 2023 06:29
FreeNAS Backup to Backblaze B2

Backing up FreeNAS to Backblaze B2

I am not the original author of the content on this page. While searching for information about setting up Backblaze B2 on a FreeNAS installation, I came across this hyperlink: https://blog.justin-tech.com/blog/freenas-b2-backup. Unfortunately, that page now leads to an HTTP 502. Google had it cached.

*The instructions worked almost perfectly, except for a couple adjustments due to updated versions of the relevant software. The idea that this useful information may disappear into the aether worried me, as it may still help others, and I'll more than likely need it again in the future. In the spirit of open source, I copied the page as rich text in Firefox, ran it through an HTML to Markdown converter, and set about cleaning it up, fixing conversion errors and fo

@chris-jamieson
chris-jamieson / snippet.js
Created November 26, 2017 13:44
Sequelize snippet for sorting (REST api)
// snippet to help feed sort parameters into Sequelize query
// following Vinay Sahni's best practices (http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api)
// e.g. https://my-url.com/api/v1/sausages?sort=-createdAt,name
function list (req, res, next) {
const findOptions = {
order: [],
};
// handle sorting / ordering
if (req.query.sort) {
@soulmachine
soulmachine / jwt-expiration.md
Last active April 10, 2025 12:28
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.example.com;
root /var/www/ghost/system/nginx-root;
return 301 https://example.com$request_uri;
ssl_certificate /etc/letsencrypt/www.example.com/fullchain.cer;
ssl_certificate_key /etc/letsencrypt/www.example.com/www.example.com.key;
@karlhillx
karlhillx / macos_high_sierra_apache_php_brew_2018.md
Last active January 4, 2025 05:36
macOS High Sierra Setup: Homebrew + Apache + PHP + MariaDB + SSL

macOS High Sierra Setup: Homebrew + Apache + PHP + MariaDB + SSL

Homebrew Installation

First let's install Homebrew.

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

@jeffochoa
jeffochoa / Response.php
Last active May 6, 2025 01:52
Laravel HTTP status code
<?php
// This can be found in the Symfony\Component\HttpFoundation\Response class
const HTTP_CONTINUE = 100;
const HTTP_SWITCHING_PROTOCOLS = 101;
const HTTP_PROCESSING = 102; // RFC2518
const HTTP_OK = 200;
const HTTP_CREATED = 201;
const HTTP_ACCEPTED = 202;
@mbmohib
mbmohib / PHP.txt
Created October 27, 2017 16:16
PHP
PHP - MARIA DB - LARAVEL - ATOM
# PHP + Maria DB:
$ sudo apt-add-repository ppa:ondrej/php
$ sudo apt-get install curl unzip phpunit mariadb-client mariadb-server sqlite3 php7.0 php7.0-cli php7.0-curl php7.0-mcrypt php7.0-sqlite3 php7.0-mbstring php7.0-zip php7.0-mysql php7.0-xml
$ which php
$ which mysql
# Composer + Laravel
Get the Composer first : https://getcomposer.org/download/
@gabrielrojasnyc
gabrielrojasnyc / file_go_no.go
Created October 22, 2017 22:28
file_go_no.go
package main
import (
"fmt"
"log"
"io"
"os"
"net/http"
"time"
)
@paulofreitas
paulofreitas / AuthServiceProvider.php
Last active July 7, 2023 13:15
Extending the default Eloquent User Provider (Laravel 5.4+)
<?php
namespace App\Providers;
use App\Auth\UserProvider;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**