Skip to content

Instantly share code, notes, and snippets.

View Takadimi's full-sized avatar

Ethan Woodward Takadimi

View GitHub Profile
Tue Nov 21 14:54:36 EST 2023 | panther:requests=0
Tue Nov 21 14:54:40 EST 2023 | panther:requests=490
Tue Nov 21 14:54:44 EST 2023 | panther:requests=490
Tue Nov 21 14:54:49 EST 2023 | panther:requests=480
Tue Nov 21 14:54:53 EST 2023 | panther:requests=480
Tue Nov 21 14:54:57 EST 2023 | panther:requests=472
Tue Nov 21 14:55:02 EST 2023 | panther:requests=470
Tue Nov 21 14:55:06 EST 2023 | panther:requests=466
Tue Nov 21 14:55:11 EST 2023 | panther:requests=462
Tue Nov 21 14:55:15 EST 2023 | panther:requests=458
@Takadimi
Takadimi / aws-ec2-instance-region.py
Last active October 10, 2023 16:34
EC2 instance metadata - Get running region
import requests
def get_instance_token():
try:
response = requests.put('http://169.254.169.254/latest/api/token', headers={
'X-aws-ec2-metadata-token-ttl-seconds': '21600'}, timeout=0.1)
return response.text.strip()
except Exception as e:
print(f"Error: {e}")
### Keybase proof
I hereby claim:
* I am takadimi on github.
* I am ewoodward (https://keybase.io/ewoodward) on keybase.
* I have a public key ASANumesgQNbUeWLsxpVas0qSzI5t_QN_728G_uGr-AM0Ao
To claim this, I am signing this object:
- Actually learn bash scripting
- Learn the basics of awk & sed
- Create basic app in swift 3
@Takadimi
Takadimi / Preferences.sublime-settings
Created October 11, 2016 20:12
Sublime User Preferences (10/11/2016)
{
"atomic_save": false,
"detect_indentation": true,
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"tab_size": 4,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
@Takadimi
Takadimi / strategy_pattern.php
Created October 6, 2016 14:36
Example of Strategy pattern
<?php
/*
NOTES:
As always, coding to an interface is king.
Using the strategy pattern you can have a class inject different algorithms for use in their own methods.
Representing each algorithm as a class that implements the same interface allows for easily swappable functionality!
@Takadimi
Takadimi / specification_pattern.php
Last active October 6, 2016 13:58
Example of Specification Pattern
<?php
interface CustomerSpecification {
public function isSatisfiedBy(Customer $customer);
}
class CustomerIsGold implements CustomerSpecification {
public function isSatisfiedBy(Customer $customer) {
return $customer->plan == 'gold';
}
@Takadimi
Takadimi / decorator_pattern.php
Last active October 6, 2016 13:59
Example of Decorator Pattern
<?php
/*
NOTES:
Useful for extending/decorating the behavior of an object.
Instead of having to compose a matrix of class combinations for
your different needs, you define an interface that allows each
component to extend the base behavior. This means you can mix and
match the different behaviors freely.
@Takadimi
Takadimi / adapter_pattern.php
Last active October 6, 2016 13:59
Example of Adapter Pattern
<?php
/*
NOTES:
This pattern is useful for translating from one interface to another.
In the example below, we see that a 'Person' is 'read'ing a book. Consider that
the 'BookInterface' may be out of your reach and is already set in stone, what happens
if you already have an 'eReaderInterface'? The methods on the 'BookInterface' are equivalent,
require "octokit"
file_name = ARGV[0]
description = ARGV[1]
if description.nil? then
description = ''
end
if !ARGV.empty? then