Skip to content

Instantly share code, notes, and snippets.

@getnamo
getnamo / Sample.cpp
Last active February 2, 2023 18:38
Unreal End/Exit Delegates
//FCoreDelegates
EndDelegate = FCoreDelegates::OnPreExit.AddLambda([&]
{
UE_LOG(LogTemp, Log, TEXT("OnPreExit"));
});
//Cleanup
FCoreDelegates::OnPreExit.Remove(EndDelegate);
const fs = require("fs");
const http = require("http");
const https = require("https");
const { Server } = require("socket.io");
const express = require("express");
//defaults
const tlsEnabled = true;
const port = 3000;
/*
Delta Compression by Glenn Fiedler.
This source code is placed in the public domain.
http://gafferongames.com/2015/03/14/the-networked-physics-data-compression-challenge/
*/
#include <stdint.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
const express = require('express')
const app = express()
app.use(express.json())
app.post(
'/',
(req, res) => {
console.log(req.body);
let resObj = { replyType:"echo", content: req.body};
@getnamo
getnamo / queryExample.js
Created April 8, 2019 20:39
sample sql query callback on node.js
//assuming you're using https://www.npmjs.com/package/mysql
const mysql = require('mysql');
const con = mysql.createConnection({
host: "localhost",
user: "yourusername",
password: "yourpassword",
database: "mydb"
});
socket.on('sqlQuery', function(queryData, callback){
@getnamo
getnamo / proxy.js
Last active March 29, 2019 18:45
simple node.js proxy. Allowing to tear down and bring up as needed. Usage: node proxy.js <from port> <to port>. Forever recommended.
let from = 80;
let to = 8080;
const httpProxy = require('http-proxy');
if(process.argv.length != 4){
console.log('Did not supply from/to params, remapping ' + from + ' to ' + to);
}
else{
from = Number(process.argv[2]);
to = Number(process.argv[3]);
import requests
def download_file_from_google_drive(id, destination):
def get_confirm_token(response):
for key, value in response.cookies.items():
if key.startswith('download_warning'):
return value
return None
from aiohttp import web
import socketio
from colorama import init, Fore
init(autoreset=True)
sio = socketio.AsyncServer()
app = web.Application()
sio.attach(app)
async def index(request):
/** from: https://nodejs.org/api/net.html#net_net_createconnection_options_connectlistener */
const net = require('net');
const port = 3000;
const client = net.createConnection({ port: 3000 }, () => {
console.log('connected to server!');
//pipe immediately something back
client.write('Hello from TCP client!\r\n');
//send delayed data test
/** from: https://nodejs.org/api/net.html#net_server_address */
const net = require('net');
const util = require('util');
const port = 3000;
let server = net.createServer((socket) => {
//give it an id
socket.id = Math.floor(Math.random() * 1000);
//console.log(util.inspect(socket));