Skip to content

Instantly share code, notes, and snippets.

View firesofmay's full-sized avatar

Mayank Jain firesofmay

View GitHub Profile
@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)
(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 / 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
@firesofmay
firesofmay / math.txt
Created December 22, 2014 13:23
Inputs
| TestCase | Input | Output | Expected |
|----------+-----------------+---------------+----------|
| 01 | "" | "" | Error |
| 02 | "()" | "" | Error |
| 03 | " 1 + 2 " | Invalid Input | 3.0 |
| 04 | "11" | 11 | 11.0 |
| 05 | "2-4+6" | 22.0 | 4.0 |
| 06 | "2-4+6-1-1-0+8" | 21.0-18.0 | 10.0 |
| 07 | "1-1+2-2+4-4+6" | 11.02.02.0 | 6.0 |
@firesofmay
firesofmay / stop_words.txt
Created December 30, 2014 12:36
stop words
a
about
above
after
again
against
all
am
an
and
@firesofmay
firesofmay / weekyear-week
Created April 16, 2015 10:41
Convert datetime to weekyear-week
(do
(require '[clj-time.format :as f])
(require '[clj-time.core :as t])
(defn get-week
[dt]
(f/unparse (:weekyear-week f/formatters)
dt))
(println (get-week (t/now)))
(println (get-week (t/minus (t/now)
(t/days 30)))))
#Py code
import cProfile
import urllib2
def main():
urllib2.urlopen('http://majorgeeks.com/page.php?id=1')
if __name__ == '__main__':
cProfile.run('main()')
main()
#Py Code tested
import urllib2
import cProfile
def main():
url = "http://majorgeeks.com/page.php?id="
for i in xrange(1,21):
tempurl = url + str(i)
res = urllib2.urlopen(tempurl)
(defn getepoch [timestamp]
(int (/ (.getMillis timestamp) 1000)))
@firesofmay
firesofmay / gist:3271980
Created August 6, 2012 07:44
Code to select iFrame and input text inside of it.
(switch-to-frame 0)
(switch-to-active)
(send-keys "body" "Thanks to noidi_ :)")
(switch-to-default) ;This is switch back from iframe.
(click (find-element {:tag :button :type :submit})) ;to submit :)