Skip to content

Instantly share code, notes, and snippets.

@barron9
barron9 / cleanse.swift
Created October 29, 2021 16:32
cleanse_swift_subcomponent_injection(modules).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 September 17, 2021 02:31
HowToMemoryLeakInJava
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");
@Singleton
class HTTPClient{
private HttpRequest request;
private HttpClient client;
private LoggerM logger;
@Inject
HTTPClient(LoggerM logger) {
@barron9
barron9 / go-nginx.md
Created July 6, 2021 14:32 — forked from yosssi/go-nginx.md
Go networking performance vs Nginx

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 July 4, 2021 16:29 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples

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 July 4, 2021 14:50 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
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])
}
import Foundation
actor BankAccount {
let accountNumber: Int
var balance: Double
init(accountNumber: Int, initialDeposit: Double) {
self.accountNumber = accountNumber
self.balance = initialDeposit
}
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) ")
}
class Free : Package {
override func setPrice(price : Int64)throws ->Int64 {
return 0 //weakened post condition
}
}