This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2022 Ali Sherief | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2022 Ali Sherief | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2022 Ali Sherief | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Credits: https://medium.com/@ujjawalsinhacool16021998/easily-convert-recursive-solutions-to-non-recursive-alternatives-4fa6e1acf702 | |
# Simple function, two branches which does not return a value | |
def simple2_noreturn(inputs): | |
CALL, HANDLE = 0, 1 | |
call_stack = [(CALL, inputs)] | |
while call_stack: | |
action, data = call_stack.pop() | |
if action == CALL: | |
call_stack.append((HANDLE, some_data)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
module.exports = { | |
mode: 'development', | |
entry: { | |
index: './src/index.js', | |
another: './src/another-module.js', | |
index: { | |
import: './src/index.js', | |
dependOn: 'shared', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Person = props => { | |
const { person } = props; | |
// You can validate `person` object here, for example | |
const { name, age, skill } = person; | |
return ( | |
<div> | |
<h2> | |
I am {name},My age is {age},I know {skill} | |
</h2> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in $(ls ~/environment/tools) | |
do | |
# Assume Lambda function is named like this: "tools-<foldername>" | |
AWS_PAGER="" aws lambda update-function-code --function-name "tools-${i}" --zip-file "fileb://~/environment/tools/${i}/lambda-func.zip" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd tools | |
# Assume that all lambda functions are located in tools/ subfolder | |
for i in $(ls ~/environment/tools); do cd $i; lzip-python; cd ..; done | |
cd .. | |
# lzip-python is an alias for this command: | |
alias lzip-python="~/environment/lzip-python.sh" | |
# This should be placed at the end of your .bashrc. | |
# It itself is another script, to be named lzip-python.sh, that contains the following: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* In this function, replace *Context* with the class you want to add state for. | |
* Of course, there will be only one State abstract class per Context class, | |
* but a variable number of conrete State classes. | |
*/ | |
class State { | |
public: | |
State() {} | |