Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Salvador Guerrero ObjSal

🎯
Focusing
View GitHub Profile
@ObjSal
ObjSal / AguilaCoin.sol
Created Dec 1, 2020
Implementation of AguilaCoin (a Chore Coin) an ERC-20 Token
View AguilaCoin.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.8.0;
contract AguilaCoin {
uint256 private _totalSupply;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
@ObjSal
ObjSal / AccountsDemo.sol
Created Oct 17, 2020
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.6.12+commit.27d51765.js&optimize=false&gist=
View AccountsDemo.sol
// Code snippet from Blockchain in Action
pragma solidity ^0.6.0;
contract AccountsDemo {
address public whoDeposited;
uint public depositAmount;
uint public accountBalance;
function deposit() public payable {
whoDeposited = msg.sender;
@ObjSal
ObjSal / app.js
Created May 20, 2020
JWT authentication in Node.js
View app.js
// Author: Salvador Guerrero
'use strict'
const fs = require('fs')
const crypto = require('crypto')
// Third-Party Modules
const {MongoClient, ObjectId} = require('mongodb')
const jwt = require('jsonwebtoken')
@ObjSal
ObjSal / app.js
Created May 7, 2020
Secure Salted Password Hashing on client and server side
View app.js
// Author: Salvador Guerrero
'use strict'
const fs = require('fs')
const crypto = require('crypto')
// Project modules
const { CreateServer } = require('./server')
const SecurityUtils = require('./security-utils')
@ObjSal
ObjSal / app.js
Last active Dec 15, 2020
Posting form data in 3 ways to a Node.js server without third-party libraries - application/json, application/x-www-form-urlencoded, and multipart/form-data
View app.js
// Author: Salvador Guerrero
'use strict'
const fs = require('fs')
// Project modules
const { CreateServer } = require('./server')
const SecurityUtils = require('./security-utils')
@ObjSal
ObjSal / EncodingUtil.js
Created Apr 19, 2020
Enable caching from Node.js
View EncodingUtil.js
// Author: Salvador Guerrero
'use strict'
// https://nodejs.org/api/zlib.html
const zlib = require('zlib')
const kGzip = 'gzip'
const kDeflate = 'deflate'
const kBr = 'br'
@ObjSal
ObjSal / EncodingUtil.js
Last active Apr 19, 2020
Encoding Node.js responses with gzip, deflate and bf without third-party modules
View EncodingUtil.js
// Author: Salvador Guerrero
'use strict'
// https://nodejs.org/api/zlib.html
const zlib = require('zlib')
const kGzip = 'gzip'
const kDeflate = 'deflate'
const kBr = 'br'
@ObjSal
ObjSal / index.js
Last active Apr 17, 2020
Upload an image from a website to a node.js server, then the node server is going to upload and then download the image from a FTP server and send it back as response to the website.
View index.js
// Author: Salvador Guerrero
const http = require('http');
const fs = require('fs')
// Third-party modules
const ftp = require("basic-ftp")
var {Base64Encode} = require('base64-stream')
let port = 3000
@ObjSal
ObjSal / index.js
Last active Apr 17, 2020
Upload files to Node.js without form or third-party frameworks
View index.js
const http = require('http');
const fs = require('fs')
let port = 3000
http.createServer((req, response) => {
/**
* `/` loads index.html
*/
if (req.url == '/' && req.method.toLowerCase() == 'get') {
@ObjSal
ObjSal / node_playground.js
Created Mar 25, 2020
Node Playground used while learning Node.js
View node_playground.js
// I created this script as a playground when learning node.js
// The Majority of examples are grabbed from https://nodejs.dev/
/**
* Make this server reacheable by the world.
* Install ngrok and type `ngrok PORT` and the PORT you want is exposed to the
* internet. You will get a ngrok.io domain, but with a paid subscription you
* can get a custom URL as well as more security options.
*
* Another service you can use is https://github.com/localtunnel/localtunnel