Skip to content

Instantly share code, notes, and snippets.

@ljmccarthy
ljmccarthy / cross-compile-musl-cortex-a8.sh
Created August 14, 2018 13:15
Cross-compile musl libc for ARM Cortex A8
#!/bin/sh
export PM=$(grep -c processor /proc/cpuinfo)
# TODO compile LLVM compiler_rt for target
./configure \
--prefix=/ \
--target=armv7a-unknown-linux-eabi \
CC=clang \
@ljmccarthy
ljmccarthy / settings.json
Last active August 15, 2018 16:12
My settings for VSCode
{
"editor.detectIndentation": false,
"editor.folding": false,
"editor.lineNumbers": "off",
"editor.renderWhitespace": "boundary",
"files.eol": "\n",
"git.autofetch": true,
"git.confirmSync": false,
"telemetry.enableCrashReporter": false,
"telemetry.enableTelemetry": false,
import json
import os
import requests
import sys
import urllib.parse
def google_search(**params):
params = dict(params, source='python', output='json')
response = requests.get('https://serpapi.com/search', params)
if response.status_code != 200:
@ljmccarthy
ljmccarthy / docker-shell
Created March 2, 2018 16:34
Docker Shell
#!/bin/sh
exec docker run -i -t --rm "$1" /bin/bash
@ljmccarthy
ljmccarthy / .Xresources
Last active December 13, 2015 13:17
My rxvt-unicode configuration
URxvt*.buffered: true
URxvt*.transparent: true
URxvt*.shading: 30
URxvt*.background: black
URxvt*.foreground: white
URxvt*.font: xft:DejaVu Sans Mono:size=10
URxvt*.scrollstyle: plain
URxvt*.scrollBar_right: true
*color0: #2E3436
@ljmccarthy
ljmccarthy / qemu-winxp.sh
Created November 28, 2015 18:31
QEMU command line for Windows XP
#!/bin/sh
exec qemu-system-i386 -enable-kvm -cpu host -m 1024 -vga std -soundhw ac97 -net nic,model=rtl8139 \
-net user -drive file=winxp.img,format=raw -drive file=/usr/share/virtio/virtio-win.iso,media=cdrom
$ sudo pacman -Rc systemd
checking dependencies...
:: alsa-plugins optionally requires libpulse: PulseAudio plugin
:: alsa-plugins optionally requires ffmpeg: libavcodec resampling plugin, a52 plugin
:: alsa-tools optionally requires gtk2: other GUI tools
:: alsa-tools optionally requires gtk3: hdajackretask
:: avahi optionally requires gtk3: avahi-discover-standalone, bshell, bssh, bvnc
:: avahi optionally requires gtk2: gtk2 bindings
:: avahi optionally requires qt4: qt4 bindings
import sys
from decimal import Decimal, ROUND_UP
def ebay_postage_price(p):
d = p * (1 / (1 - Decimal('0.134'))) + Decimal('0.20')
return d.quantize(Decimal('0.1'), rounding=ROUND_UP)
for x in sys.argv[1:]:
print(format(ebay_postage_price(Decimal(x)), '.2f'))
@ljmccarthy
ljmccarthy / factorial_tommath.c
Last active August 29, 2015 14:05
Compute factorial(1000) with libtommath
#include <stdio.h>
#include "tommath.h"
int main()
{
mp_int a, b, c;
mp_init(&a);
mp_init(&b);
mp_init(&c);
@ljmccarthy
ljmccarthy / factorial_mpdecimal.c
Created August 18, 2014 19:24
Compute factorial(1000) with mpdecimal
#include <stdio.h>
#include "mpdecimal.h"
int main()
{
mpd_context_t ctx;
mpd_t *a, *b, *c;
mpd_maxcontext(&ctx);