Skip to content

Instantly share code, notes, and snippets.

public string IP_Parse(string str)
{
const string error_str = "Input error. Invalid IP-address.";
if (split == null)
return error_str;
string[] split = str.Split(new Char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
if (split.Length != 4)
return error_str;
for (int i = 0; i < split.Length; ++i)
use std::collections::HashMap;
fn process_polish(funcs : &HashMap<&str, Box<(Fn(&mut Vec<f32>) -> f32)>>, token : &str, stack : &mut Vec<f32>)
{
if funcs.contains_key(token) {
let val = funcs[token](stack);
stack.push(val);
}else{
let tmp = token.parse::<f32>();
match tmp{
#include <boost/fusion/tuple.hpp>
#include <boost/fusion/view.hpp>
#include <boost/fusion/algorithm.hpp>
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
#include <boost/type_traits.hpp>
#include <boost/mpl/arg.hpp>
#include <boost/lambda/lambda.hpp>
#include <string>
#include <iostream>
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/containers/vector.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
#include<stdio.h>
#include <cstdlib> //std::system
//using namespace boost::interprocess;
typedef boost::interprocess::allocator<float, boost::interprocess::managed_shared_memory::segment_manager> ShmemAllocator;
typedef boost::interprocess::vector<float, ShmemAllocator> DataVector;
int main(int argc, char *argv[])
@Daiver
Daiver / 1
Created January 31, 2013 20:30
typedef boost::interprocess::allocator<float, boost::interprocess::managed_shared_memory::segment_manager> ShmemAllocator;
typedef boost::interprocess::vector<float, ShmemAllocator> DataVector;
DataVector *myvector;
void init_myvector()
{
struct shm_remove
{
shm_remove() { boost::interprocess::shared_memory_object::remove("MySharedMemory"); }
~shm_remove(){ boost::interprocess::shared_memory_object::remove("MySharedMemory"); }
} remover;
typedef boost::interprocess::allocator<float, boost::interprocess::managed_shared_memory::segment_manager> ShmemAllocator;
typedef boost::interprocess::vector<float, ShmemAllocator> DataVector;
DataVector *myvector;
void init_myvector()
{
struct shm_remove
{
shm_remove() { boost::interprocess::shared_memory_object::remove("MySharedMemory"); }
//~shm_remove(){ boost::interprocess::shared_memory_object::remove("MySharedMemory"); }
} remover;
if op == '+':
res = first + second
try:
some()
except:
print(":(")
exit()
def f(arg1, arg2='default'):
print('arg1', arg1)
print('arg2', arg2)
f('one', 'two')
f('one')
f('one', arg2='two')
f(arg1='one', arg2='two')
class A:
def __init__(self, x, y):
self.x = x
self.y = y
def hi(self):
print(self.x, self.y)