Skip to content

Instantly share code, notes, and snippets.

View Solution's full-sized avatar
🎯
Focusing

Patrik Tomášik Solution

🎯
Focusing
View GitHub Profile
@Solution
Solution / gist:1271278
Created October 7, 2011 20:25
Playing with sockets
/*
* File: main.cpp
* Author: patrik
*
* Created on October 7, 2011, 12:14 PM
*/
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
@Solution
Solution / gist:1306541
Created October 22, 2011 22:04
Price
<?php
function cutPrice($price, $delimiter = 3)
{
$pieces = array_reverse(str_split(strrev($price), $delimiter));
(string)$fprice = null;
(int)$i = 0;
foreach($pieces as $piece)
{
if($i == 0)
{
@Solution
Solution / Regpx.h
Created November 11, 2011 20:20
My C version of preg_match()
/*
* File: Regxp.h
* Author: solution
*
* Created on 11. listopad 2011, 16:00
*/
#include <stdio.h>
#include <string.h>
#include <pcre.h>
@Solution
Solution / conf
Created January 26, 2012 19:42
conf
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on; ## listen for ipv6
root /var/www/www;
index index.php index.html index.htm;
server_name localhost;
#server_name _;
access_log /var/log/nginx/localhost.access.log;
@Solution
Solution / DoctrineExtension.php
Last active July 3, 2019 22:16
Gedmo extension for Kdyby\Doctrine and some changes in Gedmo\DoctrineExtensions
<?php
namespace Gedmo;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\ORM\Mapping\Driver as DriverMappingORM;
use Doctrine\Common\Persistence\Mapping\Driver as DriverORM;
use Doctrine\ODM\MongoDB\Mapping\Driver as DriverMongodbODM;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Annotations\CachedReader;
@Solution
Solution / simpleGrupttorExample.go
Created December 9, 2018 12:58
Simple grupttor example
package main
import (
"fmt"
"github.com/PragGoLabs/grupttor"
"github.com/PragGoLabs/grupttor/handlers"
"github.com/PragGoLabs/grupttor/hooks"
"os"
"syscall"
"time"
@Solution
Solution / definition.go
Created December 9, 2018 13:11
consumer definition
func() {
// create consumer
c := consumer.NewConsumer(q, facade)
ch, _ := amqpSession.GetConnection().Channel()
interruptor := grupttor.NewGrupttor(
handlers.NewAmqpHandler(
ch,
q.GetTag(),
),
@Solution
Solution / consumerUpper.go
Last active December 9, 2018 13:17
Upper part of consumer
func (c Consumer) Consume(interruptor *grupttor.Grupttor) q.ConsumeFunc {
return func(deliveries <-chan amqp.Delivery, done chan error) {
defer func() {
if r := recover(); r != nil {
err := errors.New(fmt.Sprintf("internal goroutine paniced: %v", r))
log.Error(err)
// print out the stack
log.Error(string(debug.Stack()))
@Solution
Solution / requestFactory.go
Created December 13, 2018 21:32
Simple request factory
package client
import (
"net/http"
"strings"
"github.com/pkg/errors"
)
type RequestFactory struct {
schema Schema
package client
import (
"encoding/json"
"fmt"
"io/ioutil"
"github.com/Solution/go-httpwares"
"github.com/Solution/go-httpwares/metrics"
"github.com/Solution/go-httpwares/tags"