Skip to content

Instantly share code, notes, and snippets.

local getlocal, setlocal = debug.getlocal, debug.setlocal
local function from_err(k, msg)
local info = debug.getinfo(3)
io.stderr:write(string.format(
"%s:%s:%d: local variable '%s' %s in import block\n",
info.source:sub(2),info.name,info.currentline,k,msg))
os.exit()
end
@meric
meric / challenge.py
Created March 1, 2017 12:41
credit card validation
"""Implement credit card validation in response to
https://gist.github.com/cam-stitt/5ce63c0c2090a46b2263
Run using Python 3.4+.
Sample Usage:
cat << EOF | python3 challenge.py
4111111111111111
4111111111111
4012888888881881
@meric
meric / intelligent_creator.md
Last active August 5, 2016 15:33
Logical Proof Of An "Intelligent Creator".

Assumptions:

A. By intelligent, it means, you are intelligent.

B. By "you", I mean your mind, and the rest of your body, since your mind cannot exist in separation from your body.

C. Either the universe is self-derived and creates itself moment to moment, or it isn't, and there is a creator beyond it.

Proof:

// Code goes here
var testApp = angular.module('testApp', ['restangular'])
.config(function(RestangularProvider){
RestangularProvider.setBaseUrl("http://localhost/");
RestangularProvider.setRequestSuffix('/');
})
.controller('MainCtrl', function() {
})
<!DOCTYPE html>
<html>
<body ng-app="testApp">
<h1>Hello Plunker!</h1>
<script src="http://cdn.jsdelivr.net/underscorejs/1.5.1/underscore-min.js"></script>
<script src="http://code.angularjs.org/1.2.0rc1/angular.js"></script>
<script src="https://raw.github.com/mgonto/restangular/master/dist/restangular.min.js"></script>
<script>
// Code goes here
var testApp = angular.module('testApp', ['restangular'])
@meric
meric / a-star-velocity-demo.lua
Created December 13, 2015 04:33
A-star velocity fails, example
local BinaryHeap
local PriorityQueue = setmetatable({
empty = function(self)
return self.length == 0
end,
insert = function(self, value, priority)
assert(type(priority) == "number")
self.length = self.length + 1
table.insert(self, {value, priority})
@meric
meric / diff
Last active November 20, 2015 05:30
➜ l2l git:(master) ✗ git difftool --extcmd=diff compiler.lua --no-prompt | tee
23a24,25
> local _C
>
556c558,559
< eval = function (obj, stream, env)
---
> eval = function (obj, stream, env, G)
> G = G or _G
587c590
➜ _bootstrap git:(master) cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/Eric/test/_bootstrap
➜ _bootstrap git:(master) ✗ make
Scanning dependencies of target lua
[ 0%] Creating directories for 'lua'
[ 0%] No download step for 'lua'
[ 0%] No patch step for 'lua'
[ 0%] No update step for 'lua'
➜ test echo "$(curl -fksSL https://raw.github.com/gist/2394281/luadist.sh)" | bash
@meric
meric / base.py.diff
Created September 13, 2012 11:26
git diff 2ef7d14040a261fe284a8b72490712d4019a5766__base.py base.py
diff --git a/2ef7d14040a261fe284a8b72490712d4019a5766__base.py b/base.py
index d0a4b63..4c4d9eb 100644
--- a/2ef7d14040a261fe284a8b72490712d4019a5766__base.py
+++ b/base.py
@@ -114,25 +114,23 @@ class BaseHandler(object):
response = middleware_method(request, callback, callback_args, callback_kwargs)
if response:
break
-
- if response is None: