Skip to content

Instantly share code, notes, and snippets.

View phayes's full-sized avatar
⌨️

Patrick Hayes phayes

⌨️
View GitHub Profile
$collections = highwire_collection_get_collections('jbjsbrumb');
$hacked_collections = array();
foreach($collections as $col) {
$col['journal_id'] = 'jbjsbr';
$hacked_collections[] = $col;
}
$structured = highwire_collection_structure_collections($hacked_collections);
highwire_collection_process_collection('jbjsbr', $structured);
@phayes
phayes / gist:2770495
Created May 22, 2012 17:37
Manually rendering ctools-content-type
<?
ctools_include('plugins');
ctools_include('context');
ctools_include('content');
$plugin_id = 'super_pane';
$plugin = ctools_get_plugins('ctools','content_types', $this->options['field'], $plugin_id);
$conf = array() // array of configuration to pass to the content-type
@phayes
phayes / gist:2844824
Created May 31, 2012 17:12
There are 5 error, find them all!
HTTP/1.1 404 OK
Date: Tue, 28 Feb 2012 08:27:31 GMT
Server: Apache/2.2.14 (Unix) DAV/2 mod_jk/1.2.28 mod_ssl/2.2.14 OpenSSL/0.9.7a
X-Highwire-SessionId: HESGLsGsZ6gE@El5Ygdodg
X-Highwire-RequestId: T0yP86tDcSgAAGGWM7sAAAEm
Cache-Control: max-age=120
Set-Cookie: 07B79562CC23CD0F8BECF49A6604D0A8; Path=/
Connection: close; charset=ISO-8859-1
Content-Type: text/html
// For H10 style relations, we need to 'guesse' what the relation type is by examining the two endpoints
function getRelationType($relation, $atominstance) {
if ($relation['type'] != 'related') {
return $relation['type'];
}
$otherinstance = highwire_get_raw_data($relation['apath']);
if ($otherinstance['type'] != 'article') {
return 'related';
}
<html>
<head>
<script type = "text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type = "text/javascript">
var success = function (data) {
console.log(data);
alert(data);
};
$.get("http://api.impactstory.org/tiid/doi/10.1371/journal.pcbi.1000361", function(data){console(data);});
</script>
impactStory.createAndGetCollection = function(aliases, title, callback, error, conf) {
impactStory.createCollection(aliases, title, function(collection) {
impactStory.getCollection(collection, callback, error, conf);
}, error);
});
@phayes
phayes / Tab Seperated AIS countries
Last active December 22, 2015 20:59
This is a tab-separated lookup table for AIS country prefixes, giving both the country name and it's ISO 3166 code (for use with flag image packs). For more info see http://www.itu.int/online/mms/glad/cga_mids.sh?lng=E
201 Albania AL
202 Andorra AD
203 Austria AT
204 Azores - Portugal PT
205 Belgium BE
206 Belarus BY
207 Bulgaria BG
208 Vatican VA
209 Cyprus CY
210 Cyprus CY
You look at trees and label them just so,
(for trees are 'trees', and growing is 'to grow');
you walk the earth and tread with solemn pace
one of the many minor globes of Space:
a star's a star, some matter in a ball
compelled to courses mathematical
amid the regimented, cold, inane,
where destined atoms are each moment slain.
At bidding of a Will, to which we bend
HTTP/1.1 404 OK
Date: Tue, 28 Feb 2012 08:27:31 GMT
Server: Apache/2.2.14 (Unix) DAV/2 mod_jk/1.2.28 mod_ssl/2.2.14 OpenSSL/0.9.7a
X-Highwire-SessionId: HESGLsGsZ6gE@El5Ygdodg
X-Highwire-RequestId: T0yP86tDcSgAAGGWM7sAAAEm
Cache-Control: max-age=120
Set-Cookie: 07B79562CC23CD0F8BECF49A6604D0A8; Path=/
Connection: close; charset=ISO-8859-1
Content-Type: text/html
/**
* A timing safe equals comparison
*
* From: http://blog.ircmaxell.com/2012/12/seven-ways-to-screw-up-bcrypt.html
*
* To prevent leaking length information, it is important
* that user input is always used as the second parameter.
*
* @param string $safe The internal (safe) value to be checked
* @param string $user The user submitted (unsafe) value