Skip to content

Instantly share code, notes, and snippets.

@jordandee
jordandee / sdl2_opengl.cpp
Last active March 17, 2025 07:57
Simple SDL2/OpenGL example
// To compile with gcc: (tested on Ubuntu 14.04 64bit):
// g++ sdl2_opengl.cpp -lSDL2 -lGL
// To compile with msvc: (tested on Windows 7 64bit)
// cl sdl2_opengl.cpp /I C:\sdl2path\include /link C:\path\SDL2.lib C:\path\SDL2main.lib /SUBSYSTEM:CONSOLE /NODEFAULTLIB:libcmtd.lib opengl32.lib
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
@Restuta
Restuta / framework-sizes.md
Last active April 19, 2025 05:14
Sizes of JS frameworks, just minified + minified and gzipped, (React, Angular 2, Vue, Ember)

Below is the list of modern JS frameworks and almost frameworks – React, Vue, Angular, Ember and others.

All files were downloaded from https://cdnjs.com and named accordingly. Output from ls command is stripped out (irrelevant stuff)

As-is (minified)

$ ls -lhS
566K Jan 4 22:03 angular2.min.js
@laterbreh
laterbreh / Express 4 and Socket.io: Passing socket.io to routes - app.js
Last active August 15, 2023 13:58
Express 4 and Socket.io: Passing socket.io to routes.
var app = express();
app.io = require('socket.io')();
var routes = require('./routes/index')(app.io);
app.use('/', routes);
@bbottema
bbottema / Express with base64 file upload and read back to client
Last active December 14, 2022 14:34
A complete Express 4 example using multer to read base64 png data and reading the file back to the client as binary data
var express = require('express');
var fs = require('fs');
var multer = require('multer'); // v1.0.5
var app = express();
app.use(express.static('./public'));
var upload = multer(); // for parsing multipart/form-data
app.post('/testFormData', upload.array(), function(req, res) {
@mjohnsullivan
mjohnsullivan / http_server.rs
Last active August 23, 2024 03:19
Simple HTTP server example for Rust
// Updated example from http://rosettacode.org/wiki/Hello_world/Web_server#Rust
// to work with Rust 1.0 beta
use std::net::{TcpStream, TcpListener};
use std::io::{Read, Write};
use std::thread;
fn handle_read(mut stream: &TcpStream) {
let mut buf = [0u8 ;4096];
@rioki
rioki / sdl2test.c
Created April 9, 2015 19:47
Test of SDL2 main loop.
#include <stdio.h>
#include <SDL.h>
#include <SDL_image.h>
#include <Windows.h>
#include <time.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
const int WIDTH = 640;
const int HEIGHT = 480;
@Schniz
Schniz / plaintext-contenteditable.css
Last active April 8, 2022 17:46
Plain-Text ContentEditable div for React.js
.comPlainTextContentEditable {
-webkit-user-modify: read-write-plaintext-only;
}
.comPlainTextContentEditable--has-placeholder::before {
content: attr(placeholder);
opacity: 0.5;
color: inherit;
cursor: text;
}
@thisredone
thisredone / gist:cb23b5ae414875175d89
Created February 14, 2015 10:25
playcanvas without webgl
diff --git a/src/framework/framework_application.js b/src/framework/framework_application.js
index 13977dc..1e04457 100644
--- a/src/framework/framework_application.js
+++ b/src/framework/framework_application.js
@@ -84,7 +84,7 @@ pc.extend(pc, function () {
loader.registerHandler(pc.resources.PackRequest, new pc.resources.PackResourceHandler(registry, options.depot));
loader.registerHandler(pc.resources.AudioRequest, new pc.resources.AudioResourceHandler(this.audioManager));
- this.renderer = new pc.ForwardRenderer(this.graphicsDevice);
+ // this.renderer = new pc.ForwardRenderer(this.graphicsDevice);
@Youka
Youka / lua_myobject.cpp
Last active August 27, 2024 06:32
Example of Lua in C++ and userdata objects
// Lua C API
#include <lua.hpp>
// C++ input/output streams
#include <iostream>
// MyObject as C++ class
class MyObject{
private:
double x;
public:
// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');