Skip to content

Instantly share code, notes, and snippets.

@shawnchin
shawnchin / mod_close_on_mod_leave.lua
Last active Mar 18, 2022
Jisi Prosody plugin to close room when last moderator leaves
View mod_close_on_mod_leave.lua
--- Jitsi prosody module to delete room after all moderators left room.
--- Installation:
--- 1. Download this script to the Prosody plugins folder (/usr/share/jitsi-meet/prosody-plugins/)
--- 2. Enable module in your prosody config. E.g.
---
--- Component "conference.meet.mydomain.com" "muc"
--- modules_enabled = {
--- ...
--- ...
--- "close_on_mod_leave";
@shawnchin
shawnchin / muc_owner_allow_kick.patch
Created Dec 14, 2021
muc_owner_allow_kick.patch for prosody 0.11.10
View muc_owner_allow_kick.patch
--- muc.lib.lua 2021-12-14 19:48:43.195680418 +0000
+++ muc.lib.lua 2021-12-14 20:01:22.865824156 +0000
@@ -1390,15 +1390,16 @@
if actor == true then
actor = nil -- So we can pass it safely to 'publicise_occupant_status' below
else
+ local actor_affiliation = self:get_affiliation(actor);
+
-- Can't do anything to other owners or admins
local occupant_affiliation = self:get_affiliation(occupant.bare_jid);
@shawnchin
shawnchin / shmemctypes.py
Created Sep 16, 2011
shm_open() version of multiprocessing.sharedctypes.RawArray
View shmemctypes.py
#
# Based on multiprocessing.sharedctypes.RawArray
#
# Uses posix_ipc (http://semanchuk.com/philip/posix_ipc/) to allow shared ctypes arrays
# among unrelated processors
#
# Usage Notes:
# * The first two args (typecode_or_type and size_or_initializer) should work the same as with RawArray.
# * The shared array is accessible by any process, as long as tag matches.
# * The shared memory segment is unlinked when the origin array (that returned
@shawnchin
shawnchin / shBrushFortran.js
Created Aug 10, 2010
Fortran brush for SyntaxHighlighter
View shBrushFortran.js
/*
* Fortran brush for SyntaxHighlighter
*
* SyntaxHighlighter by Alex Gorbatchev
* http://alexgorbatchev.com/
*
* Fortran brush by Shawn Chin
* Last update : 16 April 2011
* Homepage : http://shawnchin.github.com
* Brush page : http://gist.github.com/gists/517349
View mod_muc_per_room_max_occupants.lua
local jid = require("util.jid")
local is_healthcheck_room = module:require 'util'.is_healthcheck_room;
local max_occupants_for_room = module:get_option("max_occupants_for_room", {});
if next(max_occupants_for_room) ~= nil then
module:hook("muc-room-created", function(event)
local room = event.room;
@shawnchin
shawnchin / body.html
Last active Sep 8, 2021
Jitsi Prejoin Page -- inject email input field
View body.html
<script>
const INCLUDE_LABEL = false; // "false" to match new prejoin page UX, "true" to match jitsi meet 6173 or earlier
function getLocallyStoredEmail() {
// loads email from localStorage so we can pre-populate with email users set before
const settings = JSON.parse(window.localStorage.getItem('features/base/settings') || '{}');
return settings.email || ''
}
function injectEmailInputsToPrejoinForm(formContainer) {
@shawnchin
shawnchin / mod_event_sync_component.lua
Last active Jul 8, 2021
Jitsi prosody component to POST to external API on room/occupant events
View mod_event_sync_component.lua
--- Component to trigger an HTTP POST call on room/occupant events
--
-- Example config:
--
-- Component "event_sync.mydomain.com" "event_sync_component"
-- muc_component = "conference.mydomain.com"
--
-- api_prefix = "http://external_app.mydomain.com/api"
--
-- --- The following are all optional
@shawnchin
shawnchin / mod_frozen_nick.lua
Created Jun 9, 2021
Jitsi prosody plugin to stop users from changing display name if name provided by JWT
View mod_frozen_nick.lua
--- Stop users from changing nick (display name) if name is provided provided by jisi_meet_context_user
-- For all received presence messages, if jitsi_meet_context_user.name value is set in the session, then we simply
-- override nick with that value.
function on_message(event)
if event and event["stanza"] then
if event.origin and event.origin.jitsi_meet_context_user then
local name = event.origin.jitsi_meet_context_user['name'];
@shawnchin
shawnchin / testcode_buildbot.py
Last active Aug 5, 2020
Buildbot BuildSlave for testcode2
View testcode_buildbot.py
"""
Buildbot BuildStep that runs and parses the output of testcode2.
Copyright (c) 2013 Shawn Chin
This sofware is released under the BSD 3-Clause License
"""
import re
from itertools import chain
from collections import defaultdict
from buildbot.steps.shell import ShellCommand
View coin_change.py
# https://www.hackerrank.com/challenges/coin-change/problem
def cc_dp(target, coins):
current = [0] * (target + 1)
current[0] = 1
prev = current[:]
for c in coins:
for t in xrange(target + 1):