Skip to content

Instantly share code, notes, and snippets.

@gotomypc
gotomypc / config.ts
Created December 10, 2022 03:47 — forked from AmazingTurtle/config.ts
openai client
export const DEFAULT_ENGINE = 'davinci';
export const ENGINE_LIST = ['ada', 'babbage', 'curie', 'davinci', 'davinci-instruct-beta', 'curie-instruct-beta'];
export const ORIGIN = 'https://api.openai.com';
export const DEFAULT_API_VERSION = 'v1';
export const DEFAULT_OPEN_AI_URL = `${ORIGIN}/${DEFAULT_API_VERSION}`;
@gotomypc
gotomypc / VolumeDetect.md
Created December 6, 2022 23:39 — forked from 44213/VolumeDetect.md
Use ffmpeg to detect audio volume level. bat file included for easier interaction.

Detect the audio file volume with ffmpeg.

Require tools

  • ffmpeg: [Official site][1], [Download][2]

How to use

  1. Download ffmpeg from [link][2]
  2. Extract the ffmpeg.exe from zip package and copy to the directory contain the audio file
  3. Copy the volumeDetect.bat into the folder. (Just make sure the bat file and ffmpeg.exe are in the same directory)
  4. Doulbe click volumeDetect.bat and drag the file into the window.
  5. Press enter and get the result.

Improving SSL Configuration

  • Documentation:
    • NGINX ssl module
    • Mozilla’s Server Side TLS Documentation
  • Add session caching so that fewer SSL handshakes need to be made.
  • The initial handshake is the most taxing part of the process, and if we can avoid repeating it then we’ll improve our overall performance.
    $ vim /etc/nginx/conf.d/default.conf
    

ssl_certificate /etc/nginx/ssl/public.pem;

@gotomypc
gotomypc / a.js
Created October 23, 2022 08:58 — forked from Dobby233Liu/a.js
my messing w/ msedge dev read aloud. ONLY RUN IN edge dev. i give up, so it wont work properly
var ARRAY_LENGTH = 16;
var MIN_HEX_LENGTH = 2;
class UUID {
static createUUID() {
const array = new Uint8Array(ARRAY_LENGTH);
window.crypto.getRandomValues(array);
let uuid = '';
@gotomypc
gotomypc / s3upload.js
Created October 23, 2022 01:16 — forked from marksilvis/s3upload.js
Node.js upload to AWS S3
// requires AWS SDK
var AWS = require('aws-sdk')
, fs = require('fs');
var s3 = new AWS.S3({
apiVersion: '2006-03-01',
accessKeyId: 'AccessKey',
secretAccessKey: 'SecretKey',
region: 'region'
});
@gotomypc
gotomypc / tornado_background.py
Created October 23, 2022 01:15 — forked from marksilvis/tornado_background.py
Tornado example with non-blocking background tasks executed in thread pool
import time
from tornado import (
concurrent,
gen,
httpserver,
ioloop,
log,
web
)
@gotomypc
gotomypc / tornado_multiproc.py
Created October 23, 2022 01:14 — forked from marksilvis/tornado_multiproc.py
Example Tornado server with multiple processes running background tasks
import time
form tornado import (
concurrent,
gen,
httpserver,
ioloop,
log,
process,
web
@gotomypc
gotomypc / Beanutils.java
Created October 28, 2012 05:05 — forked from ideiudicibus/Beanutils.java
Merge two java beans useful when discovering differences
class Beanutils{
//merge two bean by discovering differences
private <M> void merge(M target, M destination) throws Exception {
BeanInfo beanInfo = Introspector.getBeanInfo(target.getClass());
// Iterate over all the attributes
for (PropertyDescriptor descriptor : beanInfo.getPropertyDescriptors()) {
// Only copy writable attributes
if (descriptor.getWriteMethod() != null) {
@gotomypc
gotomypc / image2base64.js
Created October 31, 2012 00:21 — forked from jfsiii/image2base64.js
Convert a remote image to Base64-encoded string
// Uses [request](https://github.com/mikeal/request)
// /?url=http://nodejs.org/logo.png
// /?uri=http://nodejs.org/logo.png
// /?url=http://nodejs.org/logo.png&cb=cbName
// /?url=http://nodejs.org/logo.png&callback=cbName
var fs = require('fs');
var url = require('url');
var http = require('http');
var request = require('request');
@gotomypc
gotomypc / load-generator.js
Created November 4, 2012 14:14 — forked from tkrueger/load-generator.js
generate and measure CPU load with node.js
#!/usr/bin/env node
require(__dirname+"/processor-usage.js").startWatching();
var shouldRun = true;
var desiredLoadFactor = .5;
function blockCpuFor(ms) {
var now = new Date().getTime();
var result = 0