Skip to content

Instantly share code, notes, and snippets.

View ahmadarif's full-sized avatar
🎯
Focusing

Ahmad Arif ahmadarif

🎯
Focusing
View GitHub Profile
@gamerxl
gamerxl / excel-formula-parser.pegjs
Last active December 30, 2022 12:31
PEG.js based parser for excel formula. It's only a simple prototype for evaluation. Test online at https://pegjs.org/online
// PEG.js based parser for excel formula.
// Executable on https://pegjs.org/online
{
// Implementation of builtin core functionality and some demo stuff.
// TODO: Remove demo stuff.
const builtinFunctions = {
/**
* Returns a number (Demo function).
* TODO: Remove demo function.
@javilobo8
javilobo8 / download-file.js
Last active April 9, 2024 12:01
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@duanehutchins
duanehutchins / split-string-into-rows.sql
Last active March 8, 2023 20:59
MySQL split comma-separated string into rows
-- split-string-into-rows.sql
-- Duane Hutchins
-- https://www.github.com/duanehutchins
-- Split a string into a mysql resultset of rows
-- This is designed to work with a comma-separated string (csv, SET, array)
-- To use a delimiter other than a comma:
-- Just change all the occurrences of ',' to the new delimiter
-- (four occurrences in SET_EXTRACT and one occurrence in SET_COUNT)
@sarangbk
sarangbk / Base64 to String (VARCHAR) and String (VARCHAR) to Base64.sql
Created June 20, 2016 19:48
MSSQL Convert a VARCHAR to Base64 encoding and vice-versa
-- VARCHAR TO Base64
IF OBJECT_ID (N'[dbo].[uFnStringToBase64]', N'FN') IS NOT NULL
DROP FUNCTION uFnStringToBase64;
GO
CREATE FUNCTION [dbo].[uFnStringToBase64]
(
@InputString VARCHAR(MAX)
)
RETURNS VARCHAR(MAX)
AS
@stefanschmidt
stefanschmidt / fix-homebrew-owner-perms.sh
Created April 12, 2016 21:19
Fix ownership and permissions of a multi-user Homebrew installation
# fix owner of files and folders recursively
sudo chown -vR $(whoami) /usr/local /opt/homebrew-cask /Library/Caches/Homebrew
# fix read/write permission of files and folders recursively
chmod -vR ug+rw /usr/local /opt/homebrew-cask /Library/Caches/Homebrew
# fix execute permission of folders recursively
find /usr/local /opt/homebrew-cask /Library/Caches/Homebrew -type d -exec chmod -v ug+x {} +
@h2non
h2non / libvips-installer.sh
Last active October 3, 2023 20:07
libvips 7.42.x cross-platform simple installer script (supports OSX, Debian, Ubuntu, CentOS, Fedora, Amazon Linux)
#!/bin/sh
#
# Orinally made by Lovell Fuller for sharp
# https://github.com/lovell/sharp
#
# Usage:
# curl -s https://gist.githubusercontent.com/h2non/89bb2f87c6499d0b25f1/raw/bf3d0743107f02f5db2b93c53f7f0e07a1c33112/libvips-installer.sh | sudo bash -
#
@gavinhungry
gavinhungry / nginx-tls.conf
Last active March 11, 2024 14:51
Nginx SSL/TLS configuration for "A+" Qualys SSL Labs rating
#
# Name: nginx-tls.conf
# Auth: Gavin Lloyd <gavinhungry@gmail.com>
# Desc: Nginx SSL/TLS configuration for "A+" Qualys SSL Labs rating
#
# Enables HTTP/2, PFS, HSTS and OCSP stapling. Configuration options not related
# to SSL/TLS are not included here.
#
# Additional tips:
#
@denji
denji / nginx-tuning.md
Last active May 3, 2024 03:57
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@plentz
plentz / nginx.conf
Last active April 24, 2024 11:15
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048