Skip to content

Instantly share code, notes, and snippets.

View herbievine's full-sized avatar
🌴
on holiday - always

Herbie Vine herbievine

🌴
on holiday - always
View GitHub Profile
#!/bin/bash
arc=$(uname -a)
pcpu=$(grep "physical id" /proc/cpuinfo | sort | uniq | wc -l)
vcpu=$(grep "^processor" /proc/cpuinfo | wc -l)
fram=$(free -m | awk '$1 == "Mem:" {print $2}')
uram=$(free -m | awk '$1 == "Mem:" {print $3}')
pram=$(free | awk '$1 == "Mem:" {printf("%.2f"), $3/$2*100}')
fdisk=$(df -Bg | grep '^/dev/' | grep -v '/boot$' | awk '{ft += $2} END {print ft}')
udisk=$(df -Bm | grep '^/dev/' | grep -v '/boot$' | awk '{ut += $3} END {print ut}')
pdisk=$(df -Bm | grep '^/dev/' | grep -v '/boot$' | awk '{ut += $3} {ft+= $2} END {printf("%d"), ut/ft*100}')
#!/bin/bash
wall $'#Architecture: ' `hostnamectl | grep "Operating System" | cut -d ' ' -f5- ` `awk -F':' '/^model name/ {print $2}' /proc/cpuinfo | uniq | sed -e 's/^[ \t]*//'` `arch` \
'\n#CPU physical: '`cat /proc/cpuinfo | grep processor | wc -l` \
'\n#vCPU: '`cat /proc/cpuinfo | grep processor | wc -l` \
'\n'`free -m | awk 'NR==2{printf "#Memory Usage: %s/%sMB (%.2f%%)", $3,$2,$3*100/$2 }'` \
'\n'`df -h | awk '$NF=="/"{printf "#Disk Usage: %d/%dGB (%s)", $3,$2,$5}'` \
'\n'`top -bn1 | grep load | awk '{printf "#CPU Load: %.2f\n", $(NF-2)}'` \
'\n#Last boot: ' `who -b | awk '{print $3" "$4" "$5}'` \
'\n#LVM use: ' `lsblk |grep lvm | awk '{if ($1) {print "yes";exit;} else {print "no"} }'` \
'\n#Connection TCP:' `netstat -an | grep ESTABLISHED | wc -l` \
@herbievine
herbievine / useTheme.ts
Created November 1, 2021 17:33
React Native custom theme selector - ./src/hooks/useTheme.ts
import { Dispatch, SetStateAction, useContext } from 'react'
import { ThemeContext } from '../context/Theme'
import {
DARK_THEME_BACKGROUND,
DARK_THEME_SECONDARY,
DARK_THEME_SECONDARY_VARIANT,
DARK_THEME_TEXT,
DARK_THEME_VARIANT,
DARK_THEME_BACKGROUND_VARIANT,
@herbievine
herbievine / Theme.tsx
Created November 1, 2021 17:28
React Native custom theme selector - ./src/context/Theme.tsx
import React, { Dispatch, SetStateAction, useEffect, useState } from 'react'
import { useColorScheme } from 'react-native'
import { getItem, setItem } from '../lib/storage'
export type ThemeOptions = 'light' | 'dark'
export interface ThemeContextInterface {
theme: ThemeOptions
setTheme: Dispatch<SetStateAction<ThemeOptions>>
}
@herbievine
herbievine / storage.ts
Created November 1, 2021 17:23
React Native custom theme selector - ./src/lib/storage.ts
import AsyncStorage from '@react-native-async-storage/async-storage'
import { Platform } from 'react-native'
const os = Platform.OS
const webStorage = window.localStorage
const appStorage = AsyncStorage
const getItem = async (key: string) => {
if (key) {
return os === 'web'
@herbievine
herbievine / constants.ts
Created October 31, 2021 20:05
React Native custom theme selector - ./src/lib/constants.ts
const BRAND_COLOR = '#57C69E' as const
const LIGHT_THEME_BACKGROUND = '#EEEEEE' as const
const LIGHT_THEME_TEXT = '#111111' as const
const LIGHT_THEME_VARIANT = '#333333' as const
const LIGHT_THEME_SECONDARY = '#777777' as const
const LIGHT_THEME_SECONDARY_VARIANT = '#BBBBBB' as const
const LIGHT_THEME_BACKGROUND_VARIANT = '#CCCCCC' as const
const DARK_THEME_BACKGROUND = '#111111' as const
create type public.user_status as enum ('ONLINE', 'OFFLINE');
create type public.message_type as enum ('TEXT', 'IMAGE', 'VIDEO');
create table channels (
id uuid default uuid_generate_v4() primary key
);
create table messages (
id uuid default uuid_generate_v4() primary key,
content text not null,
import { useRouter } from 'next/router'
import React, { useEffect } from 'react'
import ReactMarkdown from 'react-markdown'
import PostNotFound from '../../components/errors/PostNotFound'
import DefaultWrapper from '../../components/layout/DefaultWrapper'
import Navigation from '../../components/modules/Navigation'
import {
useFindOneBySlugQuery,
useIncrementViewMutation,
} from '../../generated/graphql'
@herbievine
herbievine / main.dart
Created April 3, 2021 13:05
dart pad for so
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@herbievine
herbievine / FormGenerator.vue
Created August 1, 2020 19:46
Creates a form that delivers inputs and emits a map on submit. Needs a title as a string and an array of objects for the inputs. Uses Vue 3 and TypeScrtipt.
<template>
<div>
<form @submit.prevent="submit">
<div v-for="(input, i) in inputs" :key="i">
<label :for="input.name">{{ input.placeholder }}</label>
<input
:id="input.name"
:ref="input.name"
:type="input.type"
:placeholder="input.placeholder"