Skip to content

Instantly share code, notes, and snippets.

View mahmoudimus's full-sized avatar
💭
@_@

Mahmoud Rusty Abdelkader mahmoudimus

💭
@_@
View GitHub Profile
@mahmoudimus
mahmoudimus / JavaScript Members Not Bound to Instances.md
Created January 17, 2022 21:54 — forked from dfoverdx/JavaScript Members Not Bound to Instances.md
Why JavaScript class members are not automatically bound to the instance of the class

It took a few years, but I finally understand why member functions of classes in JavaScript aren't automatically bound to their objects, in particular when used in callback arguments.

In most object-oriented languages, functions are members of a class--they exist in memory only once, and when they are called, this is simply a hidden argument of the function which is assigned to the object that's calling it. Python makes this explicit by requiring that the first argument of a class's member function be self (Python's equivalent of this--you can name self whatever you want, but self is the convention).

class MyClass:
@mahmoudimus
mahmoudimus / noargs_setters_builders.md
Created December 1, 2021 07:53 — forked from androidfred/noargs_setters_builders.md
Stop using noargsconstructors and setters (and builders)

Stop using noargsconstructors and setters (and builders)

TLDR summary

Noargsconstructors and setters are outdated, 90's style old school Java. They needlessly allow entire categories of defects that are easily avoided by using only allargsconstructors and no setters. Please stop writing code like that.

Longer version

How many times have you come across (or written) code like this

public class User {
@mahmoudimus
mahmoudimus / idea.properties
Created September 28, 2021 20:47 — forked from lmgeorge/idea.properties
Jetbrains IDE vmoptions template
# Use ${idea.home.path} macro to specify location relative to IDE installation home.
# Use ${xxx} where xxx is any Java property (including defined in previous lines of this file) to refer to its value.
# Note for Windows users: please make sure you're using forward slashes: C:/dir1/dir2.
ide.app.name=webstorm
ide.config.home=${user.home}/.jetbrains/${ide.app.name}
#---------------------------------------------------------------------
# Uncomment this option if you want to customize a path to the settings directory.
#---------------------------------------------------------------------
idea.config.path=${ide.config.home}/config
@mahmoudimus
mahmoudimus / split-pull-requests.md
Created September 12, 2021 19:13 — forked from loilo/split-pull-requests.md
Split a large pull request into two

Quick Tips for Fast Code on the JVM

I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.

This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea

-Xms16m
-Xmx6G
-XX:ReservedCodeCacheSize=420m
-XX:+UseNUMA
-XX:+UseG1GC
-XX:ConcGCThreads=2
-XX:+G1UseAdaptiveIHOP
-XX:+UseGCOverheadLimit
-XX:MaxMetaspaceSize=2G
-XX:+ParallelRefProcEnabled
@mahmoudimus
mahmoudimus / 0: jvm-options-java8.conf
Created June 14, 2021 17:16 — forked from elifarley/0: jvm-options-java8.conf
JVM options to maximize performance
# See https://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html
# See https://docs.oracle.com/javase/8/docs/technotes/guides/vm/performance-enhancements-7.html
# See https://docs.oracle.com/javase/8/embedded/develop-apps-platforms/codecache.htm
# See http://normanmaurer.me/blog_in_progress/2013/11/07/Inline-all-the-Things/
# See http://stas-blogspot.blogspot.com.br/2011/07/most-complete-list-of-xx-options-for.html
# -XX:+LogCompilation
# -XX:+PrintInlining
-Dfile.encoding=UTF-8
#!/usr/bin/env awk -f
# Based on the idea from https://blogs.oracle.com/taylor22/entry/using_r_to_analyze_g1gc, the
# script is updated to use the format of the gc logs as received with the parameters:
# -XX:+UseThreadPriorities
# -XX:ThreadPriorityPolicy=42
# -Xms1995M -Xmx1995M
# -Xss256k -XX:StringTableSize=1000003
# -XX:SurvivorRatio=8
# -XX:MaxTenuringThreshold=1
@mahmoudimus
mahmoudimus / all.txt
Created May 17, 2021 02:44 — forked from jhaddix/all.txt
all wordlists from every dns enumeration tool... ever. Please excuse the lewd entries =/
This file has been truncated, but you can view the full file.
.
..
........
@
*
*.*
*.*.*
🐎
@mahmoudimus
mahmoudimus / convert to pkcs 8.md
Created April 8, 2021 18:31 — forked from markscottwright/convert to pkcs 8.md
How to convert a java private key from PKCS#1 encoding to PKCS#8

I had some historical key material data in pkcs#1 format that needed to be in pkcs#8 for input into another system. Here's how to do it, using BouncyCastle:

import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.DERObject;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import java.security.PrivateKey;