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
object Main extends App{ | |
val weights = Seq(10, 5, 1) | |
println(Seq("000", "001", "010", "011", "100", "101", "110", "111").permutations.toStream | |
.foldLeft[(Int, Seq[Seq[String]])]((0, Seq.empty)) { (prev, set) => | |
val count = set.tail.foldLeft((0, set.head)) { (acm, elem) => | |
(acm._1 + acm._2.zip(elem).zipWithIndex.foldLeft(0) { (sum, e) => | |
sum + (if (e._1._1 != e._1._2) weights(e._2) else 0) | |
}, elem) | |
}._1 | |
if (count > prev._1) { |
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
object StringHelper { | |
private val separatees = "[a-z](?=[A-Z])|[0-9](?=[a-zA-Z])|[A-Z](?=[A-Z][a-z])|[a-zA-Z](?=[0-9])".r | |
def camel2Snake(s: String): String = separatees.replaceAllIn(s, _.group(0) + '_') | |
.toLowerCase | |
} |
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
var config = require('config'); | |
var cluster = require('cluster'); | |
function exec(module, index) { | |
console.log((new Date()).getTime() + '[' + index + ']: ' + require('./' + config.cron.modulePath + '/' + module).hoge); | |
} | |
function execs(modules, id, exitOnFinish) { | |
console.log('execute ' + id + ' begin'); |
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
var config = require('config'); | |
var fs = require('fs'); | |
fs.readdir(config.cron.modulePath, function (err, files) { | |
if (err) { | |
console.error(err); | |
} else { | |
files.forEach(function(file) { | |
console.log(require('./' + config.cron.modulePath + '/' + file.substr(0, file.length - 3)).hoge); | |
}) |
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
class ViewController: UIViewController, UIScrollViewDelegate { | |
@IBOutlet var myImageView: UIImageView! | |
@IBOutlet var myScrollView: UIScrollView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.myScrollView.delegate = self |
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
@protocol LocationUpdatedDelegate | |
- (void)beginLocating:(BOOL)enabled; | |
- (void)locationWasUpdated:(CLLocationCoordinate2D)location; | |
@end | |
@interface AppDelegate : UIResponder<UIApplicationDelegate, CLLocationManagerDelegate> | |
@property(nonatomic) id<LocationUpdatedDelegate> locationDelegate; |
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
@interface AppDelegate () | |
// お知らせ表示用のナビゲーションコントローラー | |
@property(nonatomic, strong) UINavigationController *informationNavigationController; | |
@end | |
@implementation AppDelegate | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { |