Skip to content

Instantly share code, notes, and snippets.

Avatar

Kunal Yadav abkunal

View GitHub Profile
@abkunal
abkunal / config.py
Last active Jan 2, 2021
CDK configuration to create a custom VPC
View config.py
from aws_cdk.aws_ec2 import RouterType, CfnSecurityGroup
# basic VPC configs
VPC = 'custom-vpc'
INTERNET_GATEWAY = 'internet-gateway'
KEY_PAIR_NAME = 'us-east-1-key'
REGION = 'us-east-1'
@abkunal
abkunal / vpc_stack.py
Created Jan 2, 2021
CDK Stack file to create a custom VPC
View vpc_stack.py
from aws_cdk import core
from aws_cdk.aws_ec2 import Vpc, CfnRouteTable, RouterType, CfnRoute, CfnInternetGateway, CfnVPCGatewayAttachment, \
CfnSubnet, CfnSubnetRouteTableAssociation, CfnSecurityGroup, CfnInstance
from . import config
class VpcStack(core.Stack):
def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
@abkunal
abkunal / uwsgi.service
Created Oct 21, 2020
UWSGI service file for systemd
View uwsgi.service
## https://levelup.gitconnected.com/integrating-new-relic-apm-with-uwsgi-1dedcd0f92ff
[Unit]
Description=uWSGI Emperor service
[Service]
Environment="NEW_RELIC_CONFIG_FILE=/home/ubuntu/myapp/myapp/newrelic.ini"
Environment="NEW_RELIC_ENVIRONMENT=production"
ExecStartPre=/bin/bash -c 'mkdir -p /run/uwsgi; chown ubuntu:www-data /run/uwsgi'
ExecStart=/home/ubuntu/virtualenvs/myenv/bin/newrelic-admin run-program /home/ubuntu/virtualenvs/myenv/bin/uwsgi --emperor /etc/uwsgi/sitesRestart=always
@abkunal
abkunal / uwsgi.conf
Created Oct 21, 2020
UWSGI configuration file for Supervisor
View uwsgi.conf
## https://levelup.gitconnected.com/integrating-new-relic-apm-with-uwsgi-1dedcd0f92ff
[program:uwsgi]
user=root
command=/home/ubuntu/virtualenvs/myenv/bin/newrelic-admin run-program
/home/ubuntu/virtualenvs/myenv/bin/uwsgi
-H /home/ubuntu/virtualenvs/myenv
-s /home/ubuntu/myapp/myapp_uwsgi.sock
-C
--chown-socket ubuntu
@abkunal
abkunal / apm-server.yml
Created Oct 21, 2020
APM server configuration file
View apm-server.yml
# APM server 7.1.1
# run "locate apm-server.yml" to find file's location on server
apm-server:
# 0.0.0.0 allows the internet to send data to the apm server. 5700 is the port exposed by the apm server
host: "0.0.0.0:5700"
# denotes the maximum size of a single event in bytes that can be processed by the APM server.
# if an event size is greater than the configured then that event is dropped
max_event_size: 1457600
View otp.js
const http = require('http');
function sendOTP (phone, callback) => {
let path = '/api/sendotp.php?otp_length=6&authkey=' + OTP_AUTH_KEY +
'&message=&sender=MySHIK&mobile=+91'+ phone +'&otp_expiry=5';
path = encodeURI(path);
let options = {
'method': 'POST',
'hostname': 'control.msg91.com',
View countries.json
{
"nodes": [
{ "country": "East Timor", "code": "tl" },
{ "country": "Canada", "code": "ca" },
{ "country": "Turkmenistan", "code": "tm" },
{ "country": "United States of America", "code": "us" },
{ "country": "Lithuania", "code": "lt" },
{ "country": "Cambodia", "code": "kh" },
{ "country": "Ethiopia", "code": "et" },
{ "country": "Swaziland", "code": "sz" },
View world_countries.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View bar chart.html
<style>
body {
text-align: center;
}
</style>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://dimplejs.org/dist/dimple.v2.0.0.min.js"></script>
<script>
View miserables.json
{
"nodes": [
{"id": "Myriel", "group": 1},
{"id": "Napoleon", "group": 1},
{"id": "Mlle.Baptistine", "group": 1},
{"id": "Mme.Magloire", "group": 1},
{"id": "CountessdeLo", "group": 1},
{"id": "Geborand", "group": 1},
{"id": "Champtercier", "group": 1},
{"id": "Cravatte", "group": 1},