Skip to content

Instantly share code, notes, and snippets.

@masterzorag
masterzorag / cooling_policy
Created September 26, 2017 10:56
A simple bash script to get/set thermal cooling policy for each cpu
#!/bin/sh
# For all cpus, just report current states if no argument is passed
NCPU=$((`grep -c '^processor' /proc/cpuinfo`))
if [ $# -lt 1 ];
then
MAX=$((`cat /sys/devices/virtual/thermal/cooling_device0/max_state`))
echo "Current cooling policy for $NCPU cpus: [0-$MAX]"
for (( i=0; i<$NCPU; i++ ))
@masterzorag
masterzorag / argb_vector.c
Created November 13, 2017 18:26
An example of using Clang vector extension
/*
an example of using GCC/Clang vector extension
clang argb_vector.c
./a.out
0 ffffffff ffffffff
1 dde0e2e5 dddfe1e4
2 bbc0c5ca bbbfc4c9
3 99a1a8af 99a0a7ae
@masterzorag
masterzorag / libpng_test.c
Created December 31, 2017 18:03 — forked from niw/libpng_test.c
How to read and write PNG file using libpng. Covers trivial method calls like png_set_filler.
/*
* A simple libpng example program
* http://zarb.org/~gc/html/libpng.html
*
* Modified by Yoshimasa Niwa to make it much simpler
* and support all defined color_type.
*
* To build, use the next instruction on OS X.
* $ brew install libpng
* $ clang -lz -lpng libpng_test.c
@masterzorag
masterzorag / alsa-info
Created April 28, 2018 12:15
alsa-info on Liverpool
upload=true&script=true&cardinfo=
!!################################
!!ALSA Information Script v 0.4.64
!!################################
!!Script ran on: Sat Apr 28 11:55:56 UTC 2018
!!Linux Distribution
!!------------------
cl_get_gt_device(): error, unknown device: 0                                                                                               

  Platform Name                                   Clover                                                                                   
Number of devices                                 1                                                                                        
  Device Name                                     AMD LIVERPOOL (DRM 2.50.0 / 4.14.4, LLVM 6.0.0)                                          
  Device Vendor                                   AMD                                                                                      
  Device Vendor ID                                0x1002                                                                                   
  Device Version                                  OpenCL 1.1 Mesa 18.0.2                                                                   
  Driver Version                     
0000000000401e30 <_Z17star_accell1_4sseR6t_star>:
401e30: 55 push %rbp
401e31: 48 89 e5 mov %rsp,%rbp
401e34: 53 push %rbx
401e35: 48 81 ec e8 00 00 00 sub $0xe8,%rsp
401e3c: 48 89 fb mov %rdi,%rbx
401e3f: e8 dc ee ff ff callq 400d20 <mcount@plt>
401e44: 0f 57 db xorps %xmm3,%xmm3
401e47: 0f 29 5d e0 movaps %xmm3,-0x20(%rbp)
401e4b: 0f 29 5d d0 movaps %xmm3,-0x30(%rbp)
@masterzorag
masterzorag / note_install.md
Last active November 8, 2018 22:36
notes about bootstrapping a Fedora 29 base install

Fedora 29 base install note

0. preamble to test on ps4

  • wired (NOT wireless) ps4 connection to net
  • those files, pinned in #ps4-linux Discord
  • No video output, use ssh
# ssh 10.0.0.24 -p 2020

Welcome to better-initramfs master-d0acfbe-2017-03-04. Linux kernel 4.14.74.

>>> The lockfile was created.
>>> In order to resume boot proces, run 'resume-boot'.
>>> Be aware that it will kill your connection which means
@masterzorag
masterzorag / mpz_squares.c
Created April 9, 2019 20:32
gmp sample to compute square roots
#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
int main(int argc, char *argv[])
{
mpz_t x, t, prev, dif;
mpz_init(dif);
mpz_init(t);
mpz_init(prev);
@masterzorag
masterzorag / affine.c
Last active July 21, 2019 12:09
compute affine transform
/* clang affine.c -Wextra */
/*
./a.out 1
1.000000 in [-1 1] = 255 in [0 255]
./a.out 0
0.000000 in [-1 1] = 127 in [0 255]
./a.out -1
-1.000000 in [-1 1] = 0 in [0 255]
*/