Skip to content

Instantly share code, notes, and snippets.

View kovacshuni's full-sized avatar

Hunor Kovács kovacshuni

View GitHub Profile
@kovacshuni
kovacshuni / scala-akka-streams-concurrent-requests.scala
Last active March 22, 2017 17:07
scala-akka-streams-concurrent-requests
Source(List("/", "/docs"))
.map(theUri => HttpRequest(uri = theUri))
.via(Http().outgoingConnection("akka.io").async)
.mapAsyncUnordered(2)(r => r.entity.toStrict(2 seconds))
.map(e => e.data.utf8String)
.fold(List[String]())(_ :+ _)
.runWith(Sink.head)
.onComplete(logger.info("{}", _))
type SomeResource struct {
counter int
}
func (sr *SomeResource) incCounter(rw http.ResponseWriter, r *http.Request) {
sr.counter++
}
func (sr *SomeResource) getCounter(rw http.ResponseWriter, r *http.Request) {
v := strconv.Itoa(sr.counter)
{"attributes":"\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003c!DOCTYPE ObjectMetadata SYSTEM \"/SysConfig/Classify/FTStories/classify.dtd\"\u003e\u003cObjectMetadata\u003e\n \u003cEditorialDisplayIndexing\u003e\n \u003cDILeadCompanies/\u003e\n \u003cDITemporaryCompanies\u003e\n \u003cDITemporaryCompany\u003e\n \u003cDICoTempCode/\u003e\n \u003cDICoTempDescriptor/\u003e\n \u003cDICoTickerCode/\u003e\n \u003c/DITemporaryCompany\u003e\n \u003c/DITemporaryCompanies\u003e\n \u003cDIFTSEGlobalClassifications/\u003e\n \u003cDIStockExchangeIndices/\u003e\n \u003cDIHotTopics/\u003e\n \u003cDIHeadlineCopy\u003eBarclays shares climb as Exane sees good news in history\u003c/DIHeadlineCopy\u003e\n \u003cDIBylineCopy\u003eBryce Elder\u003c/DIBylineCopy\u003e\n \u003cDIFTNPSections/\u003e\n \n \n \u003cDIFirstParCopy\u003eUK stocks slip to their worst weekly perfo
@kovacshuni
kovacshuni / test-server.go
Created September 21, 2017 16:10
test-server
package main
import (
"fmt"
"log"
"net/http"
"net/http/httputil"
"github.com/gorilla/mux"
)
@kovacshuni
kovacshuni / CPU-MIPS.txt
Created September 27, 2017 20:56
CPU-MIPS
Intel i7 5820K 33126 MIPS ~ 2^15 MIPS (million instructions per second) = 2^35 IPS
Intel i7 6700K 25475 MIPS ~ roughly rounding up kind-of gives you the same
@kovacshuni
kovacshuni / feedingPrintingChannels.go
Created December 22, 2017 13:17
feeding-printing-channels
package main
import (
"fmt"
"time"
)
func main() {
q := make(chan string, 1)
@kovacshuni
kovacshuni / githelp.txt
Last active May 14, 2020 15:19
githelp
Don't let me Google that for you
Just ctrl-f this file
# The Git reference:
git checkout --help
# Pushing
# Recommended pushing method
git push <remote> sourceBranch
git push origin master
@kovacshuni
kovacshuni / main.go
Created October 20, 2019 19:02
generate-password-hash-scrypt
package main
import (
"fmt"
"math/rand"
"os"
"time"
"golang.org/x/crypto/scrypt"
)
@kovacshuni
kovacshuni / Typeclasses.scala
Created January 27, 2020 10:54
typeclasses-example
package com.hiya.h4b.cpas.service
import java.time.Instant
import java.time.Instant.now
import akka.http.scaladsl.model.StatusCode
import akka.http.scaladsl.model.StatusCodes.{Created, NotFound, OK}
object Typeclasses extends App {
@kovacshuni
kovacshuni / subtitles-shift-up.rb
Last active August 2, 2020 22:54
subtitles-shift-up
# Appends a new line with a - to every frame of movie subtitles to shift
# the overall position up when the tv cuts down the bottom.
#
# ruby subtitles-shift-up.rb Titanic.srt
# or
# ruby subtitles-shift-up.rb Titanic.srt UTF-8
#
# result: Titanic-shifted.srt
def addEmptyLine(inFile, outFile)