Skip to content

Instantly share code, notes, and snippets.

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

Alper asunar

🏠
Working from home
View GitHub Profile
@asunar
asunar / index.js
Created October 13, 2022 17:01
architect project Index.js file that redirects to google login if user is not logged in. (Using Auth0 with google sign in)
const layout = require('@architect/shared/layout')
const arc = require('@architect/functions')
exports.handler = arc.http.async(handler)
// @ts-ignore
async function handler(req) {
const isLoggedIn = !!req.session.email
if(isLoggedIn) {
{
"New tape test": {
"scope": "javascript,typescript",
"prefix": "tttest",
"body": [
"test('$1', (t) => {",
"\t$0",
"\tt.end()",
"})"
]
{
"include": [
"src/**/*.js",
"test/**/*.js"
],
"compilerOptions": {
/* Basic Options */
"target": "ES2017",
"lib": ["ESNext.Array"],
"module": "commonjs",
// Copy and paste it into Chrome devtools console to run it
let cliParser = (args) => {
let keyValueList = []
let keyBucket = []
let valueBucket = []
let isKey = false
let isInsideQuote = false
args += '-' //to add last key value pair
args.split('').forEach(x =>{
// console.log('Processing', x)
@asunar
asunar / update_cloud9.sh
Last active October 14, 2021 11:33
script to update awscli, sam and node in cloud9
sudo yum update -y && \
sudo yum remove awscli -y && \
sudo rm /usr/local/bin/sam && \
sudo rm -rf /usr/local/aws-sam-cli
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
sudo ./aws/install && \
wget https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip && \
unzip aws-sam-cli-linux-x86_64.zip -d sam-installation && \
sudo ./sam-installation/install && \
@asunar
asunar / template.yaml
Created April 16, 2021 17:49
SAM Policy Template StepFunctionsExecutionPolicy generated role looks incorrect
This template.yaml file
# snip
- StepFunctionsExecutionPolicy: # Manually change to StartSyncExection after deployment
StateMachineName:
!Ref ProcessImageStateMachineExpressSync
# snip
generates this role
openapi: "3.0.1"
info:
title: "Api for processImage step func"
version: "2020-11-06 15:32:29UTC"
paths:
/:
post:
responses:
default:
description: "Default response for POST /"
<html>
<body>
<button type="submit" onclick="submit();">Submit</button>
</body>
<script>
function submit(){
fetch("<api_url>", {
@asunar
asunar / sample.yaml
Last active January 16, 2021 15:26
CORS Configuration for a simple image processor
# Simple SAM template with CORS configuration for an image processor lambda
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
test
Sample SAM Template for test
Globals:
Function:
@asunar
asunar / index.html
Last active November 16, 2018 17:27
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<body>
<p>Web Components Demo
<div>
<button is="hey-there-button" name="World">Howdy</button>
</div>