Skip to content

Instantly share code, notes, and snippets.

Avatar

umihico

View GitHub Profile
@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']
@umihico
umihico / result.json
Created Oct 6, 2019
Scrap all city names from wikipedia
View result.json
{"A Coru\u00f1a": "Spain", "Aachen": "Germany", "Aalborg": "Denmark", "Aarhus": "Denmark", "Aba, Nigeria": "Nigeria", "Abadan, Iran": "Iran", "Abaetetuba": "Brazil", "Abakan": "Russia", "Abbotabad": "Pakistan", "Abbotsford, British Columbia": "Canada", "Abengourou": "Ivory Coast", "Abeokuta": "Nigeria", "Aberdeen": "United Kingdom", "Abha": "Saudi Arabia", "Abidjan": "Ivory Coast", "Abiko, Chiba": "Japan", "Abilene, Texas": "United States", "Abohar": "India", "Abu Al-Khaseeb": "Iraq", "Abu Dhabi": "United Arab Emirates", "Abu Ghraib": "Iraq", "Abuja": "Nigeria", "A\u00e7ail\u00e2ndia": "Brazil", "Acapulco": "Mexico", "Acarigua": "Venezuela", "Accra": "Ghana", "Achalpur": "India", "Acheng District": "China", "Achinsk": "Russia", "Adama": "Ethiopia", "Adana": "Turkey", "Adapazar\u0131": "Turkey", "Addis Ababa": "Ethiopia", "Adelaide": "Australia", "Aden": "Yemen", "Adhamiyah": "Iraq", "Adilabad": "India", "Adityapur": "India", "Ad\u0131yaman": "Turkey", "Ado-Ekiti": "Nigeria", "Adoni": "India", "Afyon": "Turkey
@umihico
umihico / lambda_function.py
Created Sep 3, 2019
AWS Lambda function to return image
View lambda_function.py
import requests
import base64
def lambda_handler(event, content):
response = requests.get("https://github.com/umihico.png")
return {
"isBase64Encoded": True,
"statusCode": 200,
"headers": { "content-type": "image/jpg"},
"body": base64.b64encode(response.content).decode("utf-8")
}
@umihico
umihico / README.md
Last active Sep 3, 2019
Download Python Pillow package for AWS lambda
View README.md
  1. run docker-compose up.
  2. confirm you get PIL and Pillow-6.1.0.dist-info directory next .yml file.
  3. upload them as AWS Lambda Layer
You can’t perform that action at this time.