Skip to content

Instantly share code, notes, and snippets.

View SethBuilder's full-sized avatar

Seif SethBuilder

View GitHub Profile
@SethBuilder
SethBuilder / index.js
Created December 27, 2019 14:36
This is a coding exercise: We'd like to contact partners with offices within 100km of central London to invite them out for a meal. Write a Node.js program that reads our list of partners from partners.json and outputs the company names and addresses of matching partners sorted by company name (ascending).
'use strict'
const { getPartnersWithinRange } = require("./util2");
const partnersJson = require("./partners.json");
const partners = JSON.parse(JSON.stringify(partnersJson));
console.log(getPartnersWithinRange(partners));
@SethBuilder
SethBuilder / main2.go
Last active November 24, 2022 06:38
This is a GoLang exercise: a. Create two go-routines, which are running a loop with 10 iterations. Find a way to make the execution slower. b. How do you get data from those routines in the “main thread” ? c. Receive 10 individual strings from each go-routine. d. Find a way to stop the running go-routines from the “main thread”
package main
import (
"fmt"
"sync"
"time"
)
var wg sync.WaitGroup
@SethBuilder
SethBuilder / main.go
Created December 27, 2019 13:54
This is a GoLang coding exercise: Build a middleware, which checks for the http header key “test” equals value “yes” and then log “header is fine” to console.
package main
import (
"fmt"
"github.com/gin-gonic/gin"
)
func middleware() gin.HandlerFunc {
return func(c *gin.Context) {
@SethBuilder
SethBuilder / story.blade.php
Created December 27, 2019 13:40
This Laravel Blade AMP page creates Instagram-like stories like this: https://envago.io/story/top-10-adventure-trips-in-oman
<!doctype html>
<html ⚡>
<head>
<meta charset="utf-8">
<title>{{$story->title}} | {{env('APP_NAME')}}</title>
<meta name="description" content="{{$story->title}}. Discover travel trends around the Middle East.">
<meta name="keywords" content="travel, adventures, Hiking, Abseiling, Caving, Air Balloon, Camping, Expeditions, Discover travel trends around the Middle East">
<meta name="author" content="Seif Elmughrabi">
<link rel="canonical" href="{{env('APP_URL')}}/story/{{$story->slug}}">
@SethBuilder
SethBuilder / AlertComponent.vue
Last active December 27, 2019 13:17
Vue.js code sample for a workflow management system.
<template>
<div>
<v-alert type="success" dismissible v-model="newUserSuccess">
Success
</v-alert>
<v-alert type="error" dismissible v-model="newUserFail">
Failed
</v-alert>
</div>
@SethBuilder
SethBuilder / LikeController.php
Created December 27, 2019 12:48
Code Sample from Envago.io
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Activity;
use App\Like;
use Auth;
use App\Http\Resources\Like as LikeResource;
@SethBuilder
SethBuilder / google-assistant-trip-finder.js
Last active November 24, 2020 09:48
Node webhook for the Google Assistant.
'use strict';
const {dialogflow, Image, Carousel, BasicCard, Button, LinkOutSuggestion} = require('actions-on-google');
const functions = require('firebase-functions');
// Different "Intents" or "purposes" to be fullfilled
const WELCOME_INTENT = 'Default Welcome Intent';
const TRIPS_INTENT = 'find_trips';
const TRIP_INTENT = 'trip_details';