- Most common 4 HTTP VERB used in WEB API
- GET,PUT,POST,DELETE
- what is CORS ?
- Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources (e.g. fonts) on a web page to be requested from another domain outside the domain from which the resource originated.
- Only web fonts and AJAX(XMLHttpRequest) requests faced CORS problem.
- For simple CORS requests, the server only needs to add the following
header to its response:
Access-Control-Allow-Origin: *
- what is CSRF attack?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # System wide Constants | |
| # Ubuntu Code Name Ex:- trusty for Ubuntu 14.04 | |
| CODE_NAME=$(lsb_release -cs) | |
| ## Install basic libraries required for ubuntu environment | |
| sudo apt-get install libcurl4-openssl-dev libssl-dev -y | |
| sudo apt-get install zsh -y | |
| sudo apt-get install python-software-properties -y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # exporter.py | |
| import pprint | |
| def export(field, value): | |
| res = {} | |
| if "to_dict" in dir(value): | |
| res.update(getattr(value, "to_dict", None)(value)) | |
| elif isinstance(value, list): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| # install boto using pip | |
| import types | |
| from threading import Thread | |
| from boto import ( | |
| ses, | |
| connect_s3 | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <Directory /home/ubuntu/project-dir> | |
| Options FollowSymLinks | |
| AllowOverride None | |
| Require all granted | |
| Header unset ETag | |
| FileETag None | |
| <IfModule mod_expires.c> | |
| ExpiresActive On | |
| ExpiresDefault "access plus 1 seconds" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| def RateLimited(maxPerSecond): | |
| minInterval = 1.0 / float(maxPerSecond) | |
| def decorate(func): | |
| lastTimeCalled = [0.0] | |
| def rateLimitedFunction(*args,**kargs): | |
| elapsed = time.clock() - lastTimeCalled[0] | |
| leftToWait = minInterval - elapsed | |
| if leftToWait>0: |
I hereby claim:
- I am kodekracker on github.
- I am spratapakshay (https://keybase.io/spratapakshay) on keybase.
- I have a public key ASD0-NSSOnWRdk6zbe3Hib9Izuc_XSDFJEYUjXbKn97qiQo
To claim this, I am signing this object:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # to generate your dhparam.pem file, run in the terminal | |
| openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| def rate_limiter(period, damping = 1.0): | |
| """ | |
| Prevent a method from being called if it was previously called before | |
| a time widows has elapsed. | |
| :param period: The time window after which method invocations can continue | |
| :param damping: A factor by which to dampen the time window. | |
| :return function: Decorated function that will forward method invocations if the time window has elapsed. | |
| """ |