Skip to content

Instantly share code, notes, and snippets.

@maxcnunes
maxcnunes / curl-get-status-code-and-response-body.sh
Created November 24, 2015 17:52
Curl - Get status code and response body
URL="http://stackoverflow.com/"
# store the whole response with the status at the and
HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST $URL)
# extract the body
HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g')
# extract the status
HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
@yorikvanhavre
yorikvanhavre / getrecentfiles.py
Last active August 2, 2018 12:40
get list of recent documents in linux
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import re,os,gtk,gio,magic
def geticon(filename):
m = magic.open(magic.MAGIC_MIME)
m.load()
mime = m.file(filename).split(";")[0]
mime = gio.content_type_get_icon(mime).get_names()
@akostadinov
akostadinov / xmr-stak.service
Last active May 14, 2021 07:35
Example xmr-stak systemd service unit file.
[Unit]
Description=xmr-stak miner
After=syslog.target network.target
[Service]
Type=simple
# interesting info about starting as regular user: https://bbs.archlinux.org/viewtopic.php?id=162297
User=username
LimitMEMLOCK=256M
EnvironmentFile=-/etc/sysconfig/xmr-stak
#!/usr/bin/awk -f
# This program is a copy of guff, a plot device. https://github.com/silentbicycle/guff
# My copy here is written in awk instead of C, has no compelling benefit.
# Public domain. @thingskatedid
# Run as awk -v x=xyz ... or env variables for stuff?
# Assumptions: the data is evenly spaced along the x-axis
# TODO: moving average