Skip to content

Instantly share code, notes, and snippets.

View ObjSal's full-sized avatar
🎯
Focusing

Salvador Guerrero ObjSal

🎯
Focusing
View GitHub Profile
@ObjSal
ObjSal / app.js
Last active February 22, 2024 13:29
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
// 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 April 19, 2020 23:08
Enable caching from Node.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 April 19, 2020 20:14
Encoding Node.js responses with gzip, deflate and bf without third-party modules
// 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 April 24, 2023 23:06
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.
// 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 May 3, 2023 20:31
Upload files to Node.js without form or third-party frameworks
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 March 25, 2020 04:04
Node Playground used while learning Node.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
@ObjSal
ObjSal / base58check.py
Last active June 7, 2019 14:35
Validate PKH (or SHA256/RIPEMD160 hash) with base58check.py to detect typing errors (code created from the theory of Grokking Bitcoin)
#!/usr/bin/env python3
#
# Copyright ByteApps 2019
# Author: Salvador Guerrero (salvador.icc@gmail.com)
#
# Tested by encoding and decoding the input with the following example:
# $ echo 5f2613791b36f667fdb8e95608b55e3df4c5f9eb | \
# ./base58check.py -encode | \
# ./base58check.py -decode
# will output:
@ObjSal
ObjSal / build.gradle
Created August 21, 2017 18:26
Tango's GoogleUnityWrapper
apply plugin: 'com.android.library'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
@ObjSal
ObjSal / Makefile.iphone
Last active May 22, 2019 19:42 — forked from danomatika/Makefile.iphone
FreeImage Makefile for iOS updated for XCode 7.3, tested with macOS 10.11.6 & XCode 7.3
# Configuration for iPhone OS, making static libs
# this will generate both iPhone (arm) and iPhoneSimulator (i386) libs
include Makefile.srcs
CFLAGS = -std=c99 -g -O2 -Wall -Wmissing-prototypes -ffast-math -fno-strict-aliasing -D__ANSI__ -emit-llvm -Wno-c++11-narrowing -Wno-implicit-function-declaration
CXXFLAGS = -std=gnu++14 -stdlib=libc++ -D__ANSI__ -emit-llvm -Wno-c++11-narrowing -Wno-implicit-function-declaration -fvisibility-inlines-hidden
IPHONEOS_DEPLOYMENT_TARGET = 9.3
MACOSX_DEPLOYMENT_TARGET = 10.7
@ObjSal
ObjSal / discover.py
Created January 2, 2017 21:28 — forked from jcarbaugh/discover.py
DIAL examples
import httplib
import socket
import StringIO
# generic
SSDP_ALL = 'ssdp:all'
UPNP_ROOT = 'upnp:rootdevice'
# devices
DIAL = 'urn:dial-multiscreen-org:service:dial:1'