Skip to content

Instantly share code, notes, and snippets.

View ateleshev's full-sized avatar
🏠
Working from home

Artem Teleshev ateleshev

🏠
Working from home
View GitHub Profile
# Makefile for a go project
#
# Author: Jon Eisen
# site: joneisen.me
#
# Targets:
# all: Builds the code
# build: Builds the code
# fmt: Formats the source files
# clean: cleans the code
<?php
// Doc Home - http://devel-m6w6.rhcloud.com/mdref/http
$url = 'http://php.net';
// ## Simple single Get
$req = new \http\Client\Request('GET', $url);
$client = (new \http\Client())
->enqueue($req)
->send();

Easy pthreads Pools

The final solution !!

Since the first version of pthreads, PHP has had the ability to initialize Worker threads for users. Onto those Worker threads are stacked objects of class Stackable for execution concurrently.

The objects stacked onto workers do not have their reference counts changed, pthreads forces the user to maintain the reference counts in userland, for the extremely good reason that this enables the programmer to keep control of memory usage; and so, execute indefinitely.

This is the cause of much heartache for newcomers to pthreads; if you do not maintain references properly you will, definitely, experience segmentation faults.

@ateleshev
ateleshev / gist:7dbd9bdb4f146fe59bd0
Created November 4, 2015 09:17 — forked from momer/grpc_with_reconnect.go
A pattern I created to maintain connections to an RPC server in Go. Since net/rpc does not provide any methods for automatically reconnecting to an RPC server, I needed a work-around. Additionally, rpc.Client does not export any state variables (rpc.Client.shutdown and rpc.Client.closing) nor does it export the Client's Mutex. So, we wrap the rp…
package main
import (
"myapp/webserver/app/common"
"github.com/golang/glog"
"github.com/gorilla/mux"
"encoding/json"
"strconv"
"flag"
"fmt"
@ateleshev
ateleshev / introrx.md
Created November 10, 2015 11:45 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@ateleshev
ateleshev / go-chan-test.go
Last active February 26, 2016 13:13 — forked from atotto/chan_test.go
golang channel benchmark
package chan_test
import (
"testing"
)
func BenchmarkStructChan(b *testing.B) {
ch := make(chan struct{})
go func() {
for {
@ateleshev
ateleshev / php-pthreads.md
Last active February 26, 2016 13:13 — forked from krakjoe/pthreads.md
php-pthreads.md

Multi-Threading in PHP with pthreads

A Brief Introduction to Multi-Threading in PHP

  • Foreword
  • Execution
  • Sharing
  • Synchronization
  • Pitfalls
@ateleshev
ateleshev / sshtunnel.go
Created July 27, 2016 09:54 — forked from iamralch/sshtunnel.go
SSH tunnelling in Golang
package main
import (
"log"
"bufio"
"time"
"os"
"fmt"
"io"
"net"
@ateleshev
ateleshev / join_test.go
Created August 11, 2016 15:57 — forked from dtjm/join_test.go
strings.Join vs fmt.Sprintf vs string concat (+)
package join
import (
"fmt"
"strings"
"testing"
)
var (
testData = []string{"a", "b", "c", "d", "e"}
// func GetCpuForThread() uint64
TEXT ·GetCpuForThread(SB),7,$0
MOVQ $0xB,AX
XORQ CX,CX
CPUID
MOVQ DX,ret+0(FP)
RET