This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; Creates a fake NAND gate and then creates all gates from NAND. | |
;;;; This is just an exercise, obviously has no practical application. | |
;;; NAND | |
(defun !& (a b) (if (and (= a 1) (= b 1)) 0 1)) | |
;;; NOT | |
(defun ! (a) (!& a 1)) | |
;;; AND |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.enginebai.sample; | |
import android.content.Context; | |
import android.location.Location; | |
import android.location.LocationListener; | |
import android.location.LocationManager; | |
import android.os.Bundle; | |
import android.support.design.widget.FloatingActionButton; | |
import android.support.design.widget.Snackbar; | |
import android.support.v7.app.AppCompatActivity; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys,os | |
import curses | |
def draw_menu(stdscr): | |
k = 0 | |
cursor_x = 0 | |
cursor_y = 0 | |
# Clear and refresh the screen for a blank canvas | |
stdscr.clear() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys; from PIL import Image; import numpy as np | |
chars = np.asarray(list(' .,:;irsXA253hMHGS#9B&@')) | |
if len(sys.argv) != 4: print( 'Usage: ./asciinator.py image scale factor' ); sys.exit() | |
f, SC, GCF, WCF = sys.argv[1], float(sys.argv[2]), float(sys.argv[3]), 7/4 | |
img = Image.open(f) | |
S = ( round(img.size[0]*SC*WCF), round(img.size[1]*SC) ) | |
img = np.sum( np.asarray( img.resize(S) ), axis=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print "Hello, switch" | |
-- If the default case does not have to be handled, we can use the following auxiliary function: | |
local function switch(value) | |
-- Handing `cases` to the returned function allows the `switch()` function to be used with a syntax closer to c code (see the example below). | |
-- This is because lua allows the parentheses around a table type argument to be omitted if it is the only argument. | |
return function(cases) | |
-- The default case is achieved through the metatable mechanism of lua tables (the `__index` operation). | |
setmetatable(cases, cases) |