Skip to content

Instantly share code, notes, and snippets.

View cohan's full-sized avatar
💭
Tinkering

Cohan cohan

💭
Tinkering
View GitHub Profile
@cohan
cohan / ai.sh
Created March 5, 2023 19:08
Talk to GPT from the command line
#!/bin/bash
api_key='xyzzy'
input="$@"
output=`curl --silent --location --request POST 'https://api.openai.com/v1/chat/completions' \
--header "Authorization: Bearer ${api_key}" \
--header 'Content-Type: application/json' \
--data-raw '{
@cohan
cohan / index.js
Created January 4, 2023 13:30
Prototype / Example worker for Cloudflare that pulls from R2
const corsHeaders = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET,HEAD,OPTIONS',
'Access-Control-Max-Age': '86400',
};
async function handleRequest(request) {
const url = new URL(request.url);
const key = url.pathname.slice(1);
@cohan
cohan / no-more-more-tweets.js
Last active December 14, 2022 04:10
Remove "More Tweets" by removing Twitter url params - Greasemonkey script
// ==UserScript==
// @name Remove "More Tweets"
// @version 1
// @grant none
// @run-at document-start
// @match *://*.twitter.com/*
// ==/UserScript==
function removeURLParameters(url) {
var urlParts = url.split('?');
@cohan
cohan / nginx.conf
Created June 26, 2020 03:32
thud.tv
## This is the config file for the stream ingest server
# We accept the stream (from OBS, xsplit, etc) here
# and turn it into a HLS stream (live video in fragments)
# served through HTTP. Reason we use this is HLS is very
# easy to serve using a Content Delivery Network (CDN)
# closer to individual viewers
# Generic guff. Run as the "nobody" user so if this service gets hacked
# they can't do much else
user nobody;
<?php
$captchaVerification = !empty($_REQUEST["captcha_verification"]) ? $_REQUEST["captcha_verification"] : false;
if ($captchaVerification !== false) {
$data = [
"endpoint" => "verify",
"captcha_verification" => $captchaVerification,
"captcha_difficulty" => 5 // make sure the difficulty matches the diffulty you added to form button
];
$options = [
"http" => [
<!DOCTYPE html>
<html>
<head></head>
<body>
<form action="https://link.to.your.form/" id="wehatecaptchas">
<!— more inputs here —>
<button type="submit" difficulty="5">Submit</button>
</form>
<script>
const onSubmit = (data) => {
@cohan
cohan / ircbot
Created December 18, 2017 13:32
An IRC bot interface to Botman. Would not recommend. Proof of concept only.
#!/usr/bin/env node
require('dotenv').config()
var irc = require('irc');
var request = require('ajax-request');
var foreach = require('foreach');
var client = new irc.Client(process.env.IRC_SERVER, process.env.IRC_NICK, {
channels: ['#home'],

Keybase proof

I hereby claim:

  • I am cohan on github.
  • I am cohan (https://keybase.io/cohan) on keybase.
  • I have a public key whose fingerprint is 8C52 C8B3 622D A82B 9DBC 7931 A4BF 93B6 5C5A 8060

To claim this, I am signing this object:

@cohan
cohan / gist:4131121
Created November 22, 2012 13:14
Zabbix (1.8) - MySQL query to select hosts NOT IN a specific group
# Not in a single group:
SELECT host FROM hosts h
WHERE NOT EXISTS
(SELECT groupid FROM hosts_groups hg
WHERE h.hostid = hg.hostid
AND hg.groupid = 100100000000001);
# Not in multiple groups: