Skip to content

Instantly share code, notes, and snippets.

@Linch1
Linch1 / tokenPriceApi.js
Last active March 17, 2024 08:02
Retrive the price of any bsc token from it's address without using external service like poocoin/dextools
let pancakeSwapAbi = [
{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"getAmountsOut","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"view","type":"function"},
];
let tokenAbi = [
{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},
];
const Web3 = require('web3');
/*
Required Node.js
@AlCalzone
AlCalzone / how-to-async.md
Last active February 7, 2023 10:38
JavaScript: How to Async? (german)

How to? - Asynchroner Code

Kapitel 1: Synchroner Code

Ausgangslage: Synchroner Code. Einfach zu lesen, klarer Programmablauf:

const ergebnis1 = synchroneFunktion1();
const ergebnis2 = synchroneFunktion2();
tueWasMitErgebnis(ergebnis1, ergebnis2);
@Gkiokan
Gkiokan / json-encode-decode-class.php
Created January 8, 2018 10:04
JSON full encode decode with UTF-8 support
/*
Data Class
* * * * * * *
Author: Gkiokan
Comment:
Encode and Decode Your String / Object / Array with utf-8 force.
*/
class Data {
// Encode
@poul-kg
poul-kg / valet.conf
Last active October 23, 2023 10:48
CORS Rules for Laravel Valet Nginx
# To enable CORS you should add lines with CORS rules below to your valet.conf file
# Find the file /usr/local/etc/nginx/valet/valet.conf - this is Valet conf for Nginx
# of try to execute `locate valet.conf` and find the `valet.coinf` in `nginx` subdirectory
# after you edit your valet.conf do not forget to execute `valet restart`
server {
listen 80 default_server;
root /;
charset utf-8;
client_max_body_size 128M;
@Gkiokan
Gkiokan / .htaccess
Created September 12, 2017 10:58
The WPMS non-www to www but grant access to wp-* problem in htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain\.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/wp-admin
RewriteCond %{REQUEST_URI} !^/wp-json
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
@Gkiokan
Gkiokan / alias.sh
Last active September 14, 2017 08:23
Alias mapping in terminal
echo " > Loading Aliases "
# Basics
alias ..="cd .."
alias lsa="ls -al"
alias swatch="sass --watch "
alias sfull="sass --watch sass:css --style=compressed"
alias sf="sfull"
alias m="~/.dotfiles/mount.sh"
alias s="source ~/.dotfiles/server.sh"
@squarestar
squarestar / install-wp-plugins.php
Last active March 22, 2024 19:28
Programmatically install and activate wordpress plugins
<?php
/**
* Programmatically install and activate wordpress plugins
*
* Usage:
* 1. Edit the $pluginSlugs array at the beginning of this file to include the slugs of all the
* plugins you want to install and activate
* 2. Upload this file to the wordpress root directory (the same directory that contains the
* 'wp-admin' directory).
* 3. Navigate to <your-domain-wordpress-root>/install-wp-plugins.php (If wordpress is installed
@pythoninthegrass
pythoninthegrass / cask_gist.txt
Last active May 2, 2020 18:17 — forked from jitendravyas/gist:8d35b092dd9102a05ea3
Brew Cask installation with Laptop script
#!/bin/sh
# homebrew taps
brew tap caskroom/cask
brew tap caskroom/versions
brew tap homebrew/boneyard
brew tap caskroom/fonts
# Updated grep
@solancer
solancer / apache-nginx-ftp
Created July 27, 2016 10:53
Correct permissions for /var/www/html
// Adding current user to www-data
sudo adduser $USER www-data
//change ownership to user:www-data and
sudo chown $USER:www-data -R /var/www/html
sudo chmod u=rwX,g=srX,o=rX -R /var/www/html
// change file permissions of existing files and folders to 755/644
sudo find /var/www/html -type d -exec chmod g=rwxs "{}" \;
@coreywelch
coreywelch / LowercaseRoutes.php
Last active April 28, 2023 19:19
Here is a middleware class for laravel 5 that takes incoming routes and forces them to lowercase.
<?php
namespace App\Http\Middleware;
use Closure;
use \Illuminate\Support\Facades\Redirect;
class LowercaseRoutes
{
/**