Skip to content

Instantly share code, notes, and snippets.

View heysamtexas's full-sized avatar

Sam Texas heysamtexas

View GitHub Profile
@chanmix51
chanmix51 / transliterate.sql
Last active September 4, 2015 13:45
transliteration in plpgsql
CREATE OR REPLACE FUNCTION transliterate(my_text VARCHAR) RETURNS varchar AS $$
DECLARE
text_out VARCHAR DEFAULT '';
BEGIN
text_out := my_text;
text_out := translate(text_out, 'áàâäåáăąãāçċćčĉéèėëêēĕîïìíīñôöøõōùúüûūýÿỳ', 'aaaaaaaaaaccccceeeeeeeiiiiinooooouuuuuyyy');
text_out := translate(text_out, 'ÁÀÂÄÅÁĂĄÃĀÇĊĆČĈÉÈĖËÊĒĔÎÏÌÍĪÑÔÖØÕŌÙÚÜÛŪÝŸỲ', 'AAAAAAAAAACCCCCEEEEEEEIIIIINOOOOOUUUUUYYY');
text_out := replace(text_out, 'æ', 'ae');
text_out := replace(text_out, 'Œ', 'OE');
text_out := replace(text_out, 'Æ', 'AE');
@chanmix51
chanmix51 / slugify.sql
Last active September 4, 2015 13:45
slugification in plpgsql
CREATE OR REPLACE FUNCTION slugify(title VARCHAR) RETURNS varchar AS $$
SELECT trim(both '-' from regexp_replace(lower(transliterate(title)), '[^a-z0-9]+', '-', 'g'));
$$ LANGUAGE sql IMMUTABLE;
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@clintongormley
clintongormley / html_strip.sh
Created January 15, 2011 13:06
HTML Strip charfilter test for ElasticSearch
# Analyze text: "the <b>quick</b> bröwn <img src="fox"/> &quot;jumped&quot;"
curl -XPUT 'http://127.0.0.1:9200/foo/' -d '
{
"index" : {
"analysis" : {
"analyzer" : {
"test_1" : {
"char_filter" : [
"html_strip"
location = /favicon.ico {
log_not_found off;
access_log off;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
@forkandwait
forkandwait / fips.sh
Created March 24, 2011 20:23
Reworked script for loading tiger data
declare -A FIPS
declare -A STNAME
FIPS[AK]=02; STNAME[AK]=Alaska
FIPS[AL]=01; STNAME[AL]=Alabama
FIPS[AR]=05; STNAME[AR]=Arkansas
FIPS[AS]=60; STNAME[AS]=American Samoa
FIPS[AZ]=04; STNAME[AZ]=Arizona
FIPS[CA]=06; STNAME[CA]=California
FIPS[CO]=08; STNAME[CO]=Colorado
FIPS[CT]=09; STNAME[CT]=Connecticut
@fernanDOTdo
fernanDOTdo / gist:1120286
Created August 2, 2011 14:21
My Nginx Multi-Symfony2 configuration
server {
listen 80 default;
server_name 192.168.0.34 localhost;
server_tokens off;
root /home/nginx/$host/web;
index app.php index.php index.html;
access_log /home/nginx/$host/app/logs/access.log;
error_log /var/log/nginx/error.log;
try_files $uri $uri/ @rewrite;
@yagitoshiro
yagitoshiro / push_notifications.js
Last active August 13, 2016 17:29
apple push notification sample (Titanium Mobile)
//////////////////////push_notifications.js///////////////////////
var apns = function(){
var pref = require('preferences').preferences;
Titanium.Network.registerForPushNotifications({
types: [
Titanium.Network.NOTIFICATION_TYPE_BADGE,
Titanium.Network.NOTIFICATION_TYPE_ALERT
],
success:function(e)
@spicycode
spicycode / tmux.conf
Created September 20, 2011 16:43
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@alinpopa
alinpopa / gist:1281448
Created October 12, 2011 15:05 — forked from vshkurin/gist:1109136
elasticsearch analyzer example - Test Queries
# Index
---------------------------------------------------------------------
curl -XPUT http://localhost:9200/pictures/ -d '
{
"settings": {
"analysis": {
"analyzer": {
"index_analyzer": {
"tokenizer": "standard",