Skip to content

Instantly share code, notes, and snippets.

View yeremi's full-sized avatar
🏠
Working from home

Yeremi Loli yeremi

🏠
Working from home
View GitHub Profile
function es_api_detect_lang( $text ) {
$lang = false;
//if we can't tell the lang with 5000 characters we probably can't tell the language
$text = mb_substr( $text, 0, 5000 );
//replace non-breaking spaces so they don't match the \p{L} char class
$text = preg_replace( '/[\x{00A0}\x{2007}\x{202F}]/u', ' ', $text );
//replace unicode symbols: see: http://www.utf8-chartable.de/unicode-utf8-table.pl
@joncave
joncave / plugin.php
Last active March 27, 2025 13:23
An intentionally vulnerable plugin developed for WordPress plugin author education. http://make.wordpress.org/plugins/2013/04/09/intentionally-vulnerable-plugin/
<?php
/* Plugin Name: Damn Vulnerable WordPress Plugin
* Description: Intentionally vulnerable plugin for plugin author education
* Version: 0.1
* Plugin URI: http://make.wordpress.org/plugins/2013/04/09/intentionally-vulnerable-plugin/
* Author: Jon Cave
* Author URI: http://joncave.co.uk
* License: GPLv2+
*
* DO NOT RUN THIS PLUGIN ON AN INTERNET ACCESSIBLE SITE
@rogerluiz
rogerluiz / utils.js
Last active December 15, 2015 04:08
package with useful functions in javascript
(function (window, document) {
//------------------------------------
// GLOBAL VARIABLES
//------------------------------------
var location = window.location;
var navigator = window.navigator;
var userAgent = navigator.userAgent;
//------------------------------------
@jonathantneal
jonathantneal / cross-browser-text-selection.js
Created November 8, 2011 05:18
cross-browser-text-selection.js
(function (win, doc) {
function getRangeAtCollapse(range, collapsed) {
// get range as item
if (range.item) {
var rangeItem = range.item(0);
// return the data
return { node: rangeItem };
}
// get range as text
var
@yeremi
yeremi / sarfile.php
Created October 6, 2011 01:57
Sanitize And Rename Files
<?php
/**
* function sarfile($string)
* @author Yeremi Loli
* @access : public
* @version : 0.0.1
* @description :
* Sanitize And Rename Files.
* - Replace many accented letters to clean letters.
* - Give a prefix using microtime(true). More explanation in http://php.net/manual/en/function.microtime.php
@yeremi
yeremi / singleton.connection.php
Created September 30, 2011 20:51
Singleton connection
<?php
/*
* class Connection
* @author Yeremi Loli
* @since 0.01 v
* @category Global Singleton Connect
* @copyright 2011
* @example :
try {
$conn = Connection::Singleton();