Skip to content

Instantly share code, notes, and snippets.

View gate3's full-sized avatar

Doyin Olarewaju gate3

View GitHub Profile
@gate3
gate3 / example.go
Created August 5, 2022 15:03 — forked from yanmhlv/example.go
JSONB in gorm
package main
import (
"database/sql/driver"
"encoding/json"
"github.com/jinzhu/gorm"
_ "github.com/lib/pq"
)
@gate3
gate3 / web3-main.min.js
Created July 28, 2022 05:15
Weedle No Code Testing CDN file
function t(){return document.querySelector("script[data-weedle-id]").getAttribute("data-weedle-id")}function e(){var e=new XMLHttpRequest;e.open("GET","https://swapi.dev/api/people/1"),e.send(),e.onreadystatechange=function(){4===this.readyState&&200===this.status&&console.log(JSON.parse(e.responseText))}}function n(t){var e=document.createElement("script");e.src="https://cdn.jsdelivr.net/npm/@metamask/onboarding@1.0.1/dist/metamask-onboarding.bundle.js",e.async=!0,document.body.appendChild(e),e.addEventListener("load",function(){console.log("metamask script added",t);var e=new MetaMaskOnboarding;t.disabled=!0,e.startOnboarding()}),e.onerror=function(e){console.log(e),alert("Could not setup metamask, please refresh the page!")}}function o(e){void 0!==window.ethereum?ethereum.isMetaMask&&(ethereum.request({method:"eth_requestAccounts"}).then(function(e){console.log({accounts:e}),document.getElementById("-wdl-crypto-account").textContent+=e[0]}).catch(function(e){console.log(e)}),ethereum.on("accountsChanged",e
@gate3
gate3 / TetherToken.sol
Created December 6, 2021 13:33 — forked from plutoegg/TetherToken.sol
TetherToken.sol - Tether.to USD
pragma solidity ^0.4.11;
/**
* Math operations with safety checks
*/
library SafeMath {
function mul(uint a, uint b) internal returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
@gate3
gate3 / redis_cheatsheet.bash
Created October 16, 2021 15:04 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@gate3
gate3 / build.sh
Created December 9, 2019 22:57 — forked from bobbytables/build.sh
Protocol Buffer build script for multiple folders
#!/usr/bin/env bash
# This script is meant to build and compile every protocolbuffer for each
# service declared in this repository (as defined by sub-directories).
# It compiles using docker containers based on Namely's protoc image
# seen here: https://github.com/namely/docker-protoc
set -e
REPOPATH=${REPOPATH-/opt/protolangs}
CURRENT_BRANCH=${CIRCLE_BRANCH-"branch-not-available"}
@gate3
gate3 / base.worker.js
Last active September 13, 2019 16:01
require('dotenv').config()
const redis = require('redis')
const QueueHelper = require('../../util/rabbitmq.helper');
const modelContainer = require('../models')
const pub = redis.createClient(); // creating for localhost
class BaseWorker {
constructor (type, model) {
this.type = type
this.QueueName = `${type}:queue`
@gate3
gate3 / rabbitMqHelper.js
Last active September 13, 2019 15:55
Sending Realtime Events To The Client From Node child process
const rabbitMq = require('amqplib');
class RabbitMqHelper {
constructor (channel_name) {
this.channel = null;
this.connection = null;
this.queueAssert = null;
this.channel_name = channel_name
}
@gate3
gate3 / main.js
Created September 13, 2019 15:55
// Note i skipped a lot of steps here like starting a server etc
require('dotenv').config()
const redis = require('redis')
const sub = redis.createClient();
const cp = require('child_process');
const glob = require('glob');
glob('!(node_modules)/**/*.worker.js', function (er, files) { // Ignore all workers in node_modules and use only those defined within my app
for (let f of files) {
const BaseQueue = require('./base_worker')
const userModel = require('../models/userModel')
class UserWorker extends BaseQueue {
constructor () {
super('users', userModel)
}
runQueue () {
super.runQueue()
@gate3
gate3 / nodegit-private-clone-test.js
Created July 15, 2019 13:47 — forked from mojavelinux/nodegit-private-clone-test.js
Clone a private repository using nodegit
const git = require('nodegit')
const fs = require('fs-extra')
const { URL } = require('url')
const REPO_URL = 'git@github.com:org/path.git'
const CLONE_DIR = '/tmp/private-repo-clone-test'
;(async () => {
await fs.emptyDir(CLONE_DIR)
let authAttempted = false
await git.Clone.clone(REPO_URL, CLONE_DIR, {