Skip to content

Instantly share code, notes, and snippets.

@ram-nadella
ram-nadella / Dockerfile
Last active May 22, 2020 20:32
tl;dr download this gist as a zip, unpack and run `docker-compose up` (need to have docker installed)
FROM ruby:2.7
RUN gem install sinatra redis
WORKDIR /app
COPY . .
CMD ["ruby", "web.rb", "-o", "0.0.0.0"]
@ram-nadella
ram-nadella / deployments.yaml
Last active August 4, 2019 00:18
GKE nginx ingress example
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-server
spec:
replicas: 2
selector:
matchLabels:
app: hello-server-app
template:
  • Fix the SVG logo
  • Resize logo & show at the top
  • Extension icon
@ram-nadella
ram-nadella / signalfx-pythong-django-signal.py
Last active November 4, 2016 18:08
A helper module that wraps the SignalxFX python module to expose easy metrics usage functions and uses Django signals to flush metrics
import atexit
import logging
import time
from celery.signals import task_postrun
from django.dispatch import receiver
from django.core.signals import request_finished
from django.conf import settings
import signalfx
package example
import (
"fmt"
"math/rand"
"net/http"
"google.golang.org/appengine"
"google.golang.org/appengine/file"
"google.golang.org/appengine/log"
~ $ time curl -i http://temporary-redirect.herokuapp.com
HTTP/1.1 307 Temporary Redirect
Connection: keep-alive
Date: Sun, 17 Apr 2016 01:05:26 GMT
Server: Apache/2.4.16 (Unix) OpenSSL/1.0.1f
X-Powered-By: PHP/5.6.18
Time: 1460855126.4312
Location: https://307.temporaryredirect.com
Content-Length: 0
Content-Type: text/html; charset=UTF-8
@ram-nadella
ram-nadella / output.sh
Created March 7, 2016 04:21
Using TMDB (The Movie Database), find the air date of the next season for a TV show by name
~/code/misc/tv-show-next $ ruby check.rb
Silicon Valley Season 3 2016-04-24
Game of Thrones Season 6 2016-04-24
Togetherness Season 2 2016-02-21
House of Cards Season 4 2016-03-04
~ $ curl -i 'https://4kvobmwat0.execute-api.us-east-1.amazonaws.com/prod/myTestFunction1'
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 19
Connection: keep-alive
Date: Mon, 15 Feb 2016 23:19:53 GMT
x-amzn-RequestId: 9e37d9ff-d43a-11e5-b2b6-77d2ab8c286e
X-Cache: Miss from cloudfront
Via: 1.1 dbfc7fdca19a1a429546608a6a58a3d2.cloudfront.net (CloudFront)
X-Amz-Cf-Id: fGyvXk472n6Xxuj62ygYk0fetr2IJUSIWIFUErikN2TTUxic_ei2Hw==
@ram-nadella
ram-nadella / trim.lua
Created January 19, 2016 22:40
Trim a lua string
function trim(s)
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
end