This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM table PROCEDURE ANALYSE(0,0)\G | |
-- "ANALYSE() examines the result from a query and returns an analysis of the results that suggests optimal data types for each column that may help reduce table sizes." | |
SELECT COUNT(DISTINCT(SUBSTR(column, 1, 22))) / COUNT(DISTINCT(column)) * 100 FROM table; | |
-- Figures out index coverage with the given index length (22 here). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Encoding: UTF-8 | |
# | |
# Problem: \w in regular expressions should match Unicode characters | |
# when in Unicode mode*. | |
# Solution: Use the corresponding Unicode properties directly. | |
# | |
# *http://www.geocities.co.jp/kosako3/oniguruma/doc/RE.txt | |
r = %r{ [\p{Letter}\p{Mark}\p{Number}\p{Connector_Punctuation}]+ }x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gem build oauth-plugin.gemspec | |
$ gem install oauth-plugin-0.4.0.pre4.gem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<!-- ATSUI-compatible preferred fallback --> | |
<dict> | |
<!-- default ordered fallback list - fallback entity has to be PostScript name --> | |
<key>default</key> | |
<array> | |
<string>LucidaGrande</string> <!-- MAKE sure this matches the kCTFontSystemFontType in CTFontDescriptorCreateForUIType() & TDescriptorSourceImp::CreateDefaultDescriptor()! --> | |
<string>AppleSymbolsFB</string> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ToHTML | |
def self.included(base) | |
base.send(:include, InstanceMethods) | |
end | |
module InstanceMethods | |
# Recursively builds simple HTML for an arbitrary data structure | |
# Suited for use with data from ActiveSupport::JSON.decode | |
def from_json_to_html(context = '') | |
output = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# So, with some help (and perhaps some faulty testing on my part initially) here | |
# is a solution I'm happy with. | |
def sphinx_version | |
# STDERR redirection for Unix | |
stderr = $stderr.dup | |
read, write = IO.pipe | |
$stderr.reopen(write) | |
`indexer`[/^Sphinx (\d\.\d\.\d)/, 1] | |
rescue # This catches errors for Windows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ======================== | |
# = Specific to Japanese = | |
# ======================== | |
if ( $c->stash->{query}->{form}->{jap} ) { | |
$query->{'jap.jap'} = {'like' => $c->stash->{query}->{sql}->{jap_tokens}}; | |
my $q_jap = $c->model('DJDB')->storage->dbh->quote($jap); | |
$options = { | |
join => [qw/jap/], | |
order_by => qq{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use utf8; | |
use LWP::UserAgent; | |
use JSON; | |
use XML::Simple; | |
use Data::Dumper; | |
use Time::HiRes qw(gettimeofday tv_interval); | |
use URI::Escape qw(uri_escape_utf8); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
require 'benchmark' | |
require 'rubygems' | |
require 'active_support' | |
require 'oniguruma' | |
include Oniguruma | |
SKIP_INVALID_UTF8 = Iconv.new('UTF-8//IGNORE', 'UTF-8') | |
SIZE_R = ORegexp.new('.', '', 'utf8') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run like so: perl api_functional.pl api.smart.fm YOUR_API_KEY | |
use strict; | |
use warnings; | |
use utf8; | |
use Test::More qw(no_plan); | |
use LWP::UserAgent; | |
use JSON; | |
use XML::Simple; | |
use Data::Dumper; |