Skip to content

Instantly share code, notes, and snippets.

Avatar

umihico

View GitHub Profile
@umihico
umihico / aws-funcs.sh
Last active Jun 25, 2022
Sign in AWS console by CLI credentials
View aws-funcs.sh
# https://gist.github.com/umihico/3a19974ccb251a01dc870fe39b09749f
function aws-sub() {
aws-main --incognito
}
function aws-main() {
if [ "$1" = "--incognito" ]; then # Sign-out current user
open -na 'Google Chrome' --args --incognito "https://signin.aws.amazon.com/oauth?Action=logout&redirect_uri=https://aws.amazon.com" # Mac, OSX
else
@umihico
umihico / .ssh-config
Last active Dec 14, 2021
my lima cofig
View .ssh-config
Host limadocker
HostName localhost
Port 60006
User lima
NoHostAuthenticationForLocalhost yes
@umihico
umihico / Dockerfile
Created Apr 15, 2021
Install amazon-linux-extras on public.ecr.aws/lambda/python:3.8
View Dockerfile
FROM public.ecr.aws/lambda/python:3.8
RUN yum install -y amazon-linux-extras
RUN cp -r /lib/python2.7/site-packages/amazon_linux_extras /var/lang/lib/python3.8/site-packages/
# TEST COMMAND -> RUN amazon-linux-extras install -y mate-desktop1.x
@umihico
umihico / demo.sh
Last active Aug 5, 2020
Generate secret keys whose public keys which contain specific string such as your name
View demo.sh
cd $(mktemp -d); while true; do seq 1000 | xargs -P 1000 -I NUM sh -c 'ssh-keygen -t ed25519 -f NUM.pem -N "" -C "" > /dev/null && if grep -vi umihico NUM.pem.pub > /dev/null; then rm NUM.pem NUM.pem.pub;fi' ; if find . -mindepth 1 | read; then for f in *.pem.pub; do echo $f >> files.txt; done; test -f files.txt && head -n1 files.txt | xargs -I F curl -s -X POST -d '{"text":"F"}' https://hooks.slack.com/services/XXXXXXXXX/YYYYYYYYYYY/zzzZZZzZzzZzzZZzz; break; fi ; date ; done
@umihico
umihico / download-slack-profile-pictures.py
Created Jul 18, 2020
Download all user's profile pictures in your Slack workspace
View download-slack-profile-pictures.py
import requests
import time
TOKEN = "xoxb-12345678-12345679-thairoo1airi6om7Ahga"
def main():
url = "https://slack.com/api/users.list?token=" + TOKEN
response = requests.get(url)
response.raise_for_status()
@umihico
umihico / lambda_function.py
Last active Jan 3, 2020
create selenium layer including binary WORKS python 3.7. NOT 3.8
View lambda_function.py
import json
from selenium import webdriver
def lambda_handler(event, context):
chrome=Chrome()
chrome.get('https://www.google.com/')
print(chrome.title)
chrome.quit()
return {
'statusCode': 200,
@umihico
umihico / README.md
Created Jan 2, 2020
get all slack ids in your slack workspace
View README.md

python list_all_slack_id.py xoxp-000000000000-abcdef

output will be like

https://slack.com/api/channels.list?token=xoxp-000000000000-abcdef
https://slack.com/api/usergroups.list?token=xoxp-000000000000-abcdef
https://slack.com/api/users.list?token=xoxp-000000000000-abcdef
{'CB0000000': 'general',
 'CB0000000': 'random',
 'UB0000000': 'umihico',
@umihico
umihico / lambda_function.py
Created Dec 12, 2019
Publish any AWS quicksight dashboards to public with lambda and API gateway
View lambda_function.py
import json
import boto3
"""
API gateway URL example. You have to allow your quicksight domin setting to be accessed from amazonaws.com including subdomains.
https://xxxxxxxx.execute-api.ap-northeast-1.amazonaws.com/xxx-gateway-stage-xxxx/your-lambda-func-name?dashboard_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxx
"""
def lambda_handler(event, context):
dashboard_id=event["queryStringParameters"]['dashboard_id']