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
import re | |
re_quoted_string = re.compile(r"(\"(?:\\\"|[^\"])*\"|'(?:\\'|[^'])*')") | |
def split_with_quoted_strings(s): | |
"""Split string without splitting embedded quoted strings.""" | |
return [x.strip() for x in re_quoted_string.split(s) if x.strip()] | |
for x in split_with_quoted_strings('hello "world \\\"blah" \'x y z\' blah'): | |
print(x) |
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
#include <stdio.h> | |
#include "mpdecimal.h" | |
int main() | |
{ | |
mpd_context_t ctx; | |
mpd_t *a, *b, *c; | |
mpd_maxcontext(&ctx); | |
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
#include <stdio.h> | |
#include "tommath.h" | |
int main() | |
{ | |
mp_int a, b, c; | |
mp_init(&a); | |
mp_init(&b); | |
mp_init(&c); |
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
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')) |
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
$ 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 |
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
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 |
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
# Calculate display PPI (pixels per inch) given resolution, aspect ratio and diagonal size. | |
# Luke McCarthy 2013-08-02 | |
import math | |
def display_ppi(resolution, aspect_ratio, size_inches): | |
res_h, res_v = resolution | |
aspect_h, aspect_v = aspect_ratio | |
theta = math.atan(float(aspect_v) / aspect_h) | |
width = math.cos(theta) * size_inches |
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 | |
exec docker run -i -t --rm "$1" /bin/bash |
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
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: |
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 | |
export PM=$(grep -c processor /proc/cpuinfo) | |
# TODO compile LLVM compiler_rt for target | |
./configure \ | |
--prefix=/ \ | |
--target=armv7a-unknown-linux-eabi \ | |
CC=clang \ |
OlderNewer