A couple of solutions to CS50 problem 2 ("vanity plates") along with a simple test suite.
This file contains 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
1 | 146.82500 | 146.22500 | 0.60000 | -RPT | FM | ON | MRABBY | TONE | 67.0 Hz | 023 | 1500 Hz | MID | YES | 5.0KHz | OFF | OFF | 0 | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2 | 146.61000 | 146.01000 | 0.60000 | -RPT | FM | ON | MRMDN | TONE | 146.2 Hz | 023 | 1500 Hz | MID | YES | 5.0KHz | OFF | OFF | 0 | ||
3 | 146.67000 | 146.07000 | 0.60000 | -RPT | FM | ON | MRAQCY | TONE | 146.2 Hz | 023 | 1500 Hz | MID | YES | 5.0KHz | OFF | OFF | 0 | ||
4 | 146.71500 | 146.11500 | 0.60000 | -RPT | FM | ON | MRANRD | TONE | 146.2 Hz | 023 | 1500 Hz | MID | YES | 5.0KHz | OFF | OFF | 0 | ||
5 | 146.79000 | 146.19000 | 0.60000 | -RPT | FM | ON | MRAWES | TONE | 146.2 Hz | 023 | 1500 Hz | MID | YES | 5.0KHz | OFF | OFF | 0 | ||
6 | 147.12000 | 147.72000 | 0.60000 | +RPT | FM | ON | MRABCA | TONE | 146.2 Hz | 023 | 1500 Hz | MID | YES | 5.0KHz | OFF | OFF | 0 | ||
7 | 147.27000 | 147.87000 | 0.60000 | +RPT | FM | ON | MRAMRW | TONE | 146.2 Hz | 023 | 1500 Hz | MID | YES | 5.0KHz | OFF | OFF | 0 | ||
8 | 442.25000 | 447.25000 | 5.00000 | +RPT | FM | ON | MRALWL | TONE | 88.5 Hz | 023 | 1500 Hz | MID | YES | 12.5KHz | OFF | OFF | 0 | ||
9 | 442.70000 | 447.70000 | 5.00000 | +RPT | FM | ON | MRAHB2 | TONE | 88.5 Hz | 023 | 1500 Hz | MID | YES | 12.5KHz | OFF | OFF | 0 | ||
10 | 446.77500 | 441.77500 | 5.00000 | -RPT | FM | ON | MRANRD | TONE | 88.5 Hz | 023 | 1500 Hz | MID | YES | 12.5KHz | OFF | OFF | 0 |
This file contains 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
# GDB scripts for working with Linux ax.25 subsystem | |
define ax-devs | |
set $x = ax25_dev_list | |
while ($x != 0) | |
printf "%s axdev:%d dev_refcnt:%d dev_untracked:%d dev_notrack:%d\n", $x->dev->name, \ | |
$x->refcount->refs->counter, \ | |
$x->dev->dev_refcnt->refs->counter, \ | |
$x->dev->refcnt_tracker->untracked->refs->counter, \ | |
$x->dev->refcnt_tracker->no_tracker->refs->counter |
This file contains 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
Apr 17 09:38:03 radio1.local kernel: ------------[ cut here ]------------ | |
Apr 17 09:38:03 radio1.local kernel: WARNING: CPU: 0 PID: 3750 at lib/refcount.c:28 ax25_release+0x358/0x36c [ax25] | |
Apr 17 09:38:03 radio1.local kernel: refcount_t: underflow; use-after-free. | |
Apr 17 09:38:03 radio1.local kernel: Modules linked in: tun tcp_diag inet_diag mkiss overlay cmac algif_hash aes_arm_bs crypto_simd cryptd algif_skcipher af_alg bnep vc4 snd_soc_hdmi_codec drm_display_helper cec drm_dma_helper drm_kms_helper brcmfmac_wcc snd_soc_core hci_uart btbcm bluetooth brcmfmac cp210x snd_compress usbserial raspberrypi_hwmon snd_pcm_dmaengine snd_usb_audio bcm2835_codec(C) v4l2_mem2mem brcmutil snd_hwdep snd_usbmidi_lib bcm2835_v4l2(C) bcm2835_isp(C) cfg80211 bcm2835_mmal_vchiq(C) videobuf2_dma_contig videobuf2_vmalloc videobuf2_memops snd_rawmidi snd_bcm2835(C) videobuf2_v4l2 binfmt_misc snd_seq_device videodev snd_pcm snd_timer snd videobuf2_common ecdh_generic ecc rfkill mc vc_sm_cma(C) raspberrypi_gpiomem uio_pdrv_genirq |
This file contains 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 | |
# Split a certificate bundle into individual certificates. | |
# | |
# This will produce files named `cert-000.crt`, `cert-001.crt`, .etc. | |
read -r count < <(csplit -z "$1" -f cert- -b '%03d.crt' '/^-----BEGIN CERTIFICATE-----/' '{*}' | wc -l) | |
echo "split $count certificates" |
This file contains 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
CFLAGS = -g | |
example: example.o rom.o | |
$(CC) -o $@ $^ | |
rom.o: rom.S rom.bin | |
rom.bin: | |
echo -n -e '\x09\x08\x07\x06\x05\x04\x03\x02\x01\x00' > $@ |
This file contains 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 | |
# Create the substitute of C | |
git update-ref refs/heads/main $(git log -1 --pretty=%B $C | GIT_AUTHOR_NAME=$(git log -1 --pretty=%an $C) \ | |
GIT_AUTHOR_DATE=$(git log -1 --pretty=%ad --date=iso $C) \ | |
GIT_COMMITTER_NAME=$(git log -1 --pretty=%cn $C) \ | |
GIT_COMMITTER_DATE=$(git log -1 --pretty=%cd --date=iso $C) \ | |
git commit-tree -p $A -p $B -F - $C^{tree}) | |
git update-ref refs/heads/main $(git log -1 --pretty=%B $D | GIT_AUTHOR_NAME=$(git log -1 --pretty=%an $D) \ |
This file contains 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
kprobe:fib_validate_source { | |
$skb = (struct sk_buff*) arg0; | |
@skb[tid] = $skb; | |
@ipheader[tid] = ((struct iphdr *) ($skb->head + $skb->network_header)); | |
} | |
kretprobe:fib_validate_source { | |
$skb = @skb[tid]; | |
$ipheader = @ipheader[tid]; | |
$version = $ipheader->version; |
This file contains 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/sh | |
SERIAL1=( -chardev stdio,id=uart1 -serial chardev:uart1 -monitor none ) | |
SERIAL2=( -serial vc -serial vc ) | |
SERIAL3=( -nographic -serial mon:stdio ) | |
EMU_RASPI=( -M raspi3 ) | |
EMU_VIRT=( -M virt -cpu cortex-a72 ) | |
NET_TAP=( |
This file contains 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
{ | |
"definitions": { | |
"Group": { | |
"description": "A user.openshift.io/v1 Group", | |
"properties": { | |
"apiVersion": { | |
"default": "user.openshift.io/v1", | |
"title": "Apiversion", | |
"type": "string" | |
}, |
NewerOlder