Skip to content

Instantly share code, notes, and snippets.

View HananoshikaYomaru's full-sized avatar
:shipit:
Stay focus

Hananoshika Yomaru HananoshikaYomaru

:shipit:
Stay focus
View GitHub Profile
@HananoshikaYomaru
HananoshikaYomaru / index.php
Created December 12, 2023 06:30
todolist + ajax + log + sqlite
<?php
require 'vendor/autoload.php';
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
$db = new PDO('sqlite:todo.db');
$isAjaxRequest = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
@HananoshikaYomaru
HananoshikaYomaru / todolist.php
Created December 12, 2023 05:51
todolist php with AJAX
<?php
require 'vendor/autoload.php';
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
$isAjaxRequest = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
// Create a log channel
$log = new Logger('todo');
@HananoshikaYomaru
HananoshikaYomaru / index.php
Created December 12, 2023 01:38
simple php todolist
<?php
session_start();
// Initialize the todo list
if (!isset($_SESSION['todos'])) {
$_SESSION['todos'] = [];
}
// Add a new todo item
if ($_SERVER["REQUEST_METHOD"] == "POST" && !empty($_POST['new_todo'])) {
@HananoshikaYomaru
HananoshikaYomaru / fix.css
Last active January 31, 2024 10:31
life calendar in obsidian using dataview js
/* wide */
.wide .markdown-preview-sizer {
max-width: unset !important;
}
.life-calendar p a.internal-link {
display: inline-block;
}
@HananoshikaYomaru
HananoshikaYomaru / publish.css
Created November 22, 2023 07:13
I put this code in my obsidian publish
/* section : font */
@font-face {
font-family: "Geist";
src: url(https://cdn.jsdelivr.net/gh/HananoshikaYomaru/geist@main/GeistVF.woff2)
format("woff");
font-weight: normal;
}
@font-face {
font-family: "IA Writer Quattro";
@HananoshikaYomaru
HananoshikaYomaru / Dedent.js
Last active November 8, 2023 06:42
obsidian link preview
class Dedent {
dedent(templ) {
var values = [];
for (var _i = 1; _i < arguments.length; _i++) {
values[_i - 1] = arguments[_i];
}
var strings = Array.from(typeof templ === 'string' ? [templ] : templ);
strings[strings.length - 1] = strings[strings.length - 1].replace(/\r?\n([\t ]*)$/, '');
var indentLengths = strings.reduce(function (arr, str) {
var matches = str.match(/\n([\t ]+|(?!\s).)/g);
@HananoshikaYomaru
HananoshikaYomaru / cloudinaryMigration.ts
Last active June 16, 2023 03:23
cloudinary migration
import { prisma } from "@princess/db";
import pool from "@ricokahler/pool";
import { type ResourceApiResponse, v2 } from "cloudinary";
// this is the old cloudinary
const cloudName = "dg4lbnuii";
const apiSecret = "e2L-_EHhcno3FLYZcHYbokaY-EU";
const apiKey = "673961598382791";
const newCloudNamePreview = "wemakeapp-preview";
#!/bin/bash
# Define the list of branch names start with pr-
words=($(eas channel:list --json --non-interactive | jq -r ".currentPage[].name" | grep pr-))
# Loop over the filtered words and run the commands
for word in "${words[@]}"; do
eas channel:delete $word --non-interactive
eas branch:delete $word --non-interactive
done
@HananoshikaYomaru
HananoshikaYomaru / getRandomString.ts
Created April 19, 2023 12:28
getRandomString.ts
function generateRandomString(length) {
let result = "";
const characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * characters.length));
}
return result;
}
@HananoshikaYomaru
HananoshikaYomaru / getFileFromObjectUrl.ts
Last active April 18, 2023 10:30
getImageFromObjectUrl.ts
export const getFileFromObjectUrl = async (url: string) => {
const result = await fetch(url);
return result.blob();
};