Skip to content

Instantly share code, notes, and snippets.

<?php
## script to add custom fields to magic fields
## version: 0.1
## author: Xavi Ivars (xavi.ivars at gmail.com)
define(WP_ADMIN,true);
include('wp-config.php');
include('wp-load.php');
global $wpdb;
private static String readFileAsString(String filePath) throws java.io.IOException{
byte[] buffer = new byte[(int) new File(filePath).length()];
FileInputStream f = new FileInputStream(filePath);
f.read(buffer);
return new String(buffer);
}
private static String readFileAsString(String filePath) throws java.io.IOException{
StringBuffer fileData = new StringBuffer(1000);
@xavivars
xavivars / widget-woo-photos.php
Created September 27, 2011 17:09
Woothemes Woo Widget file
<?php
/*---------------------------------------------------------------------------------*/
/* Photos CPT Widget */
/*---------------------------------------------------------------------------------*/
class WP_Widget_Photos extends WP_Widget {
function WP_Widget_Photos() {
$widget_ops = array('classname' => 'widget-photos', 'description' => __('Display Photos from your site.', 'woothemes'));
$control_ops = array('width' => 400, 'height' => 350);
$this->WP_Widget('woo_photos', __('Woo - Photos', 'woothemes'), $widget_ops, $control_ops);
@xavivars
xavivars / extract-unknown.sh
Created July 20, 2012 17:07
This script tries to extrat all unkown words (marked with "*") from a text file
#!/bin/bash
sed -e "s/[^[:alnum:]\\*]/ /g" -e "s/[[:blank:]]+/ /g" | tr " " "\\n" | sed -e "/^$/d" | grep "\*" | sort | uniq -c | sort -r -n | sed -e "s/\*//g"
@xavivars
xavivars / delete_words.py
Created July 20, 2012 18:56
Pipes stdin to stdout removing the words that appear in a given file
#!/usr/bin/python
import sys
# comprovem el parametre
if len(sys.argv)<2:
print >> sys.stderr, "ERROR: Cal utilitzar un fitxer."
# carreguem el diccionari correcte en memoria
dicc = {}
@xavivars
xavivars / remove-wrong-words.pl
Created December 17, 2012 19:41
Script to remove incorrect words from a file
use strict;
use warnings;
use Text::Aspell;
my $speller = Text::Aspell->new;
die unless $speller;
$speller->set_option('lang','en-US');
$speller->set_option('sug-mode','fast');
@xavivars
xavivars / gist:4321695
Created December 17, 2012 20:11
Missing words in apertium en-ca en monodix dictionary
com
para
self
molt
dos
default
log
anti
till
mid
@xavivars
xavivars / gist:6312777
Created August 22, 2013 21:06
Sample version of the commandline tool
package org.languagetool.commandline;
import java.io.*;
public class StdinTest {
public static void main (String [] args) throws Exception {
StdinTest stdinTest = new StdinTest();
}
@xavivars
xavivars / gist:7124845
Last active December 26, 2015 08:49
Words to add to apertium-es-ca
  • zanco/a/os/as
    • xanca/xanques
  • zancudo/a/os/as
    • xanquer/a/s/eres
@xavivars
xavivars / gist:b3f96583a18621a8c582
Created July 2, 2014 13:49
determinant_nom_estricte
<rulegroup id="determinant_nom_estricte" name="Revisa concordança determinant+nom estrictament">
<rule>
<pattern>
<token postag="D...S.*" postag_regexp="yes"></token>
<token postag="N..P.*" postag_regexp="yes"><exception postag="N..[SN0].*" postag_regexp="yes"></exception></token>
</pattern>
<message>Falta de concordança de nombre entre «\1» i «\2».</message>
<short>Concordança de gènere i nombre dubtosa</short>
<example type="incorrect">Porta <marker>el cotxes</marker>.</example>
<example type="correct">Porta el cotxe.</example>