Skip to content

Instantly share code, notes, and snippets.

View moznion's full-sized avatar

moznion moznion

View GitHub Profile
/*
* Receive the signal of infrared remote controller.
*/
#define RX_PIN 7
#define LOW_STATE 0
#define HIGH_STATE 1
typedef unsigned long ulong;
typedef unsigned int uint;
- (void)constructCustomButton:(UIBarButtonItem *)button
imageFileName:(NSString *)imageFileName
imageRect:(CGRect)
delegate:(SEL)delegate {
UIButton *customUseCouponButton = [[UIButton alloc] initWithFrame:imageRect];
[customUseCouponButton setBackgroundImage:[UIImage imageNamed:imageFileName]
forState:UIControlStateNormal];
[customUseCouponButton addTarget:self action:delegate forControlEvents:UIControlEventTouchUpInside];
[button setCustomView:customUseCouponButton];
#!/usr/bin/env ruby
# coding: utf-8
executing_processes = [];
10.times do |i|
if (executing_processes.length >= 3)
pid = Process.wait
executing_processes.reject! { |process| process == pid }
end
@moznion
moznion / restOmit.js
Created March 15, 2013 07:40
もうこれでいいや
String.prototype.restOmit = function(numberOfChar) {
if (this.length > numberOfChar) {
return this.slice(0, numberOfChar) + '...';
}
return this;
}
#!/bin/bash
array=('one' 'two' 'three' 'four')
opt_name='--exclude'
opts=''
for elem in ${array[@]}; do
opts=$opts$opt_name' '$elem' '
done
Creating /var/folders/cs/xyvyz40133z0g84f43jsrdnm0000gn/T/perl-build-20130327-19415399555(building directory)
Install 5.12.5 to /Users/ta_kawakami/.plenv/versions/5.12.5
Fetching 5.12.5 as /var/folders/cs/xyvyz40133z0g84f43jsrdnm0000gn/T/QA1hQLU1uI/perl-5.12.5.tar.bz2
Downloaded http://search.cpan.org/CPAN/authors/id/D/DO/DOM/perl-5.12.5.tar.bz2 to /var/folders/cs/xyvyz40133z0g84f43jsrdnm0000gn/T/QA1hQLU1uI/perl-5.12.5.tar.bz2.
rm -f config.sh Policy.sh
/usr/bin/perl -Mlib=/Users/ta_kawakami/.plenv/bin/../share/plenv//lib/perl5/ /Users/ta_kawakami/.plenv/bin/../share/plenv/bin/patchperl
Auto-guessed '5.12.5'
patching cpan/Archive-Tar/t/02_methods.t
patching ext/ODBM_File/hints/linux.pl
patching make_ext.pl
@moznion
moznion / cpanfile
Last active December 15, 2015 12:39
requires 'App::cpanminus' => '1.6008';
requires 'JSON' => '2.53';
requires 'Furl' => '2.10';
_requires 'List::Util' => 0;
on 'configure' => sub {
requires 'Module::Build' => '0.40';
requires 'Module::Build' => '0.09';
};
@moznion
moznion / git-merged?
Created April 16, 2013 10:59
Has current branch merged?
#!/bin/sh
decide_parent_branch() {
parent_branch=$1
if [ -z $parent_branch ] ; then
parent_branch='master'
fi
echo $parent_branch
}
#/usr/bin/env perl
use strict;
use warnings;
print "foo\n";
print "bar\n";
# foo
# bar
@moznion
moznion / number_of_depended.pl
Created May 19, 2013 15:20
This script gets number of depended by other modules...
#!/usr/bin/env perl
use strict;
use warnings;
use 5.008009;
use Furl;
use JSON;
my $module = shift @ARGV;