Skip to content

Instantly share code, notes, and snippets.

@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:

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 / 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
1995-01-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1995-03-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1995-05-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1995-07-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1995-09-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1995-11-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1996-01-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1996-03-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1996-05-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1996-07-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1995-01-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1995-03-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1995-05-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1995-07-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1995-09-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1995-11-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1996-01-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1996-03-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1996-05-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1996-07-01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@meric
meric / gist:a77f6633e023310be114
Created April 2, 2015 01:35
immstruct building pattern
// Content.js
Content.construct = function(statics, cursor, {country}) {
cursor = cursor.update(() => Immutable.fromJS({
country: (country || ""),
url: statics.routePath,
}))
return new Promise((resolve, reject) =>
setTimeout(() => resolve("Hello World"), 500))
.then((value) => cursor.cursor('world').update(() => value))
}
{
"user": {
"method": "GET",
"url": "/user/1/",
},
"cart": {
"method": "GET",
"url": "/cart/1/",
},
"log": {
<!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'])