Skip to content

Instantly share code, notes, and snippets.

View 9to6's full-sized avatar
🏠
Working from home

Gunner Kwon 9to6

🏠
Working from home
View GitHub Profile
#!/bin/bash
# Copyright 2017 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@joost
joost / api_controller.rb
Last active July 31, 2018 06:38
Validate parameters in Rails 4 JSON API
class ApiController < ApplicationController
# FIXME: Since we cannot set ActionController::Parameters.action_on_unpermitted_parameters = :raise
# on a controller level we do this hotfix.
class ApiParameters < ActionController::Parameters
def action_on_unpermitted_parameters
:raise
end
end
def params
@willurd
willurd / web-servers.md
Last active July 26, 2024 13:45
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@huyng
huyng / reflect.py
Created February 7, 2011 17:57
A simple echo server to inspect http web requests
#!/usr/bin/env python
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
# Written by Nathan Hamiel (2010)
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):