Skip to content

Instantly share code, notes, and snippets.

View frostney's full-sized avatar
🐢

Johannes Stein frostney

🐢
View GitHub Profile
@frostney
frostney / gist:5427786
Last active February 11, 2024 22:25
RequestAnimationFrame and CancelAnimationFrame as AMD modules
define('vendors', function() {
return ['ms', 'moz', 'webkit', 'o'];
});
define('requestAnimationFrame', ['root', 'vendors'], function(root, vendors) {
// frameRate is only used if requestAnimationFrame is not available
var frameRate = 60;
var requestAnimationFrame = root.requestAnimationFrame;
@frostney
frostney / Baking.js
Created May 4, 2011 03:23
This is a code snippet which shows how to embed JavaScript (using BESEN, http://besen.sourceforge.net) in FreePascal/Delphi applications. I used FPC 2.5.1, compiled using "fpc -Mdelphi FPCScript.dpr" and tested under Ubuntu Linux 10.10 (32-bit).
//importScript("Test.js"); // Imports & executes Test.js
// Wohooo, JavaScript inside of JavaScript. That's meta.
execute("(function() { print('Hello world') })();");
print("--- Let's have a cake ---");
var myCake = new Cake();
myCake.Info();
print("--- I'm hungry ---");
@frostney
frostney / achievements.css
Created April 19, 2011 01:58
This is a code snippet on how to implement achievements (as seen on Steam or XBox Live) in JavaScript games using DOM. It utilizes jQuery, HTML5 LocalStorage and some CSS3. This runs completely client-side, but it could easily be integrated into a Node.js
/* You may want to style this to your personal need */
#status.achievement {
display: none;
position: absolute;
left: 50%;
bottom: -120px;
margin-left: -160px;
}
@frostney
frostney / gist:4165353
Created November 28, 2012 22:56
Walking through folder recursively async (node.js): includes option to filter elements, hidden dot files and filenames with trailing underscore. (walkFiles function taken from http://stackoverflow.com/questions/7041638/walking-a-directory-with-node-js)
var path = require('path');
var fs = require('fs');
var es6shim = require('es6-shim');
/**
* dir: path to the directory to explore
* action(file, stat): called on each file or until an error occurs. file: path to the file. stat: stat of the file (retrived by fs.stat)
* done(err): called one time when the process is complete. err is undifined is everything was ok. the error that stopped the process otherwise
*/
var walkFiles = function(dir, action, done) {
@frostney
frostney / YoutubePlayer.js
Created May 20, 2017 13:48
Failed experiment of trying to render Youtube iframes as videos for react-vr. Fails because of cross origin iframes :(
import YoutubePlayer from 'youtube-player';
import html2canvas from 'html2canvas';
export default class YoutubeVideoPlayer {
onMediaEvent: ?(any) => void;
videoElement: HTMLVideoElement;
_muted: boolean;
_volume: number;
static supportedFormats: ?Array<string> = ['youtube'];
@frostney
frostney / talk.markdown
Last active September 4, 2017 21:16
ReactiveConf 2017 Lightning talk

This is a lightning talk proposal for ReactiveConf 2017: https://reactiveconf.com/

The Curious Case of Monorepos

Monorepos have often stigmatized as bad practice and as such something that should be avoided. Still, big companies like Facebook, AirBnB and Google are actively using monorepos to manage their projects. In the open source world, monorepos have become more popular with Babel being the most prominent example. We'll dive into why monorepos might have this bad reputation and go into where it makes sense to have monorepos, talk about their advantages and their shortcomings. We'll also look into what tooling solutions are available - especially in a JavaScript context.

@frostney
frostney / settings.json
Created April 11, 2017 00:14
VSCode settings
// Place your settings in this file to overwrite the default settings
{
"window.zoomLevel": 1,
"workbench.iconTheme": "vscode-icons",
"editor.fontFamily": "Fira Code",
"editor.fontSize": 14,
"editor.fontLigatures": true,
"editor.tabSize": 2,
"files.trimTrailingWhitespace": true,
"eslint.autoFixOnSave": true,
@frostney
frostney / gist:4402499
Created December 28, 2012 22:22
Rudimentary Entity-Component-model in CoffeeScript
class Entity
componentList = {}
constructor: (@name = @constructor.name) ->
get: (componentName) ->
if componentName
componentList[componentName]
else
Object.keys componentList
@frostney
frostney / talk.markdown
Last active September 22, 2016 12:01
ReactiveConf 2016 Lighting talk proposal: React (Native) and the cross platform pipe dream

This is a lighting talk proposal for ReactiveConf 2016: https://reactiveconf.com/

React (Native) and the cross platform pipe dream

Have one codebase, target all the platforms. While we are on the topic on re-using the same codebase, maybe we could even switch out the renderer with what is the fatest for the situation. Use DOM, Canvas or OpenGL whenever needed. This lighting talk will give impulses on how to approach this mantra and what advantages and disadvantages we might run into in the process.

(Content-wise this lighting talk is a shorter version of https://github.com/frostney/talks/blob/master/proposals.md#can-we-stop-using-lowercased-components-now.)

@frostney
frostney / dglOpenGL.pas
Created June 24, 2011 02:38
Changes to get dglOpenGL.pas (www.delphigl.com) OpenGL 4.1 header working on Mac OS X
(*
Open dglOpenGL.pas in your favorite text editor and change the following lines
*)
// Don't worry about having absolute filepaths. Mac OS X always installs the OpenGL framework with every
// clean installation of Mac OS X and the dylibs are ALWAYS in that path. (Tested on several Mac OS X
// machines including PowerMac G5 with Leopard, MacBook with Snow Leopard, MacBook Pro with Snow Leopard and Lion)
// While the standard search directory for libraries is /usr/lib on Mac OS X as well, you should not use this
// for developing your application as other Mac users don't have the OpenGL libraries in that folder and your