Skip to content

Instantly share code, notes, and snippets.

View evandertino's full-sized avatar
🎧
In the zone

Evander Otieno evandertino

🎧
In the zone
  • Foursquare
  • Nairobi, Kenya
View GitHub Profile
@DaveDeCaprio
DaveDeCaprio / gist:4db9d36a5e907fb5810c00e919347aa3
Created January 12, 2018 19:10
Lagom websockets client using Akka HTTP
import java.net.URI
import java.util.Locale
import akka.NotUsed
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.headers.RawHeader
import akka.http.scaladsl.model.ws._
import akka.http.scaladsl.model.{HttpHeader, Uri}
import akka.stream.ActorMaterializer
@OlegIlyenko
OlegIlyenko / Event-stream based GraphQL subscriptions.md
Last active May 28, 2024 17:41
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

@turtlemonvh
turtlemonvh / multiPort.py
Created July 30, 2014 13:16
Middleware for running django on multiple ports
from django.conf import settings
class MultiPortMiddleware(object):
"""
Middleware changes the SESSION_COOKIE_NAME to use the current port in the name
"""
def process_request(self, request):
settings.SESSION_COOKIE_NAME = 'sessionid' + request.META['SERVER_PORT']
@momer
momer / grpc_with_reconnect.go
Last active February 7, 2024 00:44
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"
@staltz
staltz / introrx.md
Last active June 26, 2024 10:24
The introduction to Reactive Programming you've been missing
@rponte
rponte / GenerateSimplePdfReportWithJasperReports.java
Last active May 7, 2022 10:25
Example on how to generate a simple pdf report with JasperReports
package rponte.report;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import net.sf.jasperreports.engine.JRException;
@nf
nf / hello-node.js
Created July 6, 2012 21:14
Hello world web server that scales across multiple processors
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', function(worker, code, signal) {
@szinck
szinck / database.py
Created May 23, 2012 04:56
sqlalchemy reflection
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine("postgresql://user:@host/schema")
Base = declarative_base()
Base.metadata.reflect(engine)
@fernandoaleman
fernandoaleman / Linux Static IP
Created March 23, 2012 16:20
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@jboner
jboner / Transactors: Actors and STM
Created July 30, 2009 14:37
Transactors: Actors + STM
Transactors: Actors + STM
Actors are excellent for solving of problems where you have many independent processes
that can work in isolation and only interact with other Actors through message passing.
This model fits many problems. But the actor model is unfortunately a terrible model for
implementing truly shared state. E.g. when you need to have consensus and a stable view of
state across many components. The classic example is the bank account to clients to
deposits and withdrawals in which each operation needs to be atomic. For detailed
discussion on the topic see this JavaOne presentation:
http://www.slideshare.net/jboner/state-youre-doing-it-wrong-javaone-2009.