Skip to content

Instantly share code, notes, and snippets.

@simonewebdesign
simonewebdesign / editor-demo.html
Created April 17, 2013 20:06
How to make a real-time in-browser editor with the HTML5′s contenteditable attribute -
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title contenteditable>Hey, buddy!</title>
<style class="default">
* {
transition: all .5s ease;
}
@webdesserts
webdesserts / Gulpfile.js
Last active April 3, 2023 08:16
Automatically reload your node.js app on file change with Gulp (https://github.com/wearefractal/gulp).
// NOTE: I previously suggested doing this through Grunt, but had plenty of problems with
// my set up. Grunt did some weird things with scope, and I ended up using nodemon. This
// setup is now using Gulp. It works exactly how I expect it to and is WAY more concise.
var gulp = require('gulp'),
spawn = require('child_process').spawn,
node;
/**
* $ gulp server
* description: launch the server. If there's a server already running, kill it.
@koute
koute / opengl3_hello.c
Created November 9, 2013 23:16
Minimal SDL2 + OpenGL3 example.
/*
Minimal SDL2 + OpenGL3 example.
Author: https://github.com/koute
This file is in the public domain; you can do whatever you want with it.
In case the concept of public domain doesn't exist in your jurisdiction
you can also use this code under the terms of Creative Commons CC0 license,
either version 1.0 or (at your option) any later version; for details see:
http://creativecommons.org/publicdomain/zero/1.0/
@sahat
sahat / client.js
Last active February 23, 2022 17:09
Calculate client-server latency using socket.io
var socket = io.connect('http://localhost');
var startTime;
setInterval(function() {
startTime = Date.now();
socket.emit('ping');
}, 2000);
socket.on('pong', function() {
latency = Date.now() - startTime;
@alepez
alepez / client.js
Last active December 7, 2024 14:24
nodejs file transfer with http post
var request = require('request');
var path = require('path');
var fs = require('fs');
var filename = process.argv[2];
var target = 'http://localhost:3000/upload/' + path.basename(filename);
var rs = fs.createReadStream(filename);
var ws = request.post(target);
// 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');
@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:
@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);
@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;
}
@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;