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
from aocd import get_data
inp=get_data(day=1, year=2023)
lines=inp.splitlines()
def collectNumberWords(line):
numberPairs = { "one" : 1, "two" : 2, "three" : 3, "four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9 }
indexNumberList = []
for x in numbers:
if x in line:
lastIndex = line.rindex(x)
/*
You are given an m x n matrix of characters box representing a side-view of a box. Each cell of the box is one of the following:
A stone '#'
A stationary obstacle '*'
Empty '.'
The box is rotated 90 degrees clockwise, causing some of the stones to fall due to gravity. Each stone falls down until it lands on an obstacle, another stone, or the bottom of the box. Gravity does not affect the obstacles' positions, and the inertia from the box's rotation does not affect the stones' horizontal positions.
It is guaranteed that each stone in box rests on an obstacle, another stone, or the bottom of the box.
@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>", {