Skip to content

Instantly share code, notes, and snippets.

@barron9
barron9 / cleanse.swift
Created Oct 29, 2021
cleanse_swift_subcomponent_injection(modules).swift
View cleanse.swift
import Foundation
import Core
import Cleanse
public class FeatureX{
public init(){
// _ = CoreDummy()
let f = try! ComponentFactory.of(APIComponent.self)
RootViewController2(loggedInComponent: f)
@barron9
barron9 / HowToMemoryLeakInJava.java
Last active Sep 17, 2021
HowToMemoryLeakInJava
View HowToMemoryLeakInJava.java
import java.util.ArrayList;
import java.util.List;
class Custom{
private String name;
Custom(String name){
this.name = name;
}
protected void finalize(){
// System.out.println("gc'd");
View httpclient_async_test.java
@Singleton
class HTTPClient{
private HttpRequest request;
private HttpClient client;
private LoggerM logger;
@Inject
HTTPClient(LoggerM logger) {
@barron9
barron9 / go-nginx.md
Created Jul 6, 2021 — forked from yosssi/go-nginx.md
Go networking performance vs Nginx
View go-nginx.md

1. Nginx

$ wrk -t12 -c400 -d2s http://127.0.0.1:8080
Running 2s test @ http://127.0.0.1:8080
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     7.71ms    3.16ms  23.05ms   69.17%
    Req/Sec     3.44k     1.98k    7.80k    58.22%
  63697 requests in 2.00s, 17.86MB read
@barron9
barron9 / golang-tls.md
Created Jul 4, 2021 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
View golang-tls.md

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@barron9
barron9 / main.go
Created Jul 4, 2021 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
View main.go
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
View test.swift
let accounts = [BankAccount(accountNumber: 1,initialDeposit: 100),BankAccount(accountNumber: 2,initialDeposit: 100),]
let q0 = DispatchQueue(label: "queue0", attributes: .concurrent)
q0.async
{
do {
accounts.forEach {
account in
async {
try await account.transfer(amount: 1, to: accounts[1])
}
View actortest.swift
import Foundation
actor BankAccount {
let accountNumber: Int
var balance: Double
init(accountNumber: Int, initialDeposit: Double) {
self.accountNumber = accountNumber
self.balance = initialDeposit
}
View liskovtest.swift
class test{
//takes package parent class
init(package: Package,price :Int64) {
do{
try 8 * 100/package.setPrice(price:price)
print("done")
}catch {
print("price value must be greater than 0 _ \(price) ")
}
View liskov1.swift
class Free : Package {
override func setPrice(price : Int64)throws ->Int64 {
return 0 //weakened post condition
}
}