Skip to content

Instantly share code, notes, and snippets.

class Subject
{
public:
virtual void execute() = 0;
};
class RealSubject: public Subject
{
string str;
public:
#include <iostream>
using namespace std;
// 1. "lowest common denom"
class Widget
{
public:
virtual void draw() = 0;
};
@alexprivalov
alexprivalov / work_with_struct.c
Created January 31, 2015 18:21
for test task
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ALIAS_QUANTITY 10
struct aliasID
{
char* alias; /* '\0'-terminated C string */
int specific_id;
Queries for create all needed tables:
create table if not exists customers(customer_id integer primary key, customer_login text, customer_name text, unique(customer_login))
create table if not exists goods(good_id integer, good_description text, unique(good_id))
create table if not exists orders(order_id integer primary key, customer_id integer, good_id integer, unique(order_id, customer_id, good_id))
Queries to populate tables:
insert into customers(customer_login, customer_name) values("user_login1", "customer_name1")
insert into customers(customer_login, customer_name) values("user_login2", "customer_name2")
@alexprivalov
alexprivalov / pointer_on_function.c
Created January 31, 2015 18:34
Write a “C” function that modifies each element of a user supplied array by applying a user-provided function to each element of an array of integers. The user-provided function can also accept parameters. Please provide a typedef for the user-provided function.
#include <stdio.h>
typedef void (*func_handler)(int *p_arr_item); //typedef for user defined function
void func_for_processing_array(int arr[], size_t arr_size, func_handler h);
void do_something_with_item(int *p_item);
int main(int argc, char **argv)
{
int test_arr[] = {23, 32, 43, 54, 2, 86, 90};
@alexprivalov
alexprivalov / array_to_double-linked_list.c
Created January 31, 2015 18:36
Write a “C” function to convert an array to a doubly-linked list.
#include <stdio.h>
#include <stdlib.h>
struct DoubleLinkedListItem //item of linked list
{
int field;
struct DoubleLinkedListItem *p_prev;
struct DoubleLinkedListItem *p_next;
};
//Reverse characters in a string:
void reverse(char* s)
{
int i;
char temp;
size_t l = strlen(s);
for (i = 0; i < (l/2); ++i) {
temp = s[i];
s[i] = s[l - i];
/**
Handle multiple socket connections with select and fd_set on Linux
Silver Moon ( [email protected])
*/
#include <stdio.h>
#include <string.h> //strlen
#include <stdlib.h>
#include <errno.h>
Title : Revisiting Mac OS X Kernel Rootkits
Author : fG!
Date : April 18, 2014
|=----------------------------------------------------------------------------=|
|=----------------=[ Revisiting Mac OS X Kernel Rootkits ]=-------------------=|
|=----------------------------------------------------------------------------=|
|=------------------------=[ fG! <[email protected]> ]=---------------------------=|
|=----------------------------------------------------------------------------=|
DOCKER
docker run -t -i ubuntu /bin/bash
docker run -t -v /home/alex/local_work/SDK-16.4-work/:/broadcom_arm -i ubuntu /bin/bash
docker rm `docker ps -aq` - remove all stopped containers
sudo docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs sudo docker rm
docker start -a -i $container_id - run last commant in exited container
=========RUN stopped/exited container ===========
http://stackoverflow.com/a/39329138