Skip to content

Instantly share code, notes, and snippets.

View firesofmay's full-sized avatar

Mayank Jain firesofmay

View GitHub Profile
@firesofmay
firesofmay / sml-conf.el
Created September 26, 2014 07:08
Emacs SML Config for Coursera Course Prog Lang
(require 'sml-mode)
(setenv "PATH" (concat "/usr/local/Cellar/smlnj/110.75/libexec/bin:" (getenv "PATH")))
(setq exec-path (cons "/usr/local/Cellar/smlnj/110.75/libexec/bin" exec-path))
;; README
;; To load a file and run sml repl -> Press C-c C-v inside a sml file.
;; To run the current files tests -> Press C-c C-r inside a sml file. It assumes the tests are inside the same directory.
;; For example, If your code file is hw1.sml your test file should be named as hw1tests.sml in the same directory
(defn fancy-mod
"Takes the following parameters and
returns a function which takes two integer numbers.
- operator-fn => Mathematical Operator : + OR * OR / OR -
- mod-by => number to mod by, example 2.
- output-fn => str or int.
Example:
((fancy-mod + 2 str) 10 11)
@firesofmay
firesofmay / error
Created June 15, 2014 06:46
Error installing nginx.
$ brew install nginx-full --with-headers-more-module
==> Downloading http://nginx.org/download/nginx-1.6.0.tar.gz
Already downloaded: /Library/Caches/Homebrew/nginx-full-1.6.0.tar.gz
==> Patching
patching file conf/nginx.conf
==> ./configure --prefix=/usr/local/Cellar/nginx-full/1.6.0 --with-http_ssl_module --with-pcre --with
==> make
==> make install
Error: Not a directory - (html, /usr/local/var/www)
#lang racket
;cons* takes two values and returns a new function
;which again takes a function f which is called with the closed over values x y
(define (cons* x y)
(lambda (f) (f x y)))
;car* is a function which takes a function which takes two values
;but returns just the first value and ignores the second value
;here _ is a way to say that I do take that argument but I dont care about it.
@firesofmay
firesofmay / justforfun.sml
Last active December 27, 2015 01:09
My attempt to calculating the runtime of all the videos in a list.
exception NoAnswer;
val files : string list = ["Signatures and Hiding Things (7-02).mp4",
"A Module Example (11-06).mp4",
"Signatures for Our Example (11-03).mp4",
"Signature Matching (4-03).mp4",
"An Equivalent Structure (6-38).mp4",
"Another Equivalent Structure (9-01).mp4",
"Different Modules Define Different Types (3-32).mp4",
"Equivalent Functions (8-41).mp4",
@firesofmay
firesofmay / testcase.sml
Created October 29, 2013 19:10
Test case for week3 challenge problem.
val Q13_same_con_in_2_datatypes = typecheck_patterns ([("A", "Dt1", IntT),
("A", "Dt2", IntT)],
[TupleP [ConstructorP ("A", ConstP 20)],
TupleP [ConstructorP ("A", ConstP 10)]]);
(*val Q13_same_con_in_2_datatypes = SOME (TupleT [Datatype "Dt1"]) : typ option*)
global windowx
global mousex
tell application "Finder"
set boundlist to get bounds of window of desktop
end tell
set windowx to item 3 of boundlist as string
set mousex to do shell script "/Users/firesofmay/mybin/MouseTools -location | head -n 1"
@firesofmay
firesofmay / rand_uuid.clj
Last active December 19, 2015 23:49 — forked from gorsuch/gist:1418850
Clojure random UUID
(defn uuid [] (str (java.util.UUID/randomUUID)))
@firesofmay
firesofmay / keystroke_applescript
Created July 17, 2013 19:54
some apple script examples for keystroke
tell application "System Events"
keystroke "v" using command down
delay 0.1
keystroke "."
key code 51
key code 51
key code 36 using control down
end tell
@firesofmay
firesofmay / run_this_scpt
Last active December 19, 2015 18:38
Function to run applescript code inside python. Optionally accepts arguments.
from subprocess import Popen, PIPE
def run_this_scpt(scpt, args=[]):
p = Popen(['osascript', '-'] + args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate(scpt)
return stdout
#Example of how to run it.
run_this_scpt("""tell application "System Events" to keystroke "m" using {command down}""")