Skip to content

Instantly share code, notes, and snippets.

View yashhere's full-sized avatar

Yash Agarwal yashhere

View GitHub Profile
#!/usr/bin/python2.7
spam=['free movie tickets','free watch offer','rolex watch discount']
ham=['I watch movie','I am free']
## function to calculate prior probability for SPAM ##
## how many SPAM seen out of all messages? ##
def get_prior_spam_probability(spam,ham):
return float(len(spam))/(len(spam)+len(ham))
$ grunt server
...
Running "configureProxies:server" (configureProxies) task
Rewrite rule created for: [/^\/api/ -> /backend].
Proxy created for: /api to localhost:8000
Running "connect:server" (connect) task
Started connect web server on http://localhost:8080
...
...
middleware: function (connect, options, middlewares) {
middlewares.unshift(require('grunt-connect-proxy/lib/utils').proxyRequest);
return middlewares;
}
...
grunt.registerTask('server', function (target) {
grunt.task.run([
'configureProxies:server',
'connect:server',
]);
});
connect: {
server: {
options: {
port: 8080,
base: 'public',
hostname: 'localhost',
livereload: true,
middleware: function (connect, options, middlewares) {
middlewares.unshift(require('grunt-connect-proxy/lib/utils').proxyRequest);
return middlewares;
@yashhere
yashhere / go-shebang-story.md
Created February 21, 2018 06:12 — forked from posener/go-shebang-story.md
Story: Writing Scripts with Go

Story: Writing Scripts with Go

This is a story about how I tried to use Go for scripting. In this story, I’ll discuss the need for a Go script, how we would expect it to behave and the possible implementations; During the discussion I’ll deep dive to scripts, shells, and shebangs. Finally, we’ll discuss solutions that will make Go scripts work.

Why Go is good for scripting?

While python and bash are popular scripting languages, C, C++ and Java are not used for scripts at all, and some languages are somewhere in between.

@yashhere
yashhere / gist:644b8741b31b96bd2a1d03ddb27b931c
Created February 14, 2018 14:01 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@yashhere
yashhere / open_source_at_mozilla_intro.md
Created February 14, 2018 11:49 — forked from mjzffr/open_source_at_mozilla_intro.md
This is an excerpt of an email exchange I had with a student interested in contributing to Mozilla's open source projects. The notes and resources are aimed at someone who has knowledge of programming (1st-year CS, say) but little or no knowledge of version control. Feel free to remix, reuse. :)

Hey ---, nice to talk with you yesterday! Giant email ahead!

Here's what we talked about:

All open source projects use version control tools like git for code submission. Mozilla uses two version control tools (hg and git) to track the history of code changes: hg (also called mercurial) is used for Firefox code, git is used for other supporting projects. The underlying concepts for hg and git are similar, but I think the documentation for git is much better so I suggest you focus on git first. Github is a web-based user interface for git. Locally (i.e. "on your computer"), you will interact with git using the terminal instead by entering commands. Version control is all about tracking project history so that it's easy to merge work from many different people or go back in time; it's an extra step/tool in software development on top of writing/testing your code.

To start working on any open source project, the first step is to get a copy of the source code repository (e.g. git clone). Then the programmer ch

$ mkdir themes/zeo/layouts/post
$ vim themes/zeo/layouts/post/single.html
{{ partial "header.html" . }}

  <h1>{{ .Title }}</h1>
  <h2>{{ .Date.Format "Mon, Jan 2, 2006" }}</h2>
  {{ .Content }}

{{ partial "footer.html" . }}
$ vim themes/zeo/layouts/_default/single.html
{{ partial "header.html" . }}

  <h1>{{ .Title }}</h1>
  <h2>{{ .Date.Format "Sun, Feb 11, 2018" }}</h2>
  {{ .Content }}

{{ partial "footer.html" . }}