Skip to content

Instantly share code, notes, and snippets.

View grigorig's full-sized avatar

Grigori Goronzy grigorig

View GitHub Profile
@grigorig
grigorig / swtpm-vtpm.sh
Last active February 18, 2022 14:26
Software TPM setup with swtpm plus initialization
#!/usr/bin/bash
modprobe tpm_vtpm_proxy
rm -rf /tmp/vtpm.state /tmp/vtpm.*
mkdir -p /tmp/vtpm.state
swtpm chardev --vtpm-proxy --tpmstate dir=/tmp/vtpm.state --tpm2 --ctrl type=tcp,port=2322 --log file=/tmp/vtpm.log,level=2 >/tmp/vtpm.out &
trap "kill %%" SIGINT EXIT
for i in {1..5}; do
[[ -s /tmp/vtpm.out ]] && break
echo "waiting for swtpm to be ready"
[stepper_x]
step_pin: PB3
dir_pin: PB4
enable_pin: !PB0
step_distance: .005
endstop_pin: !PB15
position_endstop: -32
position_max: 220
position_min: -32
homing_speed: 50
@grigorig
grigorig / playground.rs
Created August 20, 2017 14:25 — forked from anonymous/playground.rs
Rust code shared from the playground
fn is_vowel(c: char) -> bool {
let vocals = ['a', 'o', 'i', 'u', 'e', 'A', 'O', 'I', 'U', 'E'];
vocals.contains(&c)
}
fn pig_latin(input: &str) -> String {
let mut output = String::new();
for word in input.split_whitespace() {
if let Some(c) = word.chars().next() {
if is_vowel(c) {
@grigorig
grigorig / playground.rs
Created August 20, 2017 11:46 — forked from anonymous/playground.rs
Rust code shared from the playground
use std::collections::HashMap;
fn mean_median_mode(nums: &[i32]) -> (i32, i32, i32) {
let mut numbers = Vec::from(nums);
numbers.sort();
let median = numbers[numbers.len() / 2];
let mut sum = 0;
for num in &numbers {
sum += *num;
From c4da94d9dc105a7ab8d9883898837ff7ad001c57 Mon Sep 17 00:00:00 2001
From: Grigori Goronzy <greg@chown.ath.cx>
Date: Mon, 7 Sep 2015 11:15:15 +0200
Subject: [PATCH] DO NOT MERGE: horrible hacky fontconfig match_fonts
---
libass/ass_fontconfig.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 83 insertions(+), 1 deletion(-)
diff --git a/libass/ass_fontconfig.c b/libass/ass_fontconfig.c
From 9bf3b2082f1b8d5043e72d457cc4517b13177d13 Mon Sep 17 00:00:00 2001
From: Grigori Goronzy <greg@chown.ath.cx>
Date: Thu, 19 Jun 2014 13:54:21 +0200
Subject: [PATCH] R600/SI: implement range reduction for sin/cos
These instructions can only take a limited input range, and return
the constant value 1 out of range. We should do range reduction to
be able to process arbitrary values. Use a FRACT instruction after
normalization to achieve this.
From 9bf3b2082f1b8d5043e72d457cc4517b13177d13 Mon Sep 17 00:00:00 2001
From: Grigori Goronzy <greg@chown.ath.cx>
Date: Thu, 19 Jun 2014 13:54:21 +0200
Subject: [PATCH] R600/SI: implement range reduction for sin/cos
These instructions can only take a limited input range, and return
the constant value 1 out of range. We should do range reduction to
be able to process arbitrary values. Use a FRACT instruction after
normalization to achieve this.
diff --git a/src/gallium/drivers/radeonsi/si_blit.c b/src/gallium/drivers/radeonsi/si_blit.c
index 6bc89ab..325741b 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -500,6 +500,16 @@ static void si_reset_blittable_to_orig(struct pipe_resource *tex,
rtex->mipmap_shift = 0;
}
+static bool util_format_is_subsampled_2x1_32bpp(enum pipe_format format)
+{
// compile with gcc -o gs gs.c -lGL -lGLEW -lglut
#include <GL/glew.h>
#include <GL/glut.h>
#include <GL/freeglut_ext.h>
#include <stdio.h>
// Shader macro
#define GLSL(src) "#version 150 core\n" #src
// Vertex shader
#include <GL/glew.h>
#include <GL/glut.h>
#include <GL/freeglut_ext.h>
#include <stdio.h>
// Shader macro
#define GLSL(src) "#version 150 core\n" #src
// Vertex shader
const GLchar* vertexShaderSrc = GLSL(