Skip to content

Instantly share code, notes, and snippets.

View aslrousta's full-sized avatar
🤔
Fixing Bugs

Ali AslRousta aslrousta

🤔
Fixing Bugs
View GitHub Profile

Keybase proof

I hereby claim:

  • I am aslrousta on github.
  • I am aslrousta (https://keybase.io/aslrousta) on keybase.
  • I have a public key ASAqAudCM1mbROTXnMAJGNHNqDAjIy2IA8ydOmFiZFrROAo

To claim this, I am signing this object:

@aslrousta
aslrousta / replicate.c
Last active June 18, 2018 18:07
Process Replication
#include <sys/types.h>
#include <unistd.h>
/* Holds the path to the process's executable file.
Copied from `argv[0]` in the `main` function. */
extern const char* prog_path;
/* Replicates the current process. */
int replicate(void)
{
@aslrousta
aslrousta / Dockerfile
Last active June 15, 2018 11:34
Sample Dockerfile for Go projects.
FROM golang:alpine AS builder
RUN apk --no-cache --update add git
RUN go get ... \
&& go get ... \
&& go get github.com/ddollar/forego
COPY . src/gitlab.com/example.com/auth
RUN cd src/gitlab.com/example.com/auth \
&& go build \
@aslrousta
aslrousta / OptimisticTransaction.php
Last active June 1, 2024 03:41
Optimistic Locking for Transaction
<?php
function transfer($fromAccountId, $toAccountId, $balance)
{
$fromQuery = Account::whereId($fromAccountId);
if (! $fromQuery->exists()) {
throw new InvalidAccountException();
}
$toQuery = Account::whereId($toAccountId);
@aslrousta
aslrousta / PessimistTransaction.php
Last active June 1, 2024 03:50
Pessimistic Locking for Transaction
<?php
function transfer($fromAccountId, $toAccountId, $amount)
{
DB::beginTransaction();
try {
$fromQuery = Account::whereId($fromAccountId);
if (! $fromQuery->exists()) {
throw new InvalidAccountException();