Skip to content

Instantly share code, notes, and snippets.

View worthmine's full-sized avatar

Yuki Yoshida worthmine

View GitHub Profile
class StringLikePerlArray {
var text :String = ""
init(_ string :String = ""){
text = string
}
func count()->Int {
var count :Int = 0
for string in text {
@worthmine
worthmine / Array Like Perl in Swift
Last active August 29, 2015 14:13
it works well!
class ArrayLikePerl {
var value: [Any] = []
init(_ array :[Any] = []){
value = array
}
func count()->Int {
return self.value.count
}
@worthmine
worthmine / ArrayLikePerl.swift
Last active August 29, 2015 14:13
swiftで定義するperl風な配列操作 ref: http://qiita.com/worthmine/items/9d335ce983c04ec15359
class ArrayLikePerl {
var value: [Any] = []
init(_ array :[Any] = []){
value = array
}
func count()->Int {
return self.value.count
}
@worthmine
worthmine / Extension Array Like Perl
Last active August 29, 2015 14:13
it works well!
extension Array {
typealias Element = T
mutating func scalar() -> Int {
return Int(self.count)
}
mutating func pop() -> T? {
if self.count == 0 { return nil }
let removed = self.removeAtIndex(self.endIndex.predecessor())
@worthmine
worthmine / ExtensionArrayLikePerl.swift
Last active August 29, 2015 14:13
[Swift]extensionで実装するPerl風の配列操作 ref: http://qiita.com/worthmine/items/40bfdd8f1f75bfe3463a
extension Array {
typealias Element = T
mutating func scalar() -> Int { // use it if you like perl
return Int(self.count)
}
mutating func pop() -> T? {
return self.isEmpty ? nil : self.removeAtIndex(self.endIndex.predecessor())
}
@worthmine
worthmine / file0.txt
Last active August 29, 2015 14:13
[Swift]型の違う値を同じ配列に入れる ref: http://qiita.com/worthmine/items/e1bde90f0fea60af3f9b
var arrayWithAnyType :[Any] = [/* You can insert here any initial values */]
@worthmine
worthmine / extensionPerlLikeSplice.swift
Last active August 29, 2015 14:14
[Swift]extensionで実装するPerl風のsplice() ref: http://qiita.com/worthmine/items/e859e87d6d46355bd069
extension Array {
typealias Element = T
mutating func splice(var _ atIndex :Int = 0, _ length :Int = 0, _ newElements: T...) -> Slice<T>? {
description
var theIndex = length + atIndex
var spliced :Slice<T> = []
if length < 0 {fatalError("minus length was set")}
if atIndex >= 0 {
if theIndex > self.endIndex {fatalError("Bad Access")}
@worthmine
worthmine / StopWatchMulti.swift
Last active August 29, 2015 14:14
[Swift] UIGestureRecognizerでストップウォッチを作ってみた。 ref: http://qiita.com/worthmine/items/1cecea3a8c9194a41d89
import UIKit
protocol CountNumDelegate: class {
func rapDelegate(lastRap: Int) -> ViewController
}
class TimerView :UILabel {
var timerOn = false
var nsTimer = NSTimer()
var countNum :Int
@worthmine
worthmine / Password.pm
Last active October 30, 2017 10:06
既存のCGIスクリプトでより強固なパスワード認証を行う ref: http://qiita.com/worthmine/items/519fb4fd1d7f5117a255
package Password;
use strict;
use warnings;
our $VERSION = '3.01';
use Carp;
use Crypt::PasswdMD5;
my @charset = ('A'..'Z', 'a'..'z', '0'..'9', '#', ',', qw# ! ? = + - * / _ [ ] { } ( ) < > | ~ ^ ' " % & . ; : $ #); # 強調表示の訂正用→'
@worthmine
worthmine / session.pl
Last active August 29, 2015 14:20
[Perl] CGI::Session でログイン/ログアウトを管理する簡単なサンプル ref: http://qiita.com/worthmine/items/22380ee826991277f5c5
#! /usr/local/bin/perl
use strict;
use warnings;
# 注)環境依存。この辺は適当に変えてください
use lib "$ENV{DOCUMENT_ROOT}/lib/perl5"; # CPANモジュールを読み込む
use lib "$ENV{DOCUMENT_ROOT}/lib"; # 上位のモジュールを読み込む
use lib "./lib"; # ローカルなモジュールを読み込む
# 環境依存終了