Skip to content

Instantly share code, notes, and snippets.

@Macarthurval
Macarthurval / mongo-auth.ts
Last active May 8, 2024 22:02
A typescript class to manage Baileys auth states in Mongo database
import { WAProto } from '@adiwajshing/baileys';
import { BufferJSON, initAuthCreds } from '@adiwajshing/baileys/lib/Utils';
import { Collection, Document, MongoClient } from 'mongodb';
import chalk from 'chalk';
export class MongoDbAuth{
static mongoUrl = "mongodb+srv://your-mongodb-url/DBName/?retryWrites=true&w=majority"
sim: string
private collection: Collection
@benley
benley / shittylife.hs
Last active May 8, 2024 21:58
conway's game of 💩
-- conway's game of 💩
-- shittily written by benley
module Main where
import Control.Concurrent
import Data.Array.Unboxed
import System.Environment
data Cell = Live | Dead deriving Eq
@realvjy
realvjy / ChoasLinesShader.metal
Last active May 8, 2024 21:57
Choas Lines - Metal Shader
// Lines
float hash( float n ) {
return fract(sin(n)*753.5453123);
}
// Slight modification of iq's noise function.
float noise(vector_float2 x )
{
vector_float2 p = floor(x);
vector_float2 f = fract(x);
@jenskutilek
jenskutilek / avar-slant.py
Last active May 8, 2024 21:53
Axis variation mapping generator for the slant axis
#!/usr/bin/env python
# coding: utf-8
from __future__ import division, print_function
from math import atan, pi, tan
# Spit out some mappings for the slant axis to get closer to actual degrees.
#print(angle,
# atan(
# tan(slant * pi / 180) / (slant / angle)
@sma
sma / sqlite_kv.dart
Created January 26, 2024 13:19
A simple key-value store w/persistent sqlite3 database.
/// A simple key-value store w/persistent sqlite3 database.
class KV {
KV._(this._db);
final Database _db;
static Future<KV> open(String name) async {
return KV._(sqlite3.open(name)..execute('create table if not exists kv (k text primary key, v jsonb)'));
}
Future<Object?> get(String key) async {
@chrismccord
chrismccord / dev.exs
Created May 8, 2024 20:06
Live Reload LiveView notify
config :wps, WPSWeb.Endpoint,
live_reload: [
notify: [
live_view: [
~r"lib/wps_web/core_components.ex$",
~r"lib/wps_web/(live|components)/.*(ex|heex)$"
]
],
patterns: [
~r"priv/static/(?!uploads/).*(js|css|png|jpeg|jpg|gif|svg)$",
@alejzeis
alejzeis / timezone-mappings.csv
Created March 15, 2017 00:12
Linux-Windows Timezone Mappings CSV
AUS Central Standard Time 001 Australia/Darwin
AUS Central Standard Time AU Australia/Darwin
AUS Eastern Standard Time 001 Australia/Sydney
AUS Eastern Standard Time AU Australia/Sydney Australia/Melbourne
Afghanistan Standard Time 001 Asia/Kabul
Afghanistan Standard Time AF Asia/Kabul
Alaskan Standard Time 001 America/Anchorage
Alaskan Standard Time US America/Anchorage America/Juneau America/Metlakatla America/Nome America/Sitka America/Yakutat
Aleutian Standard Time 001 America/Adak
Aleutian Standard Time US America/Adak
@oodavid
oodavid / README.md
Created March 26, 2012 17:05
Backup MySQL to Amazon S3

Backup MySQL to Amazon S3

This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)

Sister Document - Restore MySQL from Amazon S3 - read that next

1 - Install s3cmd

this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc

@timc1
timc1 / use-dropzone.tsx
Last active May 8, 2024 21:46
A React hook that returns whether a file is being dragged into the document from the operating system and not from within the browser.
import React from 'react'
type DropzoneContextValue = {
isDragging: boolean
}
const DropzoneContext = React.createContext<DropzoneContextValue | undefined>(
undefined
)

This emulate's vim's <C-e> and <C-y> for scrolling in VSCode using the macros extension.

scrolling vscode editor

  1. add the following to settings.json
"macros": {
  "scrollLineDownFaster": [
 "scrollLineDown",