Skip to content

Instantly share code, notes, and snippets.

View ahmad-ali14's full-sized avatar
🤔

Ahmad Ali ahmad-ali14

🤔
View GitHub Profile
@siscia
siscia / split_slice.go
Last active October 24, 2024 09:53
Splitting a go array or slice in a defined number of chunks.
package foo
// SplitSlice splits a slice in `numberOfChunks` slices.
//
// Each slice is, at most, one element bigger than any other slice.
// Abs( len(result[i]) - len(result[j]) ) <= 1 for every i, j in the result.
//
// Moreover the function maintains the order of the elements, it is stable.
//
// If the input array is nil, or empty, the function returns nil.
@ychaouche
ychaouche / Spamassassin rules description
Last active April 12, 2025 20:58
Spamassassin rules description
1 AC_BR_BONANZA Too many newlines in a row... spammy template
2 ACCESSDB Message would have been caught by accessdb
3 ACCT_PHISHING_MANY Phishing for account information
4 AC_DIV_BONANZA Too many divs in a row... spammy template
5 AC_FROM_MANY_DOTS Multiple periods in From user name
6 AC_HTML_NONSENSE_TAGS Many consecutive multi-letter HTML tags, likely nonsense/spam
7 AC_POST_EXTRAS Suspicious URL
8 AC_SPAMMY_URI_PATTERNS10 link combos match highly spammy template
9 AC_SPAMMY_URI_PATTERNS11 link combos match highly spammy template
10 AC_SPAMMY_URI_PATTERNS12 link combos match highly spammy template
@33eyes
33eyes / commit_jupyter_notebooks_code_to_git_and_keep_output_locally.md
Last active April 7, 2025 11:33
How to commit jupyter notebooks without output to git while keeping the notebooks outputs intact locally

Commit jupyter notebooks code to git and keep output locally

  1. Add a filter to git config by running the following command in bash inside the repo:
git config filter.strip-notebook-output.clean 'jupyter nbconvert --ClearOutputPreprocessor.enabled=True --to=notebook --stdin --stdout --log-level=ERROR'  
  1. Create a .gitattributes file inside the directory with the notebooks

  2. Add the following to that file:

@adrienv1520
adrienv1520 / force-page-to-reload-from-server-at-browser-launch-javascript.md
Last active December 15, 2024 11:50
How to force a page to reload from server at browser launch with JavaScript

How to force a page to reload from server at browser launch with JavaScript

I spent weeks finding a way to refresh a page or a tab from the server once a user starts or restarts the browser. I was very surprised to find nothing about this topic.

Let's dig into the context, tries and the solution I came up with.

Context

Typically, once a user opens a browser and gets to a page, it directly provides the page in cache without refreshing any data from the server. Obviously, this only applies if the user is not in a private navigation.

In this case, as a user, I always need to open the browser and then manually reload the page to get the last updated data. What? Am I too lazy? Sure I am a developer!

@mtimbs
mtimbs / tsconfig.json
Last active March 4, 2025 01:30
basic default tsconfig for use in TypeScript projects
{
"compilerOptions": {
// project options
"lib": [
"ESNext",
"dom"
], // specifies which default set of type definitions to use ("DOM", "ES6", etc)
"outDir": "lib", // .js (as well as .d.ts, .js.map, etc.) files will be emitted into this directory.,
"removeComments": true, // Strips all comments from TypeScript files when converting into JavaScript- you rarely read compiled code so this saves space
"target": "ES6", // Target environment. Most modern browsers support ES6, but you may want to set it to newer or older. (defaults to ES3)
@maxkostinevich
maxkostinevich / dev.yml
Last active October 25, 2024 12:29
Github Actions - Deploy Serverless Framework (AWS)
#
# Github Actions for Serverless Framework
#
# Create AWS_KEY and AWS_SECRET secrets in Github repository settings
# If you're using env.yml file, store its content as ENV Github secret
#
# Master branch will be deployed as DEV and every new tag starting with "v**" (e.g. v1.0, v1.2, v2.0, etc) will be deployed as PROD
#
# Learn more: https://maxkostinevich.com/blog/how-to-deploy-serverless-applications-using-github-actions/
#
@bradtraversy
bradtraversy / node_redis_cache.js
Created August 20, 2019 12:55
Node.js & Redis Caching
const express = require('express');
const fetch = require('node-fetch');
const redis = require('redis');
const PORT = process.env.PORT || 5000;
const REDIS_PORT = process.env.PORT || 6379;
const client = redis.createClient(REDIS_PORT);
const app = express();
@diego3g
diego3g / NODE.md
Last active April 19, 2025 22:34
VSCode Settings (Updated)

⚠️ Note!

With VSCode version 1.94, the APC extension broke and there is no fix yet.

So, for those having issues with APC after the VSCode update, I recommend downloading the previous version of VSCode for now (https://code.visualstudio.com/updates/v1_93) and setting updates to manual by adding this to the editor's configuration:

"update.mode": "manual",
@josuecau
josuecau / gpx-routes-to-tracks.sh
Last active March 8, 2021 20:15
Convert GPX routes (rte) into tracks (trk) using gpsbabel (https://www.gpsbabel.org)
#!/usr/bin/env bash
#
# Convert GPX routes (rte) into tracks (trk) using gpsbabel.
# (https://www.gpsbabel.org/)
set -e
if ! type gpsbabel >/dev/null 2>&1; then
echo 'gpsbabel not found'
exit 1
@oak-wildwood
oak-wildwood / CalendlyEmbedReact.js
Last active September 13, 2022 00:08
Calendly Embed React component
import React from 'react';
class CalendlyEmbed extends React.Component {
calendlyScriptSrc = 'https://assets.calendly.com/assets/external/widget.js'
buildCalendlyUrl = (account, eventName) =>
`https://calendly.com/${account}/${eventName}`
componentDidMount() {
const head = document.querySelector('head')
const script = document.createElement('script')