Skip to content

Instantly share code, notes, and snippets.

@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 / onedrivefix.bat
Created June 9, 2020 11:57
microsoft onedrive fix for cannot connect to drive error
cd %systemroot%\system32\drivers
sc query cldflt
sc config cldflt start=auto
@sahilsk
sahilsk / sts-decode.py
Created June 7, 2020 08:18
aws sts decode-authorization-message
import boto3
import json
import sys
encodedMessageStr = sys.argv[1]
client = boto3.client('sts')
response = client.decode_authorization_message(
EncodedMessage=encodedMessageStr
)
@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 / burrow.toml
Last active November 27, 2024 08:07
Burrow configuration with slack and pagerduty notification
[general]
pidfile="burrow.pid"
stdout-logfile="burrow.out"
[logging]
filename="/opt/burrow/logs/burrow.log"
level="info"
maxsize=100
maxbackups=10
maxage=10
@sahilsk
sahilsk / keybase.md
Created September 10, 2019 02:37
Keybase.md

Keybase proof

I hereby claim:

  • I am sahilsk on github.
  • I am sahilkewl (https://keybase.io/sahilkewl) on keybase.
  • I have a public key ASDf72xLDozNDSBjyZvu2zl29WElHoD6s0JqnYpwvpBVjgo

To claim this, I am signing this object:

@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();