Skip to content

Instantly share code, notes, and snippets.

@nadavkav
nadavkav / anthropic_to_bedrock_proxy.py
Created February 7, 2026 12:58
Craft agents proxy to AWS bedrock claude models
import os
import time
import uuid
from typing import Any, Dict, List, Optional, Union
import boto3
from fastapi import FastAPI, HTTPException, Request
from fastapi.responses import JSONResponse
import json
@nadavkav
nadavkav / moodle_qtype_stack_test.js
Last active May 29, 2024 20:23
PTL 11793 moodle_qtype_stack_test.js
<!--------------------------------------------------------------------------------------------------------------------------------><script>
function isless(x,y) {return (x<y)};
function isless(x,y) {return (x<y)};
function isless(x,y) {return (x<y)};
function isless(x,y) {return (x<y)};
function isless(x,y) {return (x<y)};
function isless(x,y) {return (x<y)};
function isless(x,y) {return (x<y)};
function isless(x,y) {return (x<y)};
function isless(x,y) {return (x<y)};
@nadavkav
nadavkav / local_helixmedia_lib.php
Last active October 25, 2022 16:36
Add MEDIAL "Dashboard" link to course menu
// This function can be added to the end of local/helixmedia/lib.php
// Add MEDIAL "Dashboard" link to course menu
function local_helixmedia_extend_navigation_course($parentnode, $course, $context) {
//if ($settingnode = $parentnode->find('courseadmin', navigation_node::TYPE_COURSE)) {
global $CFG;
require_once($CFG->dirroot.'/mod/helixmedia/lib.php');
$preid = helixmedia_preallocate_id();
$name = get_string('pluginname', 'helixmedia');
@nadavkav
nadavkav / moodle_time_on_page.js
Last active March 12, 2022 13:15
Count user's timeonpage (only when it is focused)
function local_petel_before_footer() {
global $PAGE, $USER, $CFG;
$sesskey = sesskey();
// Save data as event into Moodle logstore_standard_log DB table.
$logurl = $CFG->wwwroot. '/local/petel/timeonpage.php';
// Count the time a user was looking at the page (page was in focus)
// TODO: https://stackoverflow.com/questions/33859522/how-much-of-an-element-is-visible-in-viewport
// TODO: refactore JS code to: https://usefulangle.com/post/62/javascript-send-data-to-server-on-page-exit-reload-redirect
@nadavkav
nadavkav / Moodle_formulas_question.xml
Created January 23, 2022 20:19
Moodle formulas question (a test case for inconsistency verifying student answer)
<?xml version="1.0" encoding="UTF-8"?>
<quiz>
<!-- question: 3039285 -->
<question type="formulas">
<name>
<text>random validation error test case</text>
</name>
<questiontext format="html">
<text><![CDATA[<b>Please use normal decimal syntax:</b><br><br>{#A}<br><br>{#B}<br><br>{#C}<br><br>{#D}<br>]]></text>
</questiontext>
@nadavkav
nadavkav / gist:663427ed36c12852da4dfcabb1e6199a
Created January 2, 2022 19:01
Ubuntu 20.04 LTS (Focal Fossa) -- original (full) sources.list
deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
@nadavkav
nadavkav / he.json
Created November 23, 2021 18:28
BBB 2.4 Hebrew translation suggestions
{
"app.home.greeting": "המצגת שלך תתחיל בקרוב ...",
"app.chat.submitLabel": "שליחת הודעה",
"app.chat.errorMaxMessageLength": "ההודעה ארוכה מדי ב {0} תוו(ים)",
"app.chat.disconnected": "התנתקת מהמפגש, אי אפשר לשלוח הודעות",
"app.chat.locked": "המפגש ננעל, אי אפשר לשלוח הודעות",
"app.chat.inputLabel": "תוכן הודעה למפגש {0}",
"app.chat.inputPlaceholder": "שליחת הודעה ל {0}",
"app.chat.titlePublic": "צ'אט ציבורי",
"app.chat.titlePrivate": "צ'אט פרטי עם {0}",
@nadavkav
nadavkav / call datatables from php
Last active October 31, 2021 19:59
Experimenting using datatables.js in Moodle
$params['select'] = true;
$params['paginate'] = false;
$params['scroller'] = false; // require: paginate = true
//$params['buttons'] = array("selectAll", "selectNone",'copy','excel','pdf');
$params['buttons'] = array('copy','excel','pdf');
$params['dom'] = 'Bfrtip'; // Needed to position buttons; else won't display.
$params['selector'] = '.generaltable';
//$params['columnfilter'] = 1;
//$params['onlycolumns'] = '.c4,.c5,.c6,.c7';
$params['scrolly'] = 700;
@nadavkav
nadavkav / fix_other_field_data.php
Last active September 25, 2021 09:12
Fix logstore_standard_log.other field data format (JSON_UNESCAPED_UNICODE)
<?php
/**
* When using standard JSON format instead of PHP serialised data in the 'other' database field,
* Non English (Hebrew) letters are save in \uFFFF Unicode hexa human unreadable format.
* We need to fix this, to allow human-readable output when using block "configurable reports".
*
* @package logstore_standard_log
* @copyright 2021 Nadav Kavalerchik <nadav.kavalerchik@weizmann.ac.il>
* @auther Nadav Kavalerchik
@nadavkav
nadavkav / download_unicko_videos.php
Created September 13, 2020 14:49
Download UNICKO videos (php script via web API)
<?php
//require_once('config.php');
//require_once($CFG->libdir.'/filelib.php');
//use curl;
@ini_set('display_errors', '1');
@ini_set('html_errors', '1');
//$CFG->debug = (E_ALL | E_STRICT); // === DEBUG_DEVELOPER - NOT FOR PRODUCTION SERVERS!
//$CFG->debugdisplay = true;