Skip to content

Instantly share code, notes, and snippets.

View dvdfreitag's full-sized avatar
👀

David Freitag dvdfreitag

👀
View GitHub Profile
from math import *
steps = 8
values = [[[0, 0] * steps for j in range(steps)] * 4 for i in range(4)]
for i in range(0, steps):
if i == 0:
x = 0
else:
x = pi / (2.0 * (steps / i))

Keybase proof

I hereby claim:

  • I am dvdfreitag on github.
  • I am dvdfreitag (https://keybase.io/dvdfreitag) on keybase.
  • I have a public key ASAReb9Fd6Gx_OfrBTSMLfsvgT9_Jjem-NQM8KEtpH4jrQo

To claim this, I am signing this object:

@dvdfreitag
dvdfreitag / stuff.sh
Last active September 18, 2018 14:04
ITEM=0
FILE=<filename>
BASENAME=${FILE%.*}
EXTENSION=${FILE##*.}
while read server; do
<scp $FILE from $server>
mv $FILE $BASENAME$ITEM.$EXTENSION
let ITEM=ITEM+1
#include <errno.h>
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
void print_usage(void)
{
printf("Usage: blksize DIRECTORY\n");
printf("Attempts to determine the optimal block size using stat\n");
}
@dvdfreitag
dvdfreitag / Chrome statistics.ps1
Last active May 15, 2017 18:00
Powershell script to get Chrome process statistics
# Chrome statistics
$chrome = Get-Process -ea silentlycontinue chrome
# Print statistics
Write-Host "$($chrome.count) instances, $(($chrome | Measure-Object PM -Sum).Sum / 1GB)GB"
@dvdfreitag
dvdfreitag / AndroidNoAds.sh
Last active February 16, 2017 18:59
Shell script to install the Zero Hosts hosts file to block ads.
# It should go without saying that this requires root. This can be run either on a host PC with
# the Android Debug Bridge (adb), or on the device itself in a terminal emulator (such as Termux).
# More information on the Zero Hosts file: http://someonewhocares.org/hosts/zero/
# Uncomment if you're using adb
# adb shell
su # switch to root
cd /storage/emulated/0 # change directory to the internal storage
wget http://someonewhocares.org/hosts/hosts # download the zero hosts file
@dvdfreitag
dvdfreitag / RemoveWin10Apps.ps1
Created January 30, 2017 16:36
Remove all Windows 10 Store apps
<# This will attempt to remove all installed packages.
# Note: This will spit out a larage number of exception messages, this is due to unremovable apps, such as Cortana.
#>
foreach ($package in Get-AppxPackage -AllUsers) { Remove-AppxPackage $package.PackageFullName }
// The XMEGA E-series is different from all the other chips in the line, specifically the temperature sensor.
// It needs to be read in signed mode with a 125kHz clock. Everything else is the same.
void init(void)
{
// Configure signed conversions, internal 1V VREF, and enable temperature readings
ADCA.REFCTRL = ADC_CONMODE_bm | ADC_REFSEL_INT1V_gc | ADC_TEMPREF_bm;
// 12bit resolution in high current mode
ADCA.CTRLB = ADC_RESOLUTION_12BIT_gc | ADC_CURRLIMIT_HIGH_gc;
// ADC clock must be 125kHz, 32MHz / 256 = 125kHz
@dvdfreitag
dvdfreitag / xmega_temperature_sensor.c
Created December 6, 2016 16:13
Snippet for reading XMEGA temperature sensor
void init(void)
{
// Configure internal 1V VREF, enable temperature readings
ADCA.REFCTRL = ADC_REFSEL_INT1V_gc | ADC_TEMPREF_bm;
// 12bit resolution in high current mode
ADCA.CTRLB = ADC_RESOLUTION_12BIT_gc | ADC_CURRLIMIT_HIGH_gc;
// ADC clock must be 62.5kHz, 32MHz / 512 = 62.5kHz
ADCA.PRESCALER = ADC_PRESCALER_DIV512_gc;
// 1:1 gain with internal positive reading
ADCA.CH0.CTRL = ADC_CH_GAIN_1X_gc | ADC_CH_INPUTMODE_INTERNAL_gc;
#define _HARDWARE_TWI_
#include "MCP4728.h"
#define TWI_BAUD 0x3B // (F_CPU / (2 * TWI_SPEED)) - 5 (truncated to byte)
int main(void)
{
// Configure TWIE
// Clear Bit 6 corresponding to TWIE