This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # X_k = \sum_{n=0}^{N-1} x_n \cdot e^{-\frac{j 2 \pi k n}{N}} | |
| # X_k = \sum_{n=0}^{N-1} x_n \cdot [\cos(-\frac{2 \pi k n}{N}) + j\sin(-\frac{2 \pi k n}{N})] | |
| import math | |
| import cmath | |
| def generate_data(timespan=64): | |
| data = [] | |
| for i in range(timespan): | |
| ni = i/timespan |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| import sys | |
| import subprocess | |
| callgrind_file = sys.argv[1] | |
| executable_file = sys.argv[2] | |
| if len(sys.argv) < 3: | |
| print("Usage: fix-callgrind.py <callgrind file> <executable>") | |
| sys.exit(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "machine.h" | |
| void state_machine_step(state_machine_t* descriptor) { | |
| state_transition_t* transition; | |
| uint32_t current_state = *descriptor->state_index; | |
| for (uint32_t i = 0; i < descriptor->num_transitions; i++) { | |
| transition = &descriptor->transitions[i]; | |
| if ((transition->from_state == current_state) && (transition->condition(current_state))) { | |
| descriptor->on_state_change(current_state, transition->to_state); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 | |
| +------------------------------------------------------------------------------------------------+ | |
| | funct7 | rs2 | rs1 | funct3 | rd | opcode | R-type | |
| | imm[11:0] | rs1 | funct3 | rd | opcode | I-type | |
| | imm[11:5] | rs2 | rs1 | funct3 | imm[4:0] | opcode | S-type | |
| | imm[12|10:5] | rs2 | rs1 | funct3 | imm[4:1|11] | opcode | B-type | |
| | imm[31:12] | rd | opcode | U-type | |
| | imm[20|10:1|11|19:12] | rd | opcode | J-type | |
| +------------------------------------------------------------------------------------------------+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Pinout for Nucleo-F401RE | |
| _________________________________________________ | |
| | O | | |
| | User Reset | | |
| | [B] [B] | | |
| | PC10 PC11 PC9 PC8 | | |
| | PC12 PD2 PB8 PC6 | | |
| | VDD E5V PB9 PC5 | | |
| | BOOT0 GND AVDD U5V | | |
| | NC NC GND NC | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| uint16_t BitReverse16(uint16_t value) { | |
| value = (value & 0xFF00) >> 8 | (value & 0x00FF) << 8; | |
| value = (value & 0xF0F0) >> 4 | (value & 0x0F0F) << 4; | |
| value = (value & 0xCCCC) >> 2 | (value & 0x3333) << 2; | |
| value = (value & 0xAAAA) >> 1 | (value & 0x5555) << 1; | |
| return value; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import math | |
| import subprocess | |
| from random import choice | |
| from argparse import ArgumentParser | |
| def random_filename(): | |
| letters = [chr(ord("a") + x) for x in range(26)] | |
| return "".join([choice(letters) for _ in range(12)]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NAME := firmware | |
| # Utility commands | |
| RM := rm -rf | |
| DIR_DUP = mkdir -p $(@D) | |
| # Compiler commands | |
| GCC_PREFIX := arm-none-eabi | |
| CC := $(GCC_PREFIX)-gcc | |
| OBJCOPY := $(GCC_PREFIX)-objcopy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Run this script as root on a linux machine to | |
| # block (at least some) facebook trackers | |
| echo "0.0.0.0 www.facebook.com" >> /etc/hosts | |
| echo "0.0.0.0 facebook.com" >> /etc/hosts | |
| echo "0.0.0.0 login.facebook.com" >> /etc/hosts | |
| echo "0.0.0.0 www.login.facebook.com" >> /etc/hosts | |
| echo "0.0.0.0 fbcdn.net" >> /etc/hosts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "title": "Map CapsLock plus i/j/k/l to Arrows", | |
| "rules": [ | |
| { | |
| "description": "Map CapsLock plus i/j/k/l to Arrows", | |
| "manipulators": [ | |
| { | |
| "type": "basic", | |
| "from": { | |
| "key_code": "j", |