Skip to content

Instantly share code, notes, and snippets.

__kernel void hello(__global char* string)
{
string[0] = 'H';
string[1] = 'e';
string[2] = 'l';
string[3] = 'l';
string[4] = 'o';
string[5] = ',';
string[6] = ' ';
string[7] = 'W';
const RECEIVE_PORT = 3001;
const SEND_PORT = 3002;
const dgram = require('dgram');
const server = dgram.createSocket('udp4');
server.on('listening', function () {
let address = server.address();
console.log(`UDP server listening on ${address.address}:${address.port}`);
});
/** 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));
/** 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 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):
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
@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]);
@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){
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};
/*
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>