Skip to content

Instantly share code, notes, and snippets.

@lexor
lexor / p.sh
Last active October 6, 2024 04:26 — forked from rauchg/p.sh
Perplexity CLI in pure shell
#!/usr/bin/env bash
function p() {
jq -n \
--arg content "$*" \
'{
"model": "pplx-7b-online",
"messages": [
{
"role": "system",
"content": "Be precise and concise."
// P.S. the real moeny is at the buttom of the file
import { getTableColumns, type Table } from "drizzle-orm";
/**
* Creates a column selector for a given Drizzle ORM table.
*
* This function allows for flexible selection and omission of columns from a table.
*
* @param table - The Drizzle ORM table to create a column selector for.
@lexor
lexor / affiliateCookieRemover.js
Created April 6, 2024 17:02 — forked from soulbliss/affiliateCookieRemover.js
Marc Louvion's script to nuke affiliate cookie
// Nuke 'em all
// Marc's tweet https://twitter.com/marc_louvion/status/1776629697046339969
import { useEffect } from 'react';
useEffect(() => {
let referral_url = new URL(window?.location?.href);
if (
referral_url?.searchParams?.has('gclid') &&
@lexor
lexor / README.md
Created October 22, 2023 11:41 — forked from sancar/README.md
An upgradable read write lock for go

And upgradable read write lock for go

UpgradableRWMutex is an enhanced version of the standard sync.RWMutex. It has the all methods sync.RWMutex with exact same semantics. It gives more methods to give upgradable-read feature.

The new semantics for upgradable-read are as follows:

  • Multiple goroutines can get read-lock together with a single upgradable-read-lock.
  • Only one goroutine can have a write-lock and no read-lock/upgradable-read-lock can be acquired in this state.
@lexor
lexor / animate.js
Created September 12, 2019 23:10 — forked from tacyarg/animate.js
how to animate a sprite sheet
export default ({ imageurl, width = 200, height = 200, scale = 1 }) => {
let img = new Image()
img.src = imageurl
img.onload = loop()
let canvas = document.querySelector('canvas')
let ctx = canvas.getContext('2d')
const scaledWidth = scale * width
const scaledHeight = scale * height
import { TimelineMax, Circ, TweenMax } from 'gsap'
import { random } from 'lodash'
let tw = new TimelineMax()
function setupAudio(sound) {
const volume = sound ? 1 : 0
const start = new Audio('START_SOUND_URL')
start.volume = volume
@lexor
lexor / wet.js
Created January 15, 2019 15:08 — forked from tacyarg/wet.js
Simple wax express trade wrapper with a few helper funtions
const assert = require('assert')
const axios = require('axios')
const join = require('url-join')
const lodash = require('lodash')
const Promise = require('bluebird')
const twoFactor = require('node-2fa')
const BASE_URL = 'https://api-trade.opskins.com'
module.exports = function(config) {
@lexor
lexor / provable.js
Created January 15, 2019 15:08 — forked from tacyarg/provable.js
provable hash chain generation
var Provable = require('provable')
var lodash = require('lodash')
var assert = require('assert')
var uuid = require('uuid/v4')
//special cofactors
var e = Math.pow(2,52)
var t = 6e-5
var tinv = 1/t
var maxHex = 13
@lexor
lexor / jackpot.js
Created January 15, 2019 15:08 — forked from tacyarg/jackpot.js
jackpot game methods, state-machine and ticket generation.
const generateRandomColor = function() {
var letters = '0123456789ABCDEF'
var color = '#'
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)]
}
return color
}
function canJoin(gameid, bet) {