Skip to content

Instantly share code, notes, and snippets.

View hawkeye64's full-sized avatar

Jeff Galbraith hawkeye64

View GitHub Profile
@hawkeye64
hawkeye64 / useful_postgresql_commands.md
Created October 21, 2024 16:06 — forked from sreekanthsnair/useful_postgresql_commands.md
Most useful PostgreSQL queries for analytics

Tested in Postgres version 9.4

Check postgres connection usage

select max_conn,used,res_for_super,max_conn-used-res_for_super res_for_normal 
from 
  (select count(*) used from pg_stat_activity) t1,
  (select setting::int res_for_super from pg_settings where name=$$superuser_reserved_connections$$) t2,
  (select setting::int max_conn from pg_settings where name=$$max_connections$$) t3;
@hawkeye64
hawkeye64 / remove-disabled-snaps.sh
Created September 24, 2024 13:24
Remove disabled snaps from the local snap store
#!/usr/bin/env bash
snap list --all | awk '/disabled/{system("sudo snap remove " $1 " --revision=" $3)}'
@hawkeye64
hawkeye64 / inotify.md
Last active December 1, 2024 20:56 — forked from coenraadhuman/inotify.md
Increasing the amount of inotify watchers

Increasing the amount of inotify watchers

Take note this is my personal edited version and the command related to Arch has been changed to work on my Arch system.

Increase inotify watchers

This file has been truncated, but you can view the full file.
@hawkeye64
hawkeye64 / deepEqual.js
Created April 8, 2022 19:17
JavaScript to compare two things as equal (client-side)
'use strict'
export function deepEqual (object1, object2) {
// check for falsy values
if (!object1 && !object2) return true
if (!object1 && object2) return false
if (object1 && !object2) return false
const keys1 = Object.keys(object1)
const keys2 = Object.keys(object2)
@hawkeye64
hawkeye64 / deepClone.js
Created April 8, 2022 19:16
JavaScript to deep clone anything (client-side)
'use strict'
function deepClone (data, hash = new WeakMap()) {
if (Object(data) !== data) return data
if (hash.has(data)) return hash.get(data)
const result = data instanceof Date
? new Date(data)
: (data instanceof RegExp
? new RegExp(data.source, data.flags)
@hawkeye64
hawkeye64 / toSnakeCase.js
Created April 8, 2022 19:16
JavaScript to convert camelCase to snake_case (server-side)
'use strict'
// converts camelCase to snake_case
// used to convert to database
// myVar => my_var
function toSnakeCase (objectArrayOrString) {
return keysToSnake(objectArrayOrString)
}
const toSnake = (s) => {
@hawkeye64
hawkeye64 / toCamelCase.js
Created April 8, 2022 19:14
JavaScript to convert snake_case to camelCase (server-side)
'use strict'
// converts snake_case to camelCase
// used to convert from database
// my_var => myVar
function toCamelCase (objectArrayOrString) {
return keysToCamel(objectArrayOrString)
}
const toCamel = (s) => {
SlideTransition.vue
```js
<template>
<div ref="container" style="transition: height 0.4s; overflow: hidden;">
<div ref="content">
<slot></slot>
</div>
</div>
</template>
@hawkeye64
hawkeye64 / jsontoFormdata.js
Created January 14, 2021 14:40
json to formdata
function buildFormData (formData, data, parentKey) {
if (data && typeof data === 'object' && !(data instanceof Date) && !(data instanceof File)) {
Object.keys(data).forEach(key => {
buildFormData(formData, data[key], parentKey ? `${parentKey}[${key}]` : key)
})
}
else {
const value = data == null ? '' : data
formData.append(parentKey, value)