Skip to content

Instantly share code, notes, and snippets.

def dfs(adj_list, start, target, path, visited=set()):
path.append(start)
visited.add(start)
if start == target:
return path
for neighbour in adj_list[start]:
if neighbour not in visited:
result = dfs(adj_list, neighbour, target, path, visited)
if result is not None:
@press0
press0 / cfeventbridge4glue
Last active June 21, 2021 02:56
AWS CW Rule to detect Glue Job failure
#ref https://gnomezgrave.com/2020/01/26/get-notified-on-aws-glue-job-failures/
Resources:
MyGlueJobFailEvent:
Type: AWS::Events::Rule
Properties:
Description: This rule is to detect if the Glue Jobs fails
EventPattern:
source:
import awswrangler as wr
import pandas as pd
df = pd.DataFrame({"id": [1, 2], "value": ["foo1", "boo1"]})
print(df)
bucketPath = 's3://press0-test/awswrangler/'
database="awswrangler"
table="awswrangler_table1"
# Storing data on Data Lake
@press0
press0 / SettingsTests.py
Created April 23, 2021 00:47
@mock.patch.dict
class SettingsTests(TestCase):
@mock.patch.dict(os.environ, {"FROBNICATION_COLOUR": "ROUGE"})
def test_frobnication_colour(self):
colour = os.environ["FROBNICATION_COLOUR"]
self.assertEqual(colour, "ROUGE")
@press0
press0 / gist:2a6529d7fe376d285b1c5ed976000d37
Last active June 21, 2021 03:01
git log --oneline --decorate --all --graph
git log --oneline --decorate --all --graph
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks Menu</H1>
<DL><p>
<DL><p>
@press0
press0 / ConvertMoneyToEnglish.java
Last active February 19, 2021 15:44
ConvertMoneyToEnglish
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
public class ConvertMoneyToEnglish {
public static String convertMoneyToEnglish(int i) {
@press0
press0 / TradeExecutorJUnit5Test
Created February 10, 2021 19:10
TradeExecutorJUnit5Test
package trp2.redonejunit5;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
class TradeExecutorJUnit5Test {
@press0
press0 / TradeExecutorJUnit4Test
Last active February 15, 2021 14:32
TradeExecutorJUnit4Test
package trp2.redonejunit4;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Test;
public class TradeExecutorJUnit4Test {
@press0
press0 / 312.java
Last active October 2, 2020 16:41
functional array update 'in place'; in 2 passes; order by 3,1,2; no other values
import static java.util.stream.Collectors.counting;
import static org.junit.Assert.assertArrayEquals;
import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;