Skip to content

Instantly share code, notes, and snippets.

View classicvalues's full-sized avatar
🥇
Automating Python! Working Chatbot @ gemini-chatbot-mocha-three.vercel.app

Classic Values classicvalues

🥇
Automating Python! Working Chatbot @ gemini-chatbot-mocha-three.vercel.app
View GitHub Profile
function translateError(msg) {
var newErr = new Error(msg); // placed here to get correct stack
return e => {
newErr.originalError = e;
throw newErr;
}
}
async function asyncTask() {
const user = await UserModel.findById(1).catch(translateError('No user found'))
@classicvalues
classicvalues / CorsFilter.kt
Created October 4, 2021 18:49 — forked from christoph-daehne/CorsFilter.kt
Set CORS Headers in Spring Boot Kotlin project with WebFlux and Reactor
import org.springframework.http.HttpMethod
import org.springframework.http.HttpStatus
import org.springframework.stereotype.Component
import org.springframework.web.server.ServerWebExchange
import org.springframework.web.server.WebFilter
import org.springframework.web.server.WebFilterChain
import reactor.core.publisher.Mono
@Component
class CorsFilter : WebFilter {
@classicvalues
classicvalues / toggle_chrome.sh
Created October 4, 2021 18:49 — forked from hartmut-co-uk/toggle_chrome.sh
Script to Toggle Chrome Process-State (STOP|CONT)
#!/bin/bash
# Copyright 2016 Hartmut Armbruster <info@hartmut.co.uk>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@classicvalues
classicvalues / QHalt.APPLESCRIPT
Created October 4, 2021 18:49 — forked from hartmut-co-uk/QHalt.APPLESCRIPT
AppleScript to shutdown / halt QNAP NAS (macOS Automator)
### AppleScript to shutdown / halt QNAP NAS
# requires pub-key access to QNAP setup for current user...
# [https://wiki.qnap.com/wiki/SSH:_How_To_Set_Up_Authorized_Keys]
tell application "Terminal"
set currentTab to do script ("ssh qnap halt;")
end tell
# Note: Using Mac OS 'Automator' it's easy to create a QHalt.app
@classicvalues
classicvalues / RouterPagination.vue
Created October 4, 2021 18:49 — forked from hartmut-co-uk/RouterPagination.vue
SSR supporting nuxt pagination vue component, pagination as links (`nuxt-link` -> vue-router) & query params (configurable param names). Data/API loading paginated results is done via nuxt `fetch` & `watchQuery`.
<template>
<div class="pagination">
<div class="inner">
<template v-if="showPrev">
<nuxt-link v-if="prev" :to="routeToPage(prev)" class="page previous">Previous</nuxt-link>
<span v-else class="page previous disabled">Previous</span>
</template>
<template v-for="it in prevPages">
<nuxt-link v-if="it !== -1" :key="it" :to="routeToPage(it)" class="page">{{ it }}</nuxt-link>
<span v-else :key="it" class="page more">...</span>
@classicvalues
classicvalues / QWake.sh
Created October 4, 2021 18:39 — forked from hartmut-co-uk/QWake.sh
Script to wakeup QNAP NAS (macOS Automator)
#!/bin/bash
### Script to wakeup QNAP NAS (well not much script there.. mostly to use via Automator)
# requires 'wakeonlan' (installed via Homebrew -> 'brew install wakeonlan')
/usr/local/bin/wakeonlan {{NAS_MAC1}}
### optional: 2nd eth adapter..
#/usr/local/bin/wakeonlan {{NAS_MAC2}}
class KMP:
def partial(self, pattern):
""" Calculate partial match table: String -> [Int]"""
ret = [0]
for i in range(1, len(pattern)):
j = ret[i - 1]
while j > 0 and pattern[j] != pattern[i]:
j = ret[j - 1]
ret.append(j + 1 if pattern[j] == pattern[i] else j)
@classicvalues
classicvalues / upload.php
Created September 28, 2021 08:42 — forked from taterbase/upload.php
Simple file upload in php
<!DOCTYPE html>
<html>
<head>
<title>Upload your files</title>
</head>
<body>
<form enctype="multipart/form-data" action="upload.php" method="POST">
<p>Upload your file</p>
<input type="file" name="uploaded_file"></input><br />
<input type="submit" value="Upload"></input>
@classicvalues
classicvalues / encryptor.md
Created September 26, 2021 12:20 — forked from vietdien2005/encryptor.md
encrypt decrypt id number
function encryptor($action, $string) {
    $output = false;

    $encrypt_method = "AES-256-CBC";
    //pls set your unique hashing key
    $secret_key = 'dj7oiop1mkdp251EnCrIt4QKq4988w6a';
    $secret_iv = 'oeuGJW0cBI4ye998Z7435sj9EkGnDD34';

 // hash
@classicvalues
classicvalues / morphagene_ableton.py
Created September 17, 2021 20:35 — forked from knandersen/morphagene_ableton.py
Allows you to use Ableton projects and exports as reels for the Make Noise Morphagene eurorack module.
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
USAGE:
morphagene_ableton.py -w <inputwavfile> -l <inputlabels> -o <outputfile>'
Instructions in Ableton:
Insert locators as splice markers in your project (Create > Add Locator)
Export Audio/Video with
Sample Rate: 48000 Hz