Skip to content

Instantly share code, notes, and snippets.

@commana
commana / mixer-download-step-function.json
Last active November 12, 2019 15:48
AWS Step Function: Download full MP4 mixer.com recordings. Periodically check a queue for new recordings, then multi-part upload three parts in parallel to S3.
{
"StartAt": "PollQueue",
"States": {
"PollQueue": {
"Type": "Task",
"Resource": "arn:aws:lambda:XXX:XXX:function:sfn_poll_queue",
"Next": "CheckForWork"
},
"CheckForWork": {
"Type": "Choice",
@commana
commana / main.js.patch
Created June 20, 2018 15:34
arsnova.cards: Prometheus, MongoDB, Meteor
diff --git a/server/main.js b/server/main.js
index 4c6ddc6e..11b1c792 100644
--- a/server/main.js
+++ b/server/main.js
@@ -22,4 +22,15 @@ import "../imports/api/userdata.js";
import "../imports/api/webPushSubscriptions.js";
import "./leitner.js";
+// npm install prom-client
+const promClient = require("prom-client");
@commana
commana / ARSnova-Router.jmx
Last active June 8, 2018 12:26
Performance test examples
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.8" jmeter="2.13.20170723">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="arsnova.voting" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="Benutzer definierte Variablen" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
@commana
commana / gold-rush.js
Last active August 29, 2015 14:02
My collection of CodeCombat scripts
// This code runs once per frame. Build units and command peons!
// Destroy the human base within 180 seconds.
// Run over 4000 statements per call and chooseAction will run less often.
// Check out the green Guide button at the top for more info.
var base = this;
function sortByCoinValue(a, b) {
return b.coin.bountyGold - a.coin.bountyGold;
}
@commana
commana / pre-receive
Created February 24, 2012 18:23
Git pre-receive hook with PHP_CodeSniffer support
#!/usr/bin/env ruby
incoming = []
$stdin.each_line do |line|
segments = line.split(" ")
incoming.push({
"old" => segments[0],
"new" => segments[1],
"ref" => segments[2]
@commana
commana / wip.js
Created July 18, 2011 06:33
An old school 'work in progress' indicator.
function rotating_indicator(indicator) {
var element = document.getElementById(indicator),
type = element.innerHTML,
next_type = "/";
switch (type) {
case "\\": next_type = "|"; break;
case "|": next_type = "/"; break;
case "/": next_type = "\u2014"; break;
case "\u2014": next_type = "\\"; break;
}
@commana
commana / constructor.php
Created March 18, 2011 13:48
Which constructor takes precedence in PHP?
<?php
/*
PHP allows two possibilities to define a constructor:
1) Using the classic, Java-like way with a method named like the class, or
2) with the magic method named __construct.
Of these two possibilities, which one takes precedence?
@commana
commana / bom-check.php
Created July 14, 2010 11:53
eStudy pre commit hooks
#!/usr/bin/php
<?php
define('SVNLOOK', '/usr/bin/svnlook');
// 1 = TXN, 2 = REPO
$command = SVNLOOK." changed -t {$_SERVER['argv'][1]} {$_SERVER['argv'][2]} | awk '{print \$2}' | grep -i \\.php\$";
$handle = popen($command, 'r');
if ($handle === false) {
echo 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL;
exit(2);
}
@commana
commana / AbschnitteProKurs.sql
Created May 16, 2010 21:41
AbschnitteProKurs
SELECT AVG(Abschnitte) FROM (SELECT courseID, COUNT(courseID) AS Abschnitte FROM `planningsection` GROUP BY courseID) AS AbschnitteProKurs
@commana
commana / estudy-conventions.php
Created October 31, 2009 14:49
eStudy Conventions
<?php
class Example extends SuperExample implements I0, I1, I2 {
const MY_TRUE = 1;
private $a = 0;
public function foo($a, $b) {
for ($i = 0; $i < 10; $i++) {}