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
@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 / 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>
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 / 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}}
@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 / 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 / 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 / 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 {
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 / latency.txt
Created October 4, 2021 18:50 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD