Skip to content

Instantly share code, notes, and snippets.

View b-abctech's full-sized avatar

Pussaaon b-abctech

  • abc-tech thailand
  • Bangkok
View GitHub Profile
#!/usr/bin/perl -w
use strict;
use CGI qw(:all);
use CGI::Carp qw(fatalsToBrowser);
my($requested_color, $old_color, $color_cookie) = ("","");
$old_color="blue"; # Default value
# Is there a new color requested?
if(defined param('color')) {
$requested_color = param('color');
}
@b-abctech
b-abctech / RomanConverter
Created May 13, 2013 10:10
Can't locate object method "ROMANS_TO_NUMBERS" via package "RomanConverter" at line 93
package RomanConverter;
use Moose;
use POSIX qw(floor);
use String::Util qw(trim);
use v5.10;
has 'NUMBERS_TO_ROMANS' => (
is => 'bare' ,
isa => 'Tree' ,
weak_ref => 1 ,
for my $method (qw(build_date bought_date)) {
Sub::Install::install($_ => sub {
my ($self, $input_arg) = @_;
return format_string($self->$method);
});
}
sub apejens {}
########################### config yml ###########################
---
name: SearchResponsive::EchoSlam
EchoSlam:
my_config:
channel_name: 'my_config_yml_channel'
########################### model ###########################
package SearchResponsive::EchoSlam;
use Moose;
@b-abctech
b-abctech / gist:7481717
Created November 15, 2013 09:38
comparing elastic search query between specific range of date and using *
# ------------- using * ---------------------
POST /logstash-*/_search
{
"query": {
"filtered": {
"query": {
"match_phrase": {
"@fields.request": "/sok/google"
}
},
@b-abctech
b-abctech / gist:7931035
Created December 12, 2013 16:41
Simple sample to create template plugins
# this example based on module to do html/text truncate
# the Template plugin package
package Template::Plugin::TextTruncater;
use warnings;
use strict;
use utf8;
use DateTime;
@b-abctech
b-abctech / gist:7998889
Created December 17, 2013 02:19
detect click event on menu to add or remove class from the elements
<!-- 1. first create the menu list -->
<ul class="my-menu">
<li data-id="id-1" class="menu current">
<a href="#">hello world 1</a>
</li>
<li data-id="id-2" class="menu">
<a href="#">hello world 2</a>
</li>
<li data-id="id-3" class="menu">
<a href="#">hello world 3</a>
@b-abctech
b-abctech / gist:7998907
Created December 17, 2013 02:20
Search query string like with multiple fields
GET /stories/fairytale/_search
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"or": [
{
@b-abctech
b-abctech / gist:8216896
Created January 2, 2014 09:35
sending mail in text/html with Catalyst::View::Email::Template
# 1. first install module Catalyst::View::Email::Template, Catalyst::View::Email
# 2. create email template view
# 3. in config add these
View::Email::Template:
template_prefix: email
default:
view: HTML
content_type: text/html
@b-abctech
b-abctech / bingsearchphp
Last active January 4, 2016 21:49
Bing search php
<?php
/****
* PHP proxy for using the Bing Search API with AJAX
*/
$acctKey = 'xxx';