Skip to content

Instantly share code, notes, and snippets.

View probablycorey's full-sized avatar
πŸ‘―β€β™‚οΈ
Dancing with my twin

Corey Johnson probablycorey

πŸ‘―β€β™‚οΈ
Dancing with my twin
View GitHub Profile
@probablycorey
probablycorey / something.coffee
Last active December 20, 2015 06:08
Simulate keydown,keypress,keyup and textinput in chrome
# Shift still doesn't work
window.keydown = (key, {ctrl, shift, alt, meta}) ->
dispatchKeyboardEvent = (target, eventArgs...) ->
e = document.createEvent("KeyboardEvent")
e.initKeyboardEvent eventArgs...
target.dispatchEvent e
dispatchTextEvent = (target, eventArgs...) ->
e = document.createEvent("TextEvent")
e.initTextEvent eventArgs...
@probablycorey
probablycorey / peer.html
Created July 19, 2013 00:41
A bug in peer js
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>PeerJS Issue</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en-us">
<script type="text/javascript" src="http://cdn.peerjs.com/0/peer.js"></script>
<script type="text/javascript" src="http://coffeescript.org/extras/coffee-script.js"></script>
<script type="text/coffeescript">
window.host = ->
def create
build_resource!
card = ActiveMerchant::Billing::CreditCard.new(
:number => params[:expiry_number],
:month => params[:expiry_month],
:year => params[:date_year],
:name => params[:name_on_card],
:verification_value => :params[:cvv]
)
String file contents!
local path = NSDocumentDirectory .. "/SomeDirectoryName"
local err = nil -- use err (instead of error) as the var name because error is a global lua function
if not NSFileManager:defaultManager():fileExistsAtPath(path) then
if not NSFileManager:defaultManager():fileManager:createDirectoryAtPath_withIntermediateDirectories_attributes_error(path, false, nil, err) then
puts("Create directory error %s", err:localizedDescription())
end
end
http://app.info.avid.com/e/er.aspx?elq_mid=4196&elq_cid=6541875&s=774&lid=4937&elq=d35c821242274f698fb5d7903e773409
void uncaughtExceptionHandler(NSException *e) {
NSLog(@"ERROR: Uncaught exception %@", [e description]);
lua_State *L = wax_currentLuaState();
if (L) {
wax_getStackTrace(L);
const char *stackTrace = luaL_checkstring(L, -1);
NSLog(@"%s", stackTrace);
NSString *message = [NSString stringWithFormat:@"Unexpected Exception:\n---------------------\n%@\n%s", [e description], stackTrace];
@probablycorey
probablycorey / perfect.m
Created July 28, 2011 18:25
How a property should be defined
@interface Perfect : NSObject {
@property UIView *containerView;
@property(nonatomic) UILabel *titleText;
}
local picData = toJPEG(photo):base64EncodedString()
local body = wax.http.escapeParams{pic = picData}
ImageModel:post{url, body = body, callback = function(body, response)
-- Blah Blah Blah
end}
diff --git a/lib/wax_helpers.m b/lib/wax_helpers.m
index dee91a9..f0c351d 100644
--- a/lib/wax_helpers.m
+++ b/lib/wax_helpers.m
@@ -219,7 +219,7 @@ void wax_fromInstance(lua_State *L, id instance) {
if ([instance isKindOfClass:[NSString class]]) {
lua_pushstring(L, [(NSString *)instance UTF8String]);
}
- else if ([instance isKindOfClass:[NSNumber class]]) {
+ else if ([instance isKindOfClass:[NSNumber class]] && ![instance isKindOfClass:[NSDecimalNumber class]]) lua_pushnumber(L, [instance doubleValue]);