Skip to content

Instantly share code, notes, and snippets.

View aphilas's full-sized avatar

Neville aphilas

View GitHub Profile
<?php
// Reads the variables sent via POST from our gateway
$sessionId = $_POST["sessionId"];
$serviceCode = $_POST["serviceCode"];
$phoneNumber = $_POST["phoneNumber"];
$text = $_POST["text"];
if ( $text == "" ) {
@aphilas
aphilas / .bash_prompt.sh
Last active July 14, 2021 12:26
Custom bash prompt to show chroot, venv, basename of current dir and git branch: (chroot)(venv)curr_dir(git_branch)$
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch of the current git repository
#
# USAGE:
#
@aphilas
aphilas / pips.sh
Last active June 10, 2022 12:36
Pip install and save to requirements.txt
# Pip install and add to requirements.txt and sort requirements.txt
# Flags: -d Use -d at the beginning! to add dev-requirements.txt instead
# TODO: Use extras from pip show, see https://github.com/pypa/pip/issues/4824
# Uses perl with \Q to perform a literal substitution
function pips ()
{
local REQS_PATH='requirements.txt'
local OPTIND=1 # Reset index
@aphilas
aphilas / custom-event-timeout.js
Last active June 10, 2022 12:33
Create and send a custom event "GET_DATA." Wait for data from another event "RETURN_DATA" with a timeout. Useful for two-way communication between a content script and an injected script.
const delay = (duration=200) => new Promise((resolve) => {
setTimeout(() => resolve, duration)
})
const getData = (timeout) => {
window.dispatchEvent(new CustomEvent("GET_DATA"))
let listener
const cleanup = () => {
@aphilas
aphilas / mpesa-schema.py
Created June 10, 2022 12:59
Pydantic models/schema for Daraja M-Pesa Express API.
# Python 3.9.6+
from typing import Literal, Optional, Union
import humps
from pydantic import BaseModel, Field, validator
from typing_extensions import Annotated
### Queue charge ###

Error mounting file with remote docker context

I am getting the error error mounting "/root/public/litesiem/core/elasticsearch/config/elasticsearch.yml" to rootfs at "/usr/share/elasticsearch/config/elasticsearch.yml" while trying to bring up a compose service on a remote host.

$ docker --version

Docker version 20.10.17, build 100c701

$ docker-compose --version

@aphilas
aphilas / zustand-immer-persist.ts
Created October 13, 2022 19:00
Zustand with immer and persist
import create, { StateCreator } from "zustand"
import { persist } from "zustand/middleware"
import { immer } from "zustand/middleware/immer"
// Custom persist storage
import { zustandStorage } from "@app/services/zustand"
export interface Entry {
sourceId: string
quantity: number
unitPrice: number
*://*.run-questions.com/*
*://*.stackify.dev/*
*://*.giters.com/*
*://*.opensourcelibs.com/*
*://*.techinplanet.com/*
*://*.codesource.io/*
*://*.itectec.com/*
*://*.stackguides.com/*
*://*.developpaper.com/*
*://*.w3schools.com/*
@aphilas
aphilas / description.txt
Last active March 6, 2023 20:03
Firefox numbered tabs
Source - https://github.com/tuomassalo/tab-numbering/blob/master/README.md
Add to /home/<user>/.mozilla/firefox/<profile>/chrome/userChrome.css
Enable toolkit.legacyUserProfileCustomizations.stylesheets in about:config
@aphilas
aphilas / inference_for_yolov5.ipynb
Created March 8, 2023 11:08
Hide labels/confidence with SAHI
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.