This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get('/auth/github', (req, res) => { | |
const redirectUri = req.query.redirect_uri || '/'; | |
req.session.redirectUri = redirectUri; | |
const params = new URLSearchParams({ | |
client_id: process.env.GITHUB_CLIENT_ID, | |
redirect_uri: 'http://localhost:3000/auth/github/callback', | |
scope: 'read:user user:email', | |
allow_signup: 'true', | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get('/auth/microsoft', (req, res) => { | |
const redirectUri = 'http://localhost:3000/auth/microsoft/callback'; // This must match the app registration | |
const finalRedirect = req.query.redirect_uri || '/'; | |
req.session.redirectUri = finalRedirect; | |
const params = new URLSearchParams({ | |
client_id: process.env.MICROSOFT_CLIENT_ID, | |
response_type: 'code', | |
redirect_uri: redirectUri, | |
scope: 'openid profile offline_access https://graph.microsoft.com/.default', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dev() { | |
local home="$HOME" | |
local dir | |
dir=$(find "$home" -type d \( \ | |
-path "$home/Music" -o \ | |
-path "$home/Library" -o \ | |
-path "$home/Downloads" -o \ | |
-path "$home/Desktop" -o \ | |
-path "$home/Documents" -o \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dev() { | |
local dir="${1:-$PWD}" | |
dir="$(realpath "$dir")" | |
if [[ ! -d "$dir" ]]; then | |
echo "Directory does not exist: $dir" | |
return 1 | |
fi | |
local session_file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { HttpClient, HttpHeaders } from '@angular/common/http'; | |
import { Observable, forkJoin, of } from 'rxjs'; | |
import { switchMap, map, catchError } from 'rxjs/operators'; | |
@Injectable({ | |
providedIn: 'root', | |
}) | |
export class GithubService { | |
private apiUrl = 'https://api.github.com'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"clientId": "xxxxx-xxxxx-xxxxx-xxxxx", | |
"clientSecret": "xxxxx-xxxxx-xxxxx-xxxxx", | |
"subscriptionId": "xxxxx-xxxxx-xxxxx-xxxxx", | |
"tenantId": "xxxxx-xxxxx-xxxxx-xxxxx", | |
"activeDirectoryEndpointUrl": "https://login.microsoftonline.com", | |
"resourceManagerEndpointUrl": "https://management.azure.com/", | |
"activeDirectoryGraphResourceId": "https://graph.windows.net/", | |
"sqlManagementEndpointUrl": "https://management.core.windows.net:8443/", | |
"galleryEndpointUrl": "https://gallery.azure.com/", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generates association routes for a model. | |
* @param {object} router - Express Router instance. | |
* @param {object} model - Sequelize model instance. | |
* @param {string} modelName - Singular name of the model. | |
* @param {object} associations - Associations for the model. | |
* @param {string} service - Service name. | |
*/ | |
function generateAssociationRoutes(router, model, modelName, associations, service) { | |
for (const [associationName, association] of Object.entries(associations)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if an LDIF file was provided | |
if [ "$#" -ne 1 ]; then | |
echo "Usage: $0 <ldif_file>" | |
exit 1 | |
fi | |
ldif_file=$1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function sse({ path, body }) { | |
let timerId; | |
const response = new ReadableStream({ | |
start(controller) { | |
timerId = setInterval(() => { | |
const msg = new TextEncoder().encode( | |
`data: hello at ${new Date().toUTCString()}\r\n\r\n`, | |
); | |
controller.enqueue(msg); | |
}, 1000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Not really needed. Just used for logging the FULL diff in the console | |
const util = require('util') | |
// Set up the diffs object | |
let diffs | |
function compare(item1, item2, diffRef = diffs, key) { | |
// Make sure we have a key | |
if (!key && key !== 0) { |
NewerOlder