Skip to content

Instantly share code, notes, and snippets.

View coreh's full-sized avatar

Marco Buono coreh

View GitHub Profile
@coreh
coreh / BEVY-REMOTE-PROTOCOL.md
Last active February 6, 2024 09:34
Bevy Remote Protocol

Bevy Remote Protocol (BRP)

The Bevy Remote Protocol (BRP) is a transport-agnostic and serialization-agnostic protocol for communication between a Bevy application (acting as a server) and a remote (or local) client. It's a request/response-style protocol (similar to HTTP), meaning that every communication is always initiated by the client, and the server only responds to the client's requests.

Example Uses

  • A editor/inspector, allowing the user to inspect and modify the Bevy application's state in real time, both locally and remotely;
  • “Gameshark“-style cheats, allowing the user to modify a game's state in real time;
  • JS/HTML-based UI interacting with an embedded Bevy application running in a browser;
  • Non-Bevy/Rust applications (e.g. a C++/Python/Java application) interacting with embedded Bevy modules;
@coreh
coreh / IFRAME-BLOCKING-TEST.md
Last active November 4, 2021 16:23
Iframe Blocking Script Test

What this is?

This is a simple experiment to verify if browsers will block/hang execution in a page when a child iframe (of a different origin) has a running script blocked in an infinite loop.

As of Nov 4, 2021, Chrome/Edge won't block the parent page, but Firefox and Safari will.

Instructions

You'll need Node and NPM for this.

/mnt/c/Users/coreh/Desktop $ sudo apt-get upgrade youtube-dl
Reading package lists... Done
Building dependency tree
Reading state information... Done
youtube-dl is already the newest version (2016.02.22-1).
Calculating upgrade... Done
The following packages have been kept back:
libegl1-mesa libgbm1 libgl1-mesa-dri libwayland-egl1-mesa mesa-va-drivers mesa-vdpau-drivers open-vm-tools
The following packages will be upgraded:
apparmor apport apt apt-transport-https apt-utils base-files bind9-host bsdutils cloud-guest-utils cloud-init
[object Object]
0 info it worked if it ends with ok
1 verbose cli [ '/Users/coreh/.nvm/versions/node/v8.1.0/bin/node',
1 verbose cli '/Users/coreh/.nvm/versions/node/v8.1.0/bin/npm',
1 verbose cli 'update' ]
2 info using npm@5.0.3
3 info using node@v8.1.0
4 verbose npm-session cf449ad0bbb9faa1
5 silly mapToRegistry name @types/config
6 silly mapToRegistry scope (from package name) @types
7 verbose mapToRegistry no registry URL found in name for scope @types
@coreh
coreh / batch-invite.js
Last active April 30, 2020 00:48
Invite users to a slack room / group as a batch
// Instructions: Open slack, switch to the channel you want to invite people to,
// Copy and paste the entire code snippet below to the "Console" tab of your web inspector, hit "Enter".
(function () {
var people = prompt('Paste the usernames you want to invite here and hit OK:').split(/,\s*|\s+/);
var textArea = $('#message-input');
var dismiss = function () {
$(".dialog_go").click();
}
@coreh
coreh / ScreenCapture.m
Last active April 20, 2023 16:37
Screen capture in Cocoa (Grabs the screen contents and puts it into a NSImage)
NSImage *CaptureScreen() {
// Get the Screen Rect
NSRect screenRect = [[NSScreen mainScreen] frame];
// Create a CGImage with the screen contents
CGImageRef cgImage = CGWindowListCreateImage(screenRect, kCGWindowListOptionOnScreenOnly, kCGNullWindowID, kCGWindowImageDefault);
// Convert the CGImage into a NSBitmapImageRep
NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];
@coreh
coreh / gist:4980837
Created February 18, 2013 21:18
How to calculate sprite coordinates by index in a sprite-sheet with fixed-sized sprites.
// These are known beforehand
int imageWidth = 640;
int imageHeight = 480;
int tileWidth = 32;
int tileHeight = 32;
int tilesPerRow = imageWidth / tileWidth;
int index = 5;

Arquivo em branco

Código Fonte

(arquivo em branco)

Saída

statement list

@coreh
coreh / bind2.js
Created August 2, 2012 01:31
bind2
/**
* This function is similar to bind, but the received value of "this"
* gets passed as the first function argument.
*/
function bind2 (fn, _this) {
return function() {
var args = [].slice.call(arguments);
args.unshift(this);
fn.apply(_this, args);
}