Skip to content

Instantly share code, notes, and snippets.

@jayvi
jayvi / basicmarket.sol
Created September 7, 2021 19:44 — forked from dabit3/basicmarket.sol
Basic NFT marketplace
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
contract NFT is ERC721URIStorage {
using Counters for Counters.Counter;
// This is a hack, a quick and dirty console script for RT/tweets (with replies) removal w/o API
// To be used in: https://twitter.com/Username/with_replies
// Set your username (without @) below (case-sensitive) to correctly trigger the right Menu
const tweetUser = 'Username'
// BUG, With above we still trigger Menu on some replies but relatively harmless.
// @Hack Implement simple has() for querySelector
const querySelectorHas = function( parent, child ){
@jayvi
jayvi / wordpress_com_nginx_proxy_to_subpath.md
Created December 6, 2020 05:51 — forked from bzamecnik/wordpress_com_nginx_proxy_to_subpath.md
Nginx proxy for Wordpress.com on custom domain with subpath.
@jayvi
jayvi / checkPhone.js
Created October 27, 2020 16:03 — forked from KirillUnited/checkPhone.js
phone number validation
function checkPhone(phone) {
var phoneVal = phone.val();
var reg = /^(\s*)?(\+)?([- ():=+]?\d[- ():=+]?){10,14}(\s*)?$/;
console.log(reg);
if (!reg.test(phoneVal)) {
phone.addClass("error");
return false;
} else {
phone.removeClass("error");
function validatePhoneForE164(phoneNumber) {
const regEx = /^\+[1-9]\d{10,14}$/;
return regEx.test(phoneNumber);
};
validatePhoneForE164('+12125551212'); // true
validatePhoneForE164('12125551212'); // false
validatePhoneForE164('2125551212'); // false
validatePhoneForE164('+1-212-555-1212'); // false
@jayvi
jayvi / sshd_config
Created April 21, 2020 16:47 — forked from VirtuBox/sshd_config
default sshd config ubuntu
# Package generated configuration file
# See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
@jayvi
jayvi / Easy way to setup a local HTTP Server on macOS
Created December 27, 2019 06:46
Easy way to setup a local HTTP Server on macOS
You want to run a simple local HTTP Server on your local PC. You want to test your html, js,… files locally.
Here is the easiest way to do it.
1. Using SimpleHTTPServer
Create your test folder, move all your html, js files to that folder.
$ mkdir test
$ cd test
Check your python version
@jayvi
jayvi / nginx-tuning.md
Created November 7, 2019 13:32 — forked from denji/nginx-tuning.md
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.

@jayvi
jayvi / my.cnf
Created November 7, 2019 11:01 — forked from fevangelou/my.cnf
Optimized my.cnf configuration for MySQL/MariaSQL (on Ubuntu, CentOS etc. servers)
# Optimized my.cnf configuration for MySQL/MariaSQL
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# === Updated December 2018 ===
#
# The settings provided below are a starting point for a 2GB - 4GB RAM server with 2-4 CPU cores.
# If you have less or more resources available you should adjust accordingly to save CPU,
# RAM and disk I/O usage.
# The settings marked with a specific comment or the word "UPD" after the value
@jayvi
jayvi / my.cnf
Created November 7, 2019 11:00 — forked from oinume/my.cnf
my.cnf
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.