Skip to content

Instantly share code, notes, and snippets.

@kolodziej
kolodziej / parser.cpp
Created December 6, 2014 13:20
Cmdline parser
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;
class Parser
{
private:
@kolodziej
kolodziej / Makefile
Last active August 29, 2015 14:10
Shell
CXX=g++
CXXFLAGS=-std=c++11 -g -DDEBUG -Wall
APPSFLAGS=-fPIC -shared
OBJS=shell_main.o shell.o
APPS=concat_application.so echo_application.so
LIBS=-ldl
TARGET=shell
all: $(OBJS) $(APPS)
$(CXX) $(CXXFLAGS) $(OBJS) $(LIBS) -o $(TARGET)
@kolodziej
kolodziej / cyclic_iterator.hpp
Last active August 29, 2015 14:12
cyclic_iterator.hpp
/* CyclicIterator
* Cyclic iterator for STL containers.
* @author Kacper Kołodziej
* @url http://kacperkolodziej.com/
* @email kacper@kolodziej.in
*/
#ifndef CYCLIC_ITERATOR_HPP
#define CYCLIC_ITERATOR_HPP
#include <iterator>
// na początku
#include <algorithm>
#include <string>
std::string str; // w nim masz tekst
std::transform(str.begin(), std.end(), str.begin(), ::tolower);
// taki zabieg dla obu stringów i porównujesz
// jeżeli chcesz zmieniony tekst mieć w drugim stringu, to:
Wezel* a;
Wezel* b;
int tmp = a->dane;
a->dane = b->dane;
b->dane = tmp;
przyklad: przyklad.cpp
g++ przyklad.cpp -o run
g++ przyklad.cpp -o run_o1 -O1
g++ przyklad.cpp -o run_o2 -O2
g++ przyklad.cpp -o run_o3 -O3
suma: suma.cpp
g++ suma.cpp -o suma
g++ suma.cpp -o suma_o1 -O1
g++ suma.cpp -o suma_o2 -O2
<?php
function array_delete(array &$array, $elements) {
//jeśli parametr $elements jest tablicą kluczy do usunięcia
if (is_array($elements)) {
//ile elementów do usunięcia
$toDelete = count($elements);
//ile usunięto poprawnie
$deleted = 0;
foreach ($elements as $index) {
if (unset($array[$index])) $deleted++;
<?php
class Collection implements ArrayAccess, Iterator, Countable
{
private $_data = array();
private $_strict;
protected $_pointer = 0;
const SEPARATOR = ':';
#!/bin/bash
a=$1
b=$2
c=$3
istnieje=true
if [ $(($a+$b)) -le $c ]; then
echo "Warunek $a + $b > $c nie jest spełniony!"
#!/bin/bash
a=$1
b=$2
c=$3
istnieje=false
if [ $(($a+$b)) -gt $c ]; then
if [ $(($b+$c)) -gt $a ]; then