Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View SimplGy's full-sized avatar

Eric Miller SimplGy

View GitHub Profile
@SimplGy
SimplGy / audio_from_elevenlabs.js
Created May 22, 2023 00:36
works, but only for short strings. getting 400 on anything else.
// docs:
// https://docs.elevenlabs.io/api-reference/quick-start/introduction
// https://api.elevenlabs.io/docs#/text-to-speech/Text_to_speech_v1_text_to_speech__voice_id__post
const axios = require('axios');
const fs = require('fs');
const path = require('path');
require('dotenv').config();
// Name: Screenshot URL
import "@johnlindquist/kit"
const { chromium }: typeof import("playwright") = await npm(
"playwright"
)
// get URL from user
let urlFromUser = await arg("Enter the URL to screenshot");
// Name: today-timestamp
// Description: inserts today's date in "ISO" format 2023-02-11
// Snippet:
import '@johnlindquist/kit';
function twoDigits(number: number): string {
return number.toString().padStart(2, '0');
}
import "@johnlindquist/kit"
// Menu: Giphy
// Description: Search giphy. Paste link.
// Author: John Lindquist
// Twitter: @johnlindquist
let download = await npm("image-downloader")
let queryString = await npm("query-string")
@SimplGy
SimplGy / generate-index-from-config.js
Created August 3, 2020 01:46
For every website folder that contains a certain file, autogen an index.html landing page for it.
// For every website folder that contains a certain file, autogen an index.html landing page for it.
const { readdirSync, statSync, writeFileSync, existsSync, readFileSync } = require('fs');
const { join } = require('path');
// ----------------------------------------- Config
const DIR = '/home/deploy/www';
const CONFIG_FILE = 'logo/info.txt';
@SimplGy
SimplGy / generate-nginx-config.js
Last active August 13, 2021 20:53
script that makes an nginx config for every folder in a certain dir
const { readdirSync, statSync, writeFileSync } = require('fs')
const { join } = require('path')
// ----------------------------------------- Config
const DIR = '/home/deploy/www';
const TARGET = '/home/deploy/deployNginxConfig';
const HEADER = `
# Config generated by 'generate-nginx-config.js', do not hand-edit
@SimplGy
SimplGy / addFileToGit.js
Last active October 6, 2021 12:38
Usage: `addFileToGit(foo.txt, "some file contents")`. Uses the "octokit" to add a single file to your gitub repo. Adapted from a Ruby guide by http://mattgreensmith.net
const Octokit = require('@octokit/rest'); // https://octokit.github.io/rest.js/
// Customize this stuff:
const auth = 'your-key-generated-in-github-ui'; // PRIVATE!
const owner = 'repo-owner';
const repo = 'your-repo-name';
// Constants
const userAgent = 'git commiter v1';
const ref = 'heads/master';
@SimplGy
SimplGy / node-get-file-contents.js
Last active May 4, 2019 03:42
Node - get the contents of all the files in DIR
const fs = require('fs')
const path = require('path')
const DIR = 'input/';
const readFile = name => fs.readFileSync(name);
(async () => {
const files = fs.readdirSync(DIR)
.filter(s => s.match(/\.csv$/)) // only .csv files -- change to whatever you want.
@SimplGy
SimplGy / sort-object-keys.ts
Last active March 16, 2019 21:53
sort keys of an object using an array index as rank, with TypeScript
export interface SomeShape {
b: string,
c: string,
a: string,
}
// Specify your sort order here
const rank: Array<keyof SomeShape> = ['a', 'b', 'c'];
export function sortedKvpString(obj: SomeShape) {
@SimplGy
SimplGy / keybindings.json
Created November 11, 2018 05:02
VSCode keybindings
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "cmd+d",
"command": "editor.action.copyLinesDownAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+alt+down",
"command": "-editor.action.copyLinesDownAction",