Skip to content

Instantly share code, notes, and snippets.

View straybro's full-sized avatar
🐢
418 I'm a teapot

straybro straybro

🐢
418 I'm a teapot
View GitHub Profile
@straybro
straybro / LazyLoadingProxy.php
Created May 2, 2021 18:47 — forked from treffynnon/LazyLoadingProxy.php
A simple example of using a Lazy Loading Proxy object in PHP. It is useful when attempting to work with legacy code for logging and memory savings when working with global objects..
<?php
/**
* @author Simon Holywell <treffynnon@php.net>
*/
class LazyLoadingProxy {
/**
* Where the instance of the actual class is stored.
* @var $instance object
*/
private $instance = null;
@straybro
straybro / benchmark.clj
Created April 16, 2021 21:36 — forked from luxbock/benchmark.clj
The Little Schemer vs. regular Clojure versions of the Collatz function
(ns little-schemer.benchmark
"Benchmarking the function C of the Collatz Conjencture:
http://en.wikipedia.org/wiki/Collatz_conjecture
in regular Clojure (C*) and as it is defined in the book The Little Schemer,
where all of the parts are defined recursively in terms of add1 and sub1."
(:gen-class)
(:refer-clojure :exclude [even?])
(:require [criterium.core :refer [quick-bench]]))

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@straybro
straybro / objects_arrays.md
Created March 2, 2021 16:33 — forked from nikic/objects_arrays.md
Post explaining why objects often use less memory than arrays (in PHP)

Why objects (usually) use less memory than arrays in PHP

This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)

The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array part of it away. So how does that work?

The key here is that objects usually have a predefined set of keys, whereas arrays don't:

@straybro
straybro / conventional_commit_messages.md
Created December 18, 2020 21:44 — forked from qoomon/conventional-commits-cheatsheet.md
Conventional Commit Messages

Conventinal Commit Messages

See how a minor change to your commit message style can make a difference. Examples

Have a look at CLI util git-conventional-commits to ensure this conventions and generate changelogs

Commit Formats

Default

There are 3 plugins for generating to create a JAR-File in maven:

  • maven-jar-plugin
  • maven-assembly-plugin
  • maven-shade-plugin

maven-jar-plugin:This plugin provides the capability to build and sign jars.But it just compiles the java files under src/main/java and /src/main/resources/.It doesn't include the dependencies JAR files.

<!--exclude all xml files from the jar-->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
@straybro
straybro / System Design.md
Created December 13, 2020 17:29 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@straybro
straybro / fluent-filebeat-comparison.md
Last active December 7, 2020 14:41 — forked from StevenACoffman/fluent-filebeat-comparison.md
Fluentd Fluent-bit FileBeat memory and cpu resources

Fluent-bit rocks

A short survey of log collection options and why you picked the wrong one. 😜

Who am I? Where am I from?

I'm Steve Coffman and I work at Ithaka. We do JStor (academic journals) and other stuff. How big is it?

Number what it means
101,332,633 unique visitors in 2017
@straybro
straybro / Badoo PHP Russia 2019 talk.md
Created November 21, 2020 18:17 — forked from pmurzakov/Badoo PHP Russia 2019 talk.md
Badoo PHP performance -- useful links and snippets -- PHP Russia 2019 talk
@straybro
straybro / gist:65e5d1755719787be96fe8e7a7d3b4c2
Created May 12, 2020 21:52 — forked from mbeale/gist:4247971
Dynamic JSON sample golang #4
type JSONContainer struct {
data []interface{}
}
func (j *JSONContainer) All() (objects []JSONObject) {
for _, v := range j.data {
objects = append(objects, JSONObject{data: v})
}
return
}