Skip to content

Instantly share code, notes, and snippets.

@Gogetter
Gogetter / Profile.js
Created August 8, 2020 12:50
profile js file for reactjs-soujourn blog post
import React from "react"
import Avatar from "../avatar/Avatar"
function Profile(props) {
return (
<div className="container">
<Avatar
avatarData = {{imageUrl: props.avatar_url,
imageAlt: props.login}}
@Gogetter
Gogetter / Search.js
Last active August 8, 2020 12:49
search js file for reactjs-soujourn blog post
import React, { Component } from "react"
import Profile from "../profile/Profile";
class Search extends Component {
constructor(props) {
super(props);
this.state = {
searchText: "",
isOrganizationSearchChecked: false,
@Gogetter
Gogetter / App.js
Created August 3, 2020 17:07
react component example
import React from "react"
class App extends React.Component {
render() {
return(
<div>
<img src="https://media.giphy.com/media/11vhCpFcD3um7m/giphy.gif" alt="code works gif"
onMouseOver={() => alert("A mouse over event")}/>
<br />
@Gogetter
Gogetter / jenkins-docker-compose.yml
Last active August 25, 2021 10:54
Jenkins container installation
version: "3.8"
services:
jenkins-docker:
image: docker:dind
restart: always
privileged: "true"
environment:
- DOCKER_TLS_CERTDIR=/certs
ports:
- "2376:2376"
@Test
void givenEmptyPerson_thenShouldHaveEmptyJson() throws JsonProcessingException {
String returnedJson = convertToJson(Person.builder().build()).orElse("{}");
assertThat(returnedJson).isNotEmpty();
Map<String, Object> personMap = of(returnedJson);
assertThat(personMap).isEmpty();
}
@Test
void givenPersonHasEmptyFirstName_thenJsonShouldNotHaveFirstNameProperty() throws JsonProcessingException {
Person personWithEmptyFirstname = Person.builder().firstName("").lastName("Last name").gender(FEMALE)
.address(Address.builder().addressLine1("Address Line 1").addressLine2("Address Line 2").postcode("The Post Code")
.build()).build();
Map<String, Object> personMap = of(convertToJson(personWithEmptyFirstname).orElse(""));
assertThat(personMap).doesNotContainKey("firstName");
}
@Data
@Builder(toBuilder = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Address {
private final String addressLine1;
private final String addressLine2;
private final String postcode;
}
@Gogetter
Gogetter / Person.java
Last active January 11, 2020 13:49
Person class for Jackson annotation blog posts
@Data
@Builder(toBuilder = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Person {
private final String firstName;
private final String lastName;
private final Gender gender;
private Address address;
}
static Future<Map<String, dynamic>> findVisitor(final String email) async {
Map<String, dynamic> visitorData;
if (email.isNotEmpty) {
// wait for result to be returned
await _firestore.collection(Constants.visitors)
.document(email)
.get().then((visitorSnapshot) {
visitorData = visitorSnapshot.data;
}).catchError((error) {
visitorData = new Map();
static void saveOrUpdateVisitor(final Visitor visitor, final bool signIn) async {
if (visitor != null) {
// _firestore is a private variable declared using -> static Firestore _firestore = Firestore.instance;
await _firestore.collection(Constants.visitors)/// create the collection where Visitors will be saved
.document(visitor.emailAddress)/// construct a path (more like reference)
.setData(Visitor.toMap(visitor, signIn));/// save data
}
}