Skip to content

Instantly share code, notes, and snippets.

View atimin's full-sized avatar
🎯
Focusing

Alexey Timin atimin

🎯
Focusing
View GitHub Profile
@atimin
atimin / Example use pthread in C
Created August 7, 2009 14:32
Work with pthread in C
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void *start_routine(void *arg)
{
int *i = (int *)arg;
while(*i< 10) {
sleep(1);
@atimin
atimin / gist:862474
Created March 9, 2011 16:14
Пример приемов метапрограммирования на Ruby
class HashStub
# Значения атрибутов хранятся в хэше @data который
# инициализируется при создании объекта
def initialize
@data = {}
end
# Наша реализация method_missing
# name - имя метода который был не найден
# args - аргументы вызова метода собранные в массив
@atimin
atimin / Получение изображения с камеры
Created April 3, 2011 05:01
Простой пример захвата изображения с камеры и вывод его на экран, с помощью библиотеки python-opencv
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from opencv import cv
from opencv import highgui
DEV = 0 #номер устройства /dev/video0
if __name__ == '__main__':
# Создаем окно для вывода изображения с камеры
@atimin
atimin / SimpleOPCClient_v2.cpp
Created August 3, 2011 11:39
Simple OPC Client
////////////////////////////////////////////////////////////////////////
// project: SimpleOPCClient
// version: 2
//
// subject: this is a simple OPC Client that read the value of an item
// from an OPC server.
//
// file: SimpleOPCClient.cpp
//
// writer: Philippe GRAS - CERN / EP
@atimin
atimin / dsl.rb
Created October 14, 2011 06:37
Example description XPCA application
# http://xpca.org
# Timin Aleksey 2011
template :analog_point do
min_raw 0
max_raw 0xffff
min_scale 0
max_scale 100
end
@atimin
atimin / example_rmodbus.rb
Created October 16, 2011 04:41
Example RModBus
require 'rmodbus'
ModBus::TCPClient.new('127.0.0.1', 8502) do |cl|
cl.with_slave(1) do |slave|
# Read a single holding register at address 16
slave.holding_registers[16]
# Write a single holding register at address 16
slave.holding_registers[16] = 123
# Read holding registers 16 through 20
@atimin
atimin / sun_system.rb
Created October 17, 2011 07:17
Example for Lipa
require 'lipa'
un = root :universe do
kind :planet_system do
num_planet run{
count = 0
children.values.each do |planet|
count += 1 if planet.kind == :planet
end
count
@atimin
atimin / xpca_modbus
Created October 17, 2011 09:46
Example XPCA gateway for ModBus
#!/usr/bin/env ruby
=begin
It's very simple example of implementation
REST-PCA gateway
for communication with TCP ModBus devices
It receives REST requests
(e.g http://127.0.0.1:4567/mb/127.0.0.1/8502/1/coils/6/17 )
and returns data in JSON format addr : data:
{"coils": {
"6":{
@atimin
atimin / access_lipa.rb
Created October 17, 2011 17:35
Lipa release-0.2.0
Lipa::Tree["tree://dir_1/dir_2/file_1"].size
#or
tree["dir_1/dir_2/file_1"].size
#or
tree.dir_1.dir_2.file_1.size
@atimin
atimin / fixed_bunch.rb
Created October 19, 2011 18:46
Lipa release-0.2.1
t = Lipa::Tree.new :tree do
kind :some_kind, :for => :node
with :attr_1 => 999 do
some_kind :obj_1
end
end