Skip to content

Instantly share code, notes, and snippets.

@yosephbernandus
yosephbernandus / app.js
Created September 26, 2024 13:41
Test Convert
import React, { useEffect, useState, useRef } from 'react';
import './style.css'; // Assuming your CSS is in the same directory
function ProgressBar() {
const [progressLabel, setProgressLabel] = useState("Loading...");
const [progressPercentage, setProgressPercentage] = useState(0);
const [progress, setProgress] = useState(0);
const [kneItems, setKneItems] = useState(Array(25).fill(false));
const progressBarRef = useRef(null);
const progressContainerRef = useRef(null);
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@yosephbernandus
yosephbernandus / shell.nix
Created February 22, 2024 16:17 — forked from glendmaatita/shell.nix
OnXP Python Web Development
let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-23.11";
pkgs = import nixpkgs { config = { allowUnfree = true; }; overlays = []; };
git = pkgs.git.overrideAttrs (oldAttrs: rec {
version = "2.42.0";
});
podman = pkgs.podman.overrideAttrs (oldAttrs: rec {
version = "4.7.2";
@yosephbernandus
yosephbernandus / celery.sh
Created May 4, 2022 04:16 — forked from amatellanes/celery.sh
Celery handy commands
/* Useful celery config.
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379')
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_QUEUES=(
Queue('default', routing_key='tasks.#'),
@yosephbernandus
yosephbernandus / check_answers.py
Created December 15, 2021 13:29
Check answers premium tryout
import csv
tkp = Category.objects.get(id=3)
tryouts = PremiumTryout.objects.get(id=19)
premium_tryout_answers = PremiumTryoutAnswer.objects.filter(premium_tryout=tryouts, subcategory__category=tkp)
rows = []
headers = ['id', 'answer', 'question_id', 'question_answer', 'score_a', 'score_b',
from ayocasn.apps.categories.models import Subcategory
question_migration = {
'Nasionalisme': 5,
'Bela Negara': 5,
'Integritas': 5,
'Pilar Negara - Bhinneka Tunggal Ika': 4,
'Pilar Negara - UUD 1945': 4,
'Pilar Negara - Pancasila': 4,
'Pilar Negara - NKRI': 3,
@yosephbernandus
yosephbernandus / migration_subcategory.py
Last active November 27, 2021 09:07
migration_subcategory
from ayocasn.apps.categories.models import Category, Subcategory
# Migration subcategory
cat_id_2 = Category.objects.get(id=2)
cat_id_2.id = 4
cat_id_2.save()
Subcategory.objects.filter(category_id=2).update(category_id=4)