Skip to content

Instantly share code, notes, and snippets.

View davidbgk's full-sized avatar
🚪
Let’s escape GAFAM+ when/while we can!

David Larlet davidbgk

🚪
Let’s escape GAFAM+ when/while we can!
View GitHub Profile
@davidbgk
davidbgk / pre-commit.py
Created July 11, 2012 10:02 — forked from streeter/pre-commit.py
Python .git/hooks/pre-commit hook
#!/usr/bin/env python
import os
import re
import subprocess
import sys
modified = re.compile('^(?:M|A)(\s+)(?P<name>.*)')
CHECKS = [
@davidbgk
davidbgk / uri.js
Created July 14, 2012 09:52 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@davidbgk
davidbgk / pr.md
Created September 17, 2012 13:21 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@davidbgk
davidbgk / rss-subscribers.sh
Created September 25, 2012 21:44
Bash script to parse Apache log for a count of RSS subscribers and email it to you
#!/bin/bash
# Schedule this to run once a day with cron. Doesn't matter what time since it parses yesterday's hits (by default).
# I only tested this on the Marco.org server, which runs CentOS (RHEL). No idea how it'll work on other distributions, but it's pretty basic.
# Required variables:
RSS_URI="/rss"
MAIL_TO="your@email.com"
LOG_FILE="/var/log/httpd/access_log"
@davidbgk
davidbgk / thoughts.mdown
Created October 7, 2012 07:59 — forked from karlcow/thoughts.mdown
About interacting with David Thoughts

A small note in David Larlet's thoughts says he is frustrated about not having interactions in his thoughts. Christian Fauré made a comment on twitter about:

  1. Writing in French instead of English.
  2. Having the possibility for comments.

I started to write a tweet for answering to Christian and David and thought, Twitter is not the right place. But I still have a stream of thoughts that I could share. Usenet was quite practical for this in the past. Very handy for sharing thoughts and discussing at the same time without any approval… until the first spam on Usenet, but I digress or more exactly it is too early for this argument.

David: There will always be spam where there is attention (and value).

French or English

@davidbgk
davidbgk / thoughts.mdown
Created October 10, 2012 18:41 — forked from karlcow/thoughts.mdown
About interacting with David Thoughts

Online Discussions And Interactions

License

This document is under CC0 aka equivalent of public domain. People may fork it at will so it will travel through space and time without a precise ownership and might blossom in thousand of branches.

Contributing to this document

You may fork, rewrite a poem, take a stroll and make a photo album with it, add a comment, it doesn't matter. At least a few branches or outcomes of this document might create something owned by our collective mind more than individual. Maybe it will die, it doesn't matter. It really depends on the desire of the people involved to make it alive.

@davidbgk
davidbgk / new_bashrc.sh
Created October 15, 2012 09:48 — forked from josephwecker/new_bashrc.sh
Replace .bashrc, .bash_profile, .profile, etc. with something much more clean, consistent, and meaningful. Now a repo: https://github.com/josephwecker/bashrc_dispatch
#!/bin/bash
# License: Public Domain.
# Author: Joseph Wecker, 2012
#
# -- DEPRICATED --
# This gist is slow and is missing .bashrc_once
# Use the one in the repo instead! https://github.com/josephwecker/bashrc_dispatch
# (Thanks gioele)
#
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile?
@davidbgk
davidbgk / kill.js
Created January 31, 2013 00:04 — forked from brunobord/kill.js
/**
* Casper script to restart Alwaysdata processes.
*
* Usage:
* $ casperjs kill.js email@example.com mysecretpassword
*/
var casper = require('casper').create();
casper.start("https://admin.alwaysdata.com/login/");

Examples of RESTful API calls for E-commerce platforms

These examples are type 3 RESTful API requests and responses. The JSON-HAL specification is used to implement HATEOAS.

Some of the examples are based on my work as architect of the RESTful API at http://www.hautelook.com. All proprietary information has been removed.

Relevant links

/**
* Casper script to restart Alwaysdata processes.
*
* Usage:
* $ casperjs kill.js email@example.com mysecretpassword
*/
var casper = require('casper').create();
casper.start("https://admin.alwaysdata.com/login/");