Skip to content

Instantly share code, notes, and snippets.

View kodekracker's full-sized avatar
🎯
Focusing

Akshay Pratap Singh kodekracker

🎯
Focusing
View GitHub Profile
@kodekracker
kodekracker / Questions.md
Last active January 14, 2016 10:46
A list of interview questions
  1. Most common 4 HTTP VERB used in WEB API
    • GET,PUT,POST,DELETE
  2. 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: *
  3. what is CSRF attack?
@kodekracker
kodekracker / install.sh
Last active April 4, 2024 13:55
A shell script to install all required applications and dependencies required to setup working environment after fresh install ubuntu .
#!/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
@kodekracker
kodekracker / exporter.py
Created April 8, 2016 10:43
A Exporter class to export it's attributes to dictionary form.
# 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):
@kodekracker
kodekracker / API.md
Created June 10, 2016 15:28 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@kodekracker
kodekracker / async-mailer.py
Last active November 21, 2017 05:23
Asynchronous mail sending using Amazon SES
#!/usr/bin/python
# install boto using pip
import types
from threading import Thread
from boto import (
ses,
connect_s3
)
@kodekracker
kodekracker / browser-caching-apache.conf
Created July 29, 2016 07:20
A browser caching snippet for apache server
<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"
@kodekracker
kodekracker / rateLimitDecorator.py
Created August 25, 2016 14:19 — forked from gregburek/rateLimitDecorator.py
Rate limiting function calls with Python Decorators
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:

Keybase proof

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:

@kodekracker
kodekracker / nginx.conf
Created September 16, 2016 20:15 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
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.
"""