Skip to content

Instantly share code, notes, and snippets.

View crazyrohila's full-sized avatar
🏠
Working from home

Sanjay Rohila crazyrohila

🏠
Working from home
View GitHub Profile
@crazyrohila
crazyrohila / lex-workflow-blog-core-structure.yml
Last active December 4, 2018 21:43
lex-workflow-blog-core-structure
main.py
src/
- controller.py # This will do most of the heavy work
- intents/
- order_pizza.py # These are kind of interface
- book_car.py
- helpers/
- responseCards.py
- aws_api/
- cognito_api.py
@crazyrohila
crazyrohila / lex-workflow-blog-example-1.py
Last active December 4, 2018 21:32
lex-workflow-blog-example-1
# pizza_order.py
flow = {
"slots": {
"pizza_type": {
"prompt": "What type of pizza you like?",
"data": [
{
"label": "Non-Veg",
"value": "non veg"
},
@crazyrohila
crazyrohila / alexa_reprompt.py
Last active December 1, 2018 13:43
Alexa skill Re-prompt/Confirmation - Voice and Display
def lambda_handler(event, context):
if event["request"]["type"] == "LaunchRequest":
return handleLaunchRequest(event)
if event["request"]["type"] == "IntentRequest":
if ('AMAZON.' in event["request"]["intent"]["name"]):
return handleInBuiltIntents(event)
else:
return handleCustomIntents(event)
elif event["request"]["type"] == "Display.ElementSelected":
tokenValue = event["request"]["token"]
@crazyrohila
crazyrohila / rich_capitalize.py
Last active November 30, 2018 15:45
Rich Capitalize
def caps(text):
words = text.split()
capswords = []
for word in words:
if ('<b>' in word):
wd = word.split('<b>')
word = wd[0].capitalize()+'<b>'+wd[1].capitalize()
elif ('</b>' in word):
wd = word.split('</b>')
word = wd[0].capitalize()+'</b>'+wd[1].capitalize()
@crazyrohila
crazyrohila / main.py
Created November 26, 2018 11:03
Google-sheet-import
engine = create_engine('postgresql://username:password@host/dbname')
scope = ['https://spreadsheets.google.com/feeds']
creds = ServiceAccountCredentials.from_json_keyfile_name('credentials.json', scope)
client = gspread.authorize(creds)
workbook = client.open_by_url('google-sheet-url')
sheet = workbook.worksheet("Tab/sheet to import")
data = sheet.get_all_records(head=1, default_blank=None)
data = pd.DataFrame(data)
data.to_sql(name='table-name', con= engine, if_exists='replace')
@crazyrohila
crazyrohila / ssm_params_index.py
Last active January 12, 2018 15:44
Get SSM parameter from lambda
import boto3
def handler(event, context):
# TODO implement
client = boto3.client('ssm')
ssmKey = 'myparams'
ssmParam = client.get_parameters(Names=[ssmKey],WithDecryption=True)
print('param', ssmParam['Parameters'][0]['Value'])
return 'param -> ' + ssmParam['Parameters'][0]['Value']
@crazyrohila
crazyrohila / cli-in-mac.txt
Created December 15, 2017 08:02
aws cli in mac
#Install pip
`curl -O https://bootstrap.pypa.io/get-pip.py`
` python get-pip.py --user`
# Install cli
`pip install awscli --upgrade --user`
Read More: http://docs.aws.amazon.com/cli/latest/userguide/awscli-install-linux.html
# Add to path
Add following line to bash profile:
@crazyrohila
crazyrohila / docker.json
Created May 10, 2017 02:50 — forked from hitsujiwool/docker.json
docker + docker-compose on Amazon Linux
{
"variables": {
"aws_access_key": "{{env `AWS_ACCESS_KEY`}}",
"aws_secret_key": "{{env `AWS_SECRET_KEY`}}"
},
"builders": [
{
"type": "amazon-ebs",
"ssh_pty": true,
"access_key": "{{user `aws_access_key`}}",
@crazyrohila
crazyrohila / authsources.php
Created February 17, 2017 07:16
Settings SimpleSamlPHP with Drupal
<?php
$config = array(
// This is a authentication source which handles admin authentication.
'admin' => array(
'core:AdminPassword',
),
'drupal-userpass' => array(
'drupalauth:External',
// The filesystem path of the Drupal directory.
'drupalroot' => '/var/www/<Drupal-Root-Path>',
@crazyrohila
crazyrohila / apache.conf
Last active January 19, 2017 09:46
Forward 3000 to 80
<VirtualHost *:80>
ServerName mysite.com
DocumentRoot /var/www/html/mysite/
DirectoryIndex index.php index.html
ProxyPass / http://localhost:3000/
#ErrorLog ${APACHE_LOG_DIR}/error.log
ErrorLog ${APACHE_LOG_DIR}/hcah-error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>