Skip to content

Instantly share code, notes, and snippets.

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

Taku Amano usualoma

🏠
Working from home
View GitHub Profile
class Object
def in(*args)
args.include?(self)
end
end
if 1.in 1, 2, 3
puts('hoge')
end
<?php
if (in_array(1, array(1, 2, 3))) {
print('hoge');
}
#include <stdio.h>
enum Values { A = 1, B = 2, C = 4, D = 8 };
void main(void) {
enum Values a = A;
if (a & (A | B | C)) {
printf("hoge\n");
}
#!/usr/bin/perl
use GD;
use JSON;
my $img = GD::Image->new(shift);
my ($width, $height) = ($img->width, $img->height);
my @pixels = ();
@usualoma
usualoma / gist:630576
Created October 17, 2010 05:41
Base64 Encode
<mt:Ignore>Base64 Encode</mt:Ignore>
<mt:Unless
regex_replace="/_/","_-_-----"
regex_replace="/-/","__-_--_-"
regex_replace="/\x00/","________"
regex_replace="/\x01/","_______-"
regex_replace="/\x02/","______-_"
regex_replace="/\x03/","______--"
regex_replace="/\x04/","_____-__"
@usualoma
usualoma / gist:630579
Created October 17, 2010 05:43
Base64 Decode
<mt:Ignore>Base64 Decode</mt:Ignore>
<mt:Unless
regex_replace="/[\s\t\n\r=]/g",""
replace="A","______"
replace="B","_____-"
replace="C","____-_"
replace="D","____--"
replace="E","___-__"
replace="F","___-_-"
@usualoma
usualoma / gist:702898
Created November 17, 2010 02:41
mt-search-tag.cgi
#!/usr/bin/perl -w
use CGI;
$CGI::USE_PARAM_SEMICOLONS = 0;
my $q = CGI->new;
if ( my $tag = $q->param('tag') ) {
$tag =~ s/(\s| )+/ AND /;
$q->param( 'tag', $tag );
}
<mt:Var name="regex" value='/(.*?<img[^>]*src=")([^"]*)(.*)|.*/s' />
<mt:Unless regex_replace="$regex","$2">
<h1>test</h1>
<img src="http://www.example.com/test1.jpg" />
<p>message</p>
</mt:Unless>
<mt:Unless regex_replace="$regex","$2">
<h1>test</h1>
mkdir pdf-extract
cd pdf-extract
curl https://github.com/usualoma/pdf-extract/raw/master/distribution/MacPorts/Portfile > Portfile
sudo port install
package tainavi;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PlugIn_RecRD_BR610 extends PlugIn_RecRD_BZ700 implements HDDRecorder {
// 種族の特性
@Override