Skip to content

Instantly share code, notes, and snippets.

View CodebyOmar's full-sized avatar

Umar Abdullahi CodebyOmar

View GitHub Profile
@CodebyOmar
CodebyOmar / icon-with-badge-tailwind.html
Last active July 10, 2023 06:53
Place a badge that show notification numbers or number of items in a cart at top right of an icon with tailwindcss
<button class="py-4 px-1 relative border-2 border-transparent text-gray-800 rounded-full hover:text-gray-400 focus:outline-none focus:text-gray-500 transition duration-150 ease-in-out" aria-label="Cart">
<svg class="h-6 w-6" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" stroke="currentColor">
<path d="M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z"></path>
</svg>
<span class="absolute inset-0 object-right-top -mr-6">
<div class="inline-flex items-center px-1.5 py-0.5 border-2 border-white rounded-full text-xs font-semibold leading-4 bg-red-500 text-white">
6
</div>
</span>
</button>
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
// all the peeps in a map ensures no duplicates
@CodebyOmar
CodebyOmar / init-func.md
Last active February 20, 2019 16:03
Moving database connection to an init function
// some other code here

func init() {
	once.Do(func() {
		args := []string{
			"host=" + os.Getenv("DB_HOST"),
			"port=" + os.Getenv("DB_PORT"),
			"user=" + os.Getenv("DB_USER"),
 "dbname=" + os.Getenv("DB_NAME"),
mutation {
  insert_users(objects: { username: "codebyomar" }) {
    returning {
      id
      username
      last_seen
      last_typed
    }
 }
@CodebyOmar
CodebyOmar / event_triggers.json
Created February 20, 2019 09:36
Setting up Hasura Event Triggers via API
{
"type": "bulk",
"args": [
{
"args": {
"headers": [],
"insert": {
"columns": [
"id",
"username",
@CodebyOmar
CodebyOmar / types.go
Created February 18, 2019 14:16
Types used in the notifications package
package notifications
// Result type
type Result struct {
PushToken string
RoomID string
UserID string
Username string
}
@CodebyOmar
CodebyOmar / fn.go
Last active February 18, 2019 14:58
package notifications
import (
"fmt"
"io/ioutil"
"net/http"
"os"
s "strings"
"github.com/Jeffail/gabs"
package rooms
// Room is a model representation of our room table
type Room struct {
ID float64
Name string
RoomType string
}
// UserRoom is a model representation of our user_rooms table
DB_HOST=
DB_PORT=
DB_USER=
DB_NAME=
DB_PASSWORD=
@CodebyOmar
CodebyOmar / fn.go
Last active February 18, 2019 14:18
Entry function for the addToRooms cloud function
package rooms
import (
"fmt"
"io/ioutil"
"net/http"
"os"
s "strings"
"github.com/Jeffail/gabs"