Skip to content

Instantly share code, notes, and snippets.

@payload
payload / bitbucket-branch-author-names.js
Created July 20, 2023 13:46
Bitbucket Branch Author Names
Array.from(document.querySelectorAll(".aui-avatar [alt]")).map(
e => e.parentElement.parentElement.appendChild(
(() => { const p = document.createElement('p'); p.innerHTML = e.alt; return p })()
)
)
@payload
payload / mac-camera-playground.swift
Created October 2, 2022 16:47
How to get some camera frames with AVCaptureDevice APIs
import AVFoundation
import Cocoa
var greeting = "Hello, playground"
var camera_type = AVCaptureDevice.DeviceType.builtInWideAngleCamera
var unknown_type = AVCaptureDevice.DeviceType.externalUnknown
var discovery = AVCaptureDevice.DiscoverySession(
deviceTypes: [camera_type, unknown_type],
@payload
payload / rotating_bevy.rs
Created August 23, 2021 21:18
rotating bevy
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_startup_system(setup)
.add_system(update)
.run();
}
@payload
payload / Area2D.gd
Created January 3, 2020 12:16
Godot 3.2 - Area2D collides with TileMap cells
extends Area2D
func _ready():
connect("area_shape_entered", self, "area_shape_entered")
func area_shape_entered(area_id: int, area: Area2D, area_shape: int, self_shape: int):
var trans = Physics2DServer.area_get_shape_transform(area.get_rid(), area_shape)
var tilemap = area.get_node("Items") as TileMap
var offset = 2 * tilemap.cell_size if tilemap.centered_textures else Vector2.ZERO
var orig = trans.xform(offset)
@payload
payload / Camera.gd
Created August 8, 2019 18:59
simple godot camera control almost like in editor
extends Camera
export var speed = 5
export var max_speed = 20
export var wheel_speed = 5
export var fov_speed = 20
export var size_factor = 0.1
export var rotate_speed_x = 0.01
export var rotate_speed_y = 0.01
@payload
payload / canvascapture.md
Created October 24, 2017 14:29 — forked from iandanforth/canvascapture.md
Capture WebGL frames to disk

How to capture WebGL/Canvas by piping data over a websocket.

This Gist builds on https://gist.github.com/unconed/4370822 from @unconed.

Instead of the original method which writes to the browsers sandboxed filesystem here we use a websocket connection provided by websocketd to pipe image data to a short python script that writes out the .png files to disk.

Install websocketd

@payload
payload / if_let_lint.rs
Last active August 29, 2015 14:10
rust compiler plugin to check for `if let` opportunities
#![feature(if_let)]
#[phase(plugin,link)]
extern crate syntax;
#[phase(plugin, link)]
extern crate rustc;
use syntax::ast::{Expr, ExprMatch, PatWild, PatWildSingle, ExprTup};
use rustc::lint::{Context, LintPass, LintArray};
use syntax::codemap::NO_EXPANSION;
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from libavg import avg, app, player
class RemoteTestDiv(app.MainDiv):
def onInit(self):
self.canvas1 = player.createCanvas(id="1", size=(400,300))
self.canvas2 = player.createCanvas(id="2", size=(400,300))
@payload
payload / palava-example.html
Last active January 1, 2016 01:38
A little example to get plava client library started.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Meine erste Videoapplikation</title>
<script src="https://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="https://raw.github.com/Wolfy87/EventEmitter/master/EventEmitter.min.js"></script>
<script src="https://raw.github.com/palavatv/palava-client/master/palava.min.js"></script>
<script type="text/coffeescript">
@payload
payload / prettyics.sh
Created May 31, 2013 21:01
pretty print a .ics calendar file
#!/bin/sh
perl -ne'/END:/ && $i--; print "\t" x $i . "$_\n"; /BEGIN:/ && $i++;'