This file contains hidden or 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
# encoding: utf-8 | |
require 'redis' | |
require 'mongo' | |
def mongo2redis | |
redis = Redis.new | |
redis.flushall | |
connection = Mongo::Connection.new |
This file contains hidden or 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
require 'active_record' | |
ActiveRecord::Base.establish_connection( | |
:adapter => 'sqlite3', | |
:database => 'db/hatena.db' | |
) | |
class EntryInit < ActiveRecord::Migration | |
def self.up | |
create_table(:entries) do |t| |
This file contains hidden or 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
#------------------------------------------------- | |
# | |
# Project created by QtCreator 2013-03-14T00:52:51 | |
# | |
#------------------------------------------------- | |
QT += core gui | |
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets |
This file contains hidden or 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
#include "mainwindow.h" | |
#include "ui_mainwindow.h" | |
#include <QLayout> | |
#include <QVTKWidget.h> | |
#include <vtkRenderer.h> | |
#include <vtkRenderWindow.h> | |
MainWindow::MainWindow(QWidget *parent) : |
This file contains hidden or 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
require 'opencv' | |
capture = OpenCV::CvCapture.open | |
mat = capture.query.to_CvMat | |
mat.save('output.jpg') |
This file contains hidden or 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
def ping(ip) | |
r = Regexp.new('[1-9]\d* (packets )?received') | |
result = r.match(`ping -c 1 -W 1 #{ip}`) | |
result != nil | |
end | |
def arp(ip) | |
r = Regexp.new('[0-f]+:[0-f]+:[0-f]+:[0-f]+:[0-f]+:[0-f]+') | |
result = r.match(`arp -n #{ip}`) | |
result ? result.to_s : nil |
This file contains hidden or 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
# 最初は前提ソフトウエアのインストール | |
sudo apt-get -yV install build-essential | |
# | |
cd /tmp; sudo apt-get source opencv | |
sudo apt-get -yV build-dep opencv | |
# | |
sudo apt-get -yV install opencl-headers | |
# | |
sudo apt-get -yV install libjpeg-dev | |
sudo apt-get -yV install libopenjpeg-dev |
This file contains hidden or 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
<div class="pagination"> | |
<ul> | |
<?php echo $this->Paginator->prev(__('prev'), array('tag' => 'li'), null, array('tag' => 'li','class' => 'disabled','disabledTag' => 'a')); ?> | |
<?php echo $this->Paginator->numbers(array('separator' => '','currentTag' => 'a', 'currentClass' => 'active','tag' => 'li','first' => 1, 'ellipsis' => '<li class="disabled"><a>...</a></li>')); ?> | |
<?php echo $this->Paginator->next(__('next'), array('tag' => 'li','currentClass' => 'disabled'), null, array('tag' => 'li','class' => 'disabled','disabledTag' => 'a')); ?> | |
</ul> | |
</div> |
This file contains hidden or 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
require 'opencv' | |
require 'em-websocket' | |
require 'base64' | |
class WebCam | |
def initialize(n = 0) | |
@cap = OpenCV::CvCapture.open(n) | |
end | |
def get_with_base64 |
This file contains hidden or 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
import Adafruit_BBIO.PWM as PWM | |
servo_pin = "P8_13" | |
duty_min = 3 | |
duty_max = 14.5 | |
duty_span = duty_max - duty_min | |
PWM.start(servo_pin, duty_min, 60.0) | |
while True: |