Skip to content

Instantly share code, notes, and snippets.

View fgm's full-sized avatar

Frédéric G. MARAND fgm

View GitHub Profile
@fgm
fgm / keybase.md
Created September 17, 2016 17:28

Keybase proof

I hereby claim:

  • I am fgm on github.
  • I am fgm (https://keybase.io/fgm) on keybase.
  • I have a public key whose fingerprint is 134F 30CA B7AE 45B8 E50E 7756 EC88 8C26 7F6E 6384

To claim this, I am signing this object:

@fgm
fgm / instrument.drush.inc
Created August 4, 2016 12:01
Drush time and memory measurement
<?php
/**
* @file
* A simple Drush plugin to report on time spent and memory usage
* without all the noise from the Drush "-d" option. Results look like:
$ drush cc all
'all' cache was cleared. [success]
Duration: 3.39 seconds
Memory:
<?php
/**
* Stubs generated from the mongodb extension using:
* Fgm\StubGenerator\StubDumper 2.0.0
*
* Name : mongodb
* Version : 1.1.7
* INI entries : 1
* - mongodb.debug = /tmp/mongodb_php.log
*/
@fgm
fgm / compile.bash
Last active January 2, 2016 12:44
2D graphics example using the g2 library
#! /bin/bash
set -x
# Exécution d'un programme utilisant la bibliothèque graphique g2
name=`basename -s.c $1`
cc $name.c -L/usr/local/lib -lg2 -L/usr/X11R6/lib -lm && ./a.out
@fgm
fgm / simpletest-clean.js
Last active November 4, 2015 17:12
Drop the MongoDB Simpletest collections from a Drupal 7 database
var collections = db.getCollectionNames();
collections.forEach(function(e) {
if (e.match(/^simpletest/)) {
db[e].drop();
}
});
// And the one-liner version, simple to paste.
db.getCollectionNames().forEach(function(e) { if (e.match(/^simpletest/)) { db[e].drop();}});
#!/bin/bash
# Build a commit frequency list.
ROW_LIMIT=20
git log --name-status $* | \
grep -E '^[A-Z]\s+' | \
cut -c3-500 | \
sort | \
uniq -c | \
@fgm
fgm / tinytest.api.js
Last active July 25, 2018 07:48 — forked from stbaer/tinytest.api
Meteor tinytest api
// From 1.1.03 packages/tinytest/tinytest.js
test._stringEqual(actual, expected, message) // Source comment: EXPERIMENTAL nicer (multiline) string display in runner
test.equal(actual, expected, message, not) // Source comment: "XXX eliminate 'message' and 'not' arguments"
/* Call this to fail the test with an exception. Use this to record exceptions
* that occur inside asynchronous callbacks in tests. It should only be used
* with asynchronous tests, and if you call this function, you should make
* sure that
* (1) the test doesn't call its callback (onComplete function);
* (2) the test function doesn't directly raise an exception.
*/
package main
import (
"net/http"
"fmt"
)
func main() {
mux := http.NewServeMux()
<?php
class Person {
public $name;
public function __construct($name) {
$this->name = $name;
}
public static function getName(Person $p = NULL) {
<?php
class Person {
public $name;
public function __construct($name) {
$this->name = $name;
}
public function getName() {