Skip to content

Instantly share code, notes, and snippets.

View jeroenbourgois's full-sized avatar
🐢

Jeroen Bourgois jeroenbourgois

🐢
View GitHub Profile
find . -name .svn -print0 | xargs -0 rm -rf
@jeroenbourgois
jeroenbourgois / index.php
Created January 23, 2011 13:25
Parse that html
<?php
$oldSetting = libxml_use_internal_errors( true );
libxml_clear_errors();
$html = new DOMDocument();
$html->loadHtmlFile( 'http://www.makro.be/Content/assortiment/benzinestation/benzineprijzen/1/index.jsp?stat=0' );
$xpath = new DOMXPath( $html );
$nodelist = $xpath->query('//div[@class="boxContent"]/table/tr[last()]/td[last()]');
import lxml
import urllib
from lxml.html import fromstring
from lxml import etree
# vars
url = "http://www.makro.be/Content/assortiment/benzinestation/benzineprijzen/1/index.jsp?stat=0"
# methods
@jeroenbourgois
jeroenbourgois / mysql db backup script
Created February 9, 2011 21:25
Backup scripts that goes through all the mysql dbs and backups them to a backup folder, by date
#!/bin/sh
set -o errexit
nopass=0
if [ $# -eq 0 ]; then
echo "-----> No parameters passed, assuming username 'root' and empty password"
DBS=`mysql -uroot -e "show databases;"`
nopass=1
; $Id: drupalconnect.info, v 0.1 $
name = Drupal Connect
description = Provide a service for an external site
package = Custom modules
core = 6.x
<?php
/*
* Implementation of hook_disable()
* Perform necessary actions before module is disabled. (like clear the drupalconnect:methods cache)
*/
function drupalconnect_disable() {
cache_clear_all('drupalconnect:methods', 'cache');
}
/*
* Implementation of hook_enable()
<?php
/*
* Implementation of hook_service()
* Required by all server modules
* Returns array defining all the methods available in the service
*/
function drupalconnect_service() {
return array(
array(
<!DOCTYPE html>
<head>
<title>Drupalconnect frontend</title>
<style type="text/css">
* { padding: 0; margin: 0; }
html { font-family: "Lucida grande", arial, sans-serif; color: #222;}
body { width: 800px; margin: 0 auto; }
h1 { margin: 80px 0; }
h3 { margin-bottom: 10px; }
<?php
// let's turn on error reporting
ini_set("display_errors", 1);
// include the XMLRPC library
// I used the one by keithdevens.com/software/xmlrpc
// You are free to use any library, but then the call will be different
//
// Note: this library has one big downside, it throws a lot of warnings in PHP 5, since
// it has some deprecated calls. I just hide warnings on my production site, so that was not
<?php // this php tag is only included for gist to detect the file and do syntax coloring :)
// Call default or custom access callback
if (call_user_func_array($method['access callback'], $access_arguments) != TRUE) {
return services_error(t('Access denied'), 401);
}