Skip to content

Instantly share code, notes, and snippets.

@barron9
barron9 / wakefix.service
Last active May 5, 2023 13:33
ubuntu 22.04 a4tech fstyler wireless keyboard wake fix service
View wakefix.service
[Unit]
Description=Run script after screen unlock/wake
After=sleep.target
After=suspend.target
[Service]
User=root
Type=oneshot
ExecStart=/home/berkin/wakefix.sh
@barron9
barron9 / 2.py
Last active March 17, 2023 10:39
generative network with dense layers
View 2.py
from keras.models import Model
from keras.layers import Input, Dense
from keras.optimizers import Adam
# Define the input layer
inputs = Input(shape=(784,))
# Define the hidden layers
hidden1 = Dense(128, activation='relu')(inputs)
hidden2 = Dense(64, activation='relu')(hidden1)
@barron9
barron9 / deadlock.c
Last active November 16, 2022 21:49
deadlock example
View deadlock.c
#include <stdio.h>
#include <pthread/pthread.h>
void* someprocess(void* arg);
void *anotherprocess(void* arg);
pthread_mutex_t lock;
pthread_t tid[2];
int counter;
int main(int argc, const char * argv[]) {
@barron9
barron9 / cleanse.swift
Created October 29, 2021 16:32
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 September 17, 2021 02:31
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 July 6, 2021 14:32 — 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 July 4, 2021 16:29 — 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 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
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])
}