Skip to content

Instantly share code, notes, and snippets.

View frostney's full-sized avatar
🐢

Johannes Stein frostney

🐢
View GitHub Profile
@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 / 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 / BESENObject.pas
Created May 4, 2011 18:20
How to get BESEN (Revision: 145) to work with FreePascal 2.4.x: Replace line 1280 with the following in BESENObject.pas. Thanks to BeRo for the hint.
Hash:=((Hash-TBESENUINT32(Integer(Prop^.Attributes))) xor TBESENUINT32(Integer(Prop^.Presents)))*1664525;
@frostney
frostney / SDL_uikitview.m
Created May 27, 2011 08:35
Add a simple function in SDL iOS 1.3 to detect if the current target has a retina display or not.
/*
Add this little function to a .m file of your choice. I chose SDL_uikitview.m as it already has the iPhone specific keyboard functions in it.
I'm pretty sure you can choose any *.m file in /Library Source/video/uikit from the Xcode project file.
Make sure this function is added after @implementation ... @end.
Admittedly this is not best solution as it forces you capsulate your asset loading into one or more if calls.
SDL unfortunately has no tie-ins to NSImage, so you can't use the usual @2x stuff by default. (I'm not sure about SDL_image for iOS though. This option here is also preferred if you want to include a third-party non-SDL image library such as Vampyre Imaging.)
*/
@frostney
frostney / myApplication.pas
Created May 31, 2011 16:08
Elysion - Custom template (If you don't want or need to use the default template shipped with Elysion)
(*
Elysion Custom Template
Compile with: fpc -Mdelphi myApplication.pas
Make sure the Elysion library source are added to the search paths of the compiler for example by compiling with fpc -Mdelphi -Fu./path/to/Elysion -Fi./path/to/Elysion myApplication.pas
(Created by Johannes Stein, 2011. This source code file is PUBLIC DOMAIN.)
*)
program myApplication;
@frostney
frostney / SDL_uikitview.m
Created June 12, 2011 10:39
Add a simple function in SDL iOS 1.3 to detect whether the current target is an iPhone or an iPad
/*
Add this little function to a .m file of your choice. I chose SDL_uikitview.m as it already has the iPhone specific keyboard functions in it.
I'm pretty sure you can choose any *.m file in /Library Source/video/uikit from the Xcode project file.
Make sure this function is added after @implementation ... @end.
*/
int
SDL_iPhoneIsDevicePad(void)
@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
@frostney
frostney / cmdtest.pas
Created September 10, 2011 18:11
Converts the output of the command line to a string list without the use of pipes or processes. This should work on all unixoid systems.
program cmdtest;
uses
Unix,
Classes,
SysUtils;
function CmdToString(Command: AnsiString): TStringList;
var
formattedDateTime: AnsiString = '';
@frostney
frostney / less-1.3.0.js
Created March 14, 2012 22:28
Less 1.3.0 with being always set to production mode
//
// LESS - Leaner CSS v1.3.0
// http://lesscss.org
//
// Copyright (c) 2009-2011, Alexis Sellier
// Licensed under the Apache 2.0 License.
//
(function (window, undefined) {
//
// Stub out `require` in the browser
@frostney
frostney / gist:2561433
Created April 30, 2012 19:05
Small jQuery plugin for using CSS3 properties with vendor prefixes. Also includes functions for scaling and rotating.
(function($) {
var vendorPrefix = ['webkit', 'o', 'ms', 'moz'];
$.fn.vendorProperty = function(property, argument) {
var self = this;
self.css(property, argument);
$.each(vendorPrefix, function(index, value) {
self.css('-' + value + '-' + property, argument);