Skip to content

Instantly share code, notes, and snippets.

@sahilsk
sahilsk / x.json
Created March 5, 2021 20:07 — forked from KensoDev/x.json
{
"Volumes": [
{
"AvailabilityZone": "us-west-2a",
"Attachments": [
{
"AttachTime": "2013-09-17T00:55:03.000Z",
"InstanceId": "i-a071c394",
"VolumeId": "vol-e11a5288",
"State": "attached",
{
"DBInstances": [
{
"PubliclyAccessible": false,
"MasterUsername": "mymasteruser",
"MonitoringInterval": 0,
"LicenseModel": "general-public-license",
"VpcSecurityGroups": [
{
"Status": "active",
@sahilsk
sahilsk / mock_requests.py
Created February 24, 2021 17:41 — forked from evansde77/mock_requests.py
Example of mocking requests calls, python requests.get mock
#!/usr/bin/env python
"""
mocking requests calls
"""
import mock
import unittest
import requests
from requests.exceptions import HTTPError
@sahilsk
sahilsk / async-await.js
Created January 12, 2021 22:54 — forked from wesbos/async-await.js
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}
@sahilsk
sahilsk / predict2.py
Created June 17, 2020 19:44 — forked from rajarsheem/predict2.py
Temperature Predictions
# PROBLEM LINK : https://www.hackerrank.com/challenges/temperature-predictions
import numpy as np
from sklearn import ensemble
def isfloat(value):
try:
float(value)
return True
@sahilsk
sahilsk / ec2-aws-hostanme-change.md
Last active May 20, 2020 18:09 — forked from diegopacheco/ec2-aws-hostanme-change.md
How to change Hostname on Amazon Linux - EC2 AWS?

Summary

  1. Change file /etc/sysconfig/network
  2. Change file /etc/hostname
  3. Chnage file /etc/hosts
sudo vim /etc/sysconfig/network
@sahilsk
sahilsk / wafv2.yaml
Created March 19, 2020 15:40
cloudformation-yaml-wafv2 parametrized DefaultAction using custom action
Description: Create WebACL example
Parameters:
WebACLDefaultAction:
Type: String
AllowedValues:
- Allow
- Block
WebACLRuleAction:
Type: String
@sahilsk
sahilsk / test-simple-http-data.js
Created August 3, 2019 07:17 — forked from murvinlai/test-simple-http-data.js
Socket Hang up problem - A sample to generate the problem.
/*
* This is a simple HTTP data generator for testing.
*
*/
var http = require('http');
var counter = 0;
http.createServer(function (req, res) {
var start = new Date();
@sahilsk
sahilsk / README-Template.md
Created April 29, 2019 03:26 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@sahilsk
sahilsk / kubernetes_add_service_account_kubeconfig.sh
Created April 11, 2019 09:52 — forked from innovia/kubernetes_add_service_account_kubeconfig.sh
Create a service account and generate a kubeconfig file for it - this will also set the default namespace for the user
#!/bin/bash
set -e
set -o pipefail
# Add user to k8s using service account, no RBAC (must create RBAC after this script)
if [[ -z "$1" ]] || [[ -z "$2" ]]; then
echo "usage: $0 <service_account_name> <namespace>"
exit 1
fi