Skip to content

Instantly share code, notes, and snippets.

View swaathi's full-sized avatar
💃

Swaathi Kakarla swaathi

💃
View GitHub Profile
@swaathi
swaathi / postmortem.md
Created June 20, 2019 10:39 — forked from mlafeldt/postmortem.md
Example Postmortem from SRE book, pp. 487-491

Shakespeare Sonnet++ Postmortem (incident #465)

Date

2015-10-21

Authors

  • jennifer
  • martym
@swaathi
swaathi / markdown-template-engine.rb
Last active December 16, 2017 06:50
Markdown Template Engine
PWD = File.expand_path(File.dirname(__FILE__))
VARIABLE_REGEX = %r{\<[A-Z\-]*\>}
class MTEngineError
class << self
def not_a_file(filepath)
raise "#{filepath} is not a file or does not exist"
end
end
end
@swaathi
swaathi / .gitconfig
Created November 25, 2017 12:49
.gitconfig
[user]
name = <username>
email = <email>
[credential]
helper = osxkeychain
[alias]
ci = commit
fu = fetch upstream
mum = merge upstream/master
pom = push origin master
@swaathi
swaathi / show
Last active May 29, 2019 14:11
Add quick functions to your shell
#! /bin/bash
if [[ $1 == 'me' ]]; then
cat "$(which show)"
elif [[ $1 == 'loc' ]]; then
echo `which show`
elif [[ $1 == 'install' ]]; then
echo "Ensure to place this file in `usr/local/bin` and read instructions on https://gist.github.com/swaathi/8c18be3a437e498034a5a3ede54d0ce9/."
brew install fortune
brew install cowsay
brew install lolcat
@swaathi
swaathi / dijkstras.py
Last active October 27, 2019 00:39
Dijkstra's Algorithm with Python
from collections import defaultdict
class Graph:
def __init__(self, start, end):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
self.start = start
self.end = end
def add_node(self, value):
@swaathi
swaathi / parser.rb
Last active December 25, 2016 11:18
ML Training Data
require 'fileutils'
require 'securerandom'
directory = File.expand_path File.dirname(__FILE__)
textfiles = "#{directory}/textfiles"
FileUtils::mkdir_p textfiles
Dir["#{directory}/*.scss"].each do |file|
file_content = File.new(file, "r").read
rgbas = file_content.scan(/rgba\(([0-9, ]*)/)
@swaathi
swaathi / time.rb
Last active September 26, 2016 04:26
Offset your time by timezone difference
class Time
# Adds an offset to your time
# So you can go from
# Fri, 22 Jul 2016 07:56:38 UTC +00:00
# To,
# Fri, 22 Jul 2016 13:26:38 UTC +00:00
#
# Example,
# t = Time.now.utc
# => Fri, 22 Jul 2016 07:56:38 UTC +00:00
@swaathi
swaathi / getNames.jsx
Created July 17, 2016 06:35
Convert an array into a comma seperated sentence.
getNames: function(people) {
var length = people.length;
if (length == 0) {
return "";
} else if (length == 1) {
return people[0].name;
} else if (length == 2) {
return people[0].name + " and " + people[1].name;
} else {
var SongsSearch = React.createClass({
render () {
return (
<div>
<form ref="form" action={ this.props.searchPath } acceptCharset="UTF-8" method="get">
<p><input ref="query" name="query" placeholder="Search here." onChange={ this.props.submitPath } /></p>
</form>
<a href="#" onClick={ this.props.cancelPath }>Cancel</a>
</div>
var Song = React.createClass({
render () {
return (
<div>
<h4>{ this.props.artist } sang:</h4>
<p>{ this.props.name }</p>
</div>
)
}
});