Skip to content

Instantly share code, notes, and snippets.

@seka
seka / sample.html
Created Aug 27, 2015
An invalid form control with name='' is not focusable.
View sample.html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>sample html</title>
</head>
<body>
<form id="hoge">
<fieldset>
<legend>test form</legend>
View RomaNumber
#include <stdio.h>
#include <string.h>
#define NUM_LEN (100)
int main(void)
{
int i;
int count;
char num[NUM_LEN];
@seka
seka / SocketServerRedis.coffee
Created May 1, 2014
Node.jsのメモリーストアをredisにする場合のsocket.ioとのセッションの共有
View SocketServerRedis.coffee
module.exports = (SessionConfig, app, express) ->
sio = require "socket.io"
# Session Class
Session = express.session.Session
# sessionStore
# new RedisStore()
sessionStore = SessionConfig.getSessionStore().store
@seka
seka / setupAssetMovieContents.swift
Created Oct 31, 2014
AssetLibraryから動画を再生する際の設定 - Setup when playing a video from AssetLibrary (サンプル - Sample)
View setupAssetMovieContents.swift
func setupAssetMovieContents() {
let file = NSURL(string: "assets-library:// ~ hogehuga ~ ")
let assetLibrary = ALAssetsLibrary()
assetLibrary.assetForURL(
file
, resultBlock: {
(asset: ALAsset!) in
if asset != nil {
let rep: ALAssetRepresentation = asset.defaultRepresentation()
View rand.c
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int num;
char c;
printf("乱数の範囲を指定して下さい:");
scanf("%d", &num);
@seka
seka / mongoose-group
Last active Aug 29, 2015
node.jsでmongooseを使っている際、純粋なgroup メソッドを利用する。
View mongoose-group
var mongoose = require("mongoose");
var DBName = "";
M.prototype.connection = mongoose.createConnection("mongodb://127.0.0.1/" + DBName, callback);
var database = M.connection.db
var collection = database.collection("datas");
// keys (object), condition (object), initial (object), reduce (function), finalize (function), [options] (object), callback
collection.group({"id":true}, null, {}, function (curr, result) {
result._id = curr._id;
@seka
seka / Ownd.coffee
Created Apr 18, 2015
Ameba Owndのある記事からデータを抜き出すために作ったスクリプト
View Ownd.coffee
https = require 'https'
async = require 'async'
global = {
url: 'https://api.amebaowndme.com/v2/public/blogPosts?limit=200&page=&siteId=11014&sortType=recent'
}
requestURL = (callback) =>
req = https.get global.url, (res) ->
@res = ""
@seka
seka / sample-cluster.conf
Created Sep 30, 2015
gnatsdのclusterについて, confファイルの設定方法をメモ
View sample-cluster.conf
# クライアントからは以下のようにして接続
# nats://user:password@localhost:4242
port: 4242
authorization {
user: user
password: password
}
# クラスタの設定
cluster {
@seka
seka / setup-nginx.sh
Created Nov 12, 2015
setup script of nginx.
View setup-nginx.sh
# Install
sudo touch /etc/yum.repos.d/nginx.repo
sudo sh -c "cat << 'EOF' > /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
gpgcheck=0
enabled=1
EOF"
sudo yum update -y
@seka
seka / app.coffee
Created Jun 25, 2013
configure class pattern 1
View app.coffee
### ------- Module dependencies. ------ ###
# Webアプリの立ち上げに必要なモジュール
express = require 'express'
cluster = require 'cluster'
app = express()
### ------- Class. -------------------- ###
class AppConfig
setViewEngine : (app, express) ->
app.engine(@template_name, @template)