Skip to content

Instantly share code, notes, and snippets.

Avatar

Sylvain Machefert symac

View GitHub Profile
@symac
symac / contributionsUtilisateursRecents.js
Created Feb 18, 2016
script greasemonkey pour n'afficher que les utilisateurs recents ayant contribué.
View contributionsUtilisateursRecents.js
// ==UserScript==
// @name New users
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://fr.wikipedia.org/w/index.php?title=Spécial%3AListe_des_utilisateur*
// @match https://fr.wikipedia.org/w/index.php?title=Sp%C3%A9cial%3AListe_des_utilisateurs*
// @match https://fr.wikipedia.org/w/index.php?title=Sp%C3%A9cial:Liste_des_utilisateurs*
// @grant none
View proxy.php
<?php
if (isset($_GET["mimetype"]))
{
$type = $_GET["mimetype"];
}
else
{
$type = "";
print "Manque le mimetype";
@symac
symac / processing_file.py
Last active Jan 30, 2016
processing utf8 file
View processing_file.py
#!usr/bin/env python
# -*- coding: utf-8 -*-
import pymarc
fout = open("output.mrc", "wb")
reader = pymarc.MARCReader(open("D978421.USM"), force_utf8=True, utf8_handling='ignore')
for record in reader:
f001 = record.get_fields("001")[0].data
print f001
fout.write(record.as_marc())
View getPages.py
def list_template_usage(site, article_tpl_name):
"""Return a generator of main space pages transcluding a given template."""
rowTemplate = wikipedia.Page(site, u'%s:%s' % (site.namespace(10), article_tpl_name))
transGen = pagegenerators.ReferringPageGenerator(rowTemplate, onlyTemplateInclusion=True)
filteredGen = pagegenerators.NamespaceFilterPageGenerator(transGen, [0])
generator = pagegenerators.PreloadingGenerator(filteredGen)
return generator
site = wikipedia.getSite("en", 'wikipedia')
for page in list_template_usage(site, "Infobox person"):
View testLink.py
View gist:cffcf1f9ab560b44a665
URL used:
http://ezproxy.yorksj.ac.uk/login?url=http://linksource.ebsco.com/linking.aspx?sid=EBSCO:eric&genre=article&issn=01411926&ISBN=&volume=39&issue=3&date=20130601&spage=473&pages=473-490&title=British%20Educational%20Research%20Journal&atitle=A%20Review%20of%20Thinking%20and%20Research%20about%20Inclusive%20Education%20Policy%2C%20with%20Suggestions%20for%20a%20New%20Kind%20of%20Inclusive%20Thinking&aulast=Thomas%2C%20Gary&pid=%3Cebsco-pid%3E%3CAN%3EEJ1014382%3C/AN%3E%3CDATABASE%3EERIC%3C/DATABASE%3E%3C/ebsco-pid%3E
EzProxy log:
193.61.230.106 - h5opmRemBAz7vTh [24/Aug/2015:16:54:33 +0000] "GET http://linksource.ebsco.com:80/linking.aspx?sid=EBSCO:eric&genre=article&issn=01411926&ISBN=&volume=39&issue=3&date=20130601&spage=473&pages=473-490&title=British%20Educational%20Research%20Journal&atitle=A%20Review%20of%20Thinking%20and%20Research%20about%20Inclusive%20Education%20Policy%2C%20with%20Suggestions%20for%20a%20New%20Kind%20of%20Inclusive%20Thinking&aulast=Thomas%2C%20Gary&pid=%3Cebsco-pid%3E%3CAN%
View stacktrace
1
Traceback (most recent call last):
File "testReading.py", line 11, in <module>
for record in reader:
File "/usr/lib/python2.7/dist-packages/six.py", line 535, in next
return type(self).__next__(self)
File "/usr/local/lib/python2.7/dist-packages/pymarc/reader.py", line 97, in __next__
utf8_handling=self.utf8_handling)
File "/usr/local/lib/python2.7/dist-packages/pymarc/record.py", line 72, in __init__
utf8_handling=utf8_handling)
View cacheRender.php
<?php
public function fightCache(Request $request, Application $app, $p1, $p2, $Q1, $Q2, $format = "")
{
$md5_page = md5($request->getUri());
// We need to check the cache page
$cache_file = __DIR__."/../../cache/render/".$md5_page.".txt";
if (file_exists($cache_file))
{
return file_get_contents($cache_file);
}
View wd_query.js
function search_player(request, respond){
//https:///w/api.php?action=wbsearchentities&search=one+dire&format=json&language=fr&type=item&continue=0
return $.ajax({
url: "https://www.wikidata.org/w/api.php?callback=?",
data: {
search: request.term,
action: "wbsearchentities",
format: "json",
language: window.lang,
type: "item"
You can’t perform that action at this time.