Skip to content

Instantly share code, notes, and snippets.

View deiu's full-sized avatar

Andrei deiu

View GitHub Profile
@deiu
deiu / linkheaderparser.js
Last active July 25, 2019 11:34
Parse HTTP Link header in Javascript
// parse a Link header
//
// Link:<https://example.org/.meta>; rel=meta
//
// var r = parseLinkHeader(xhr.getResponseHeader('Link');
// r['meta'] outputs https://example.org/.meta
//
function parseLinkHeader(header) {
var linkexp = /<[^>]*>\s*(\s*;\s*[^\(\)<>@,;:"\/\[\]\?={} \t]+=(([^\(\)<>@,;:"\/\[\]\?={} \t]+)|("[^"]*")))*(,|$)/g;
var paramexp = /[^\(\)<>@,;:"\/\[\]\?={} \t]+=(([^\(\)<>@,;:"\/\[\]\?={} \t]+)|("[^"]*"))/g;
@deiu
deiu / deploy.sh
Last active December 25, 2015 00:58
RWW.IO Web app deployer
#!/bin/sh
# RWW.IO Web app deployer. Simply run `sh deploy.sh` inside your Web app dir and follow the steps.
CERTCMD=""
# get target URI
read -p "Please provide the URI of the target dir (ex: http://example.org/apps/myapp/): " HOST
if [ "$HOST" = "" ]
then
@deiu
deiu / git-delete-history.sh
Last active September 10, 2018 07:57
Script to permanently remove files/folders from your Git history.
#!/bin/bash
# Script to permanently remove files/folders from your git history. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
set -o errexit
if [ $# -eq 0 ]; then
echo "Usage: $0 file1 file2"
echo " or: $0 path1 path2"
@deiu
deiu / delegated-webid.py
Created July 6, 2012 11:03
Uses a certificate (in PEM) to authenticate (through WebID) and access a protected page.
#!/usr/bin/env python
import urllib
import httplib2
cert_file = 'my.pem'
http = httplib2.Http(disable_ssl_certificate_validation=True)
http.add_certificate('', cert_file, domain='')