Skip to content

Instantly share code, notes, and snippets.

View banerRana's full-sized avatar

Rana Banerjee banerRana

  • Automated It Solutions
  • Washington, DC
View GitHub Profile
Optionals.ifPresentOrElse(opt, System.out::println,
() -> System.out.println("not present"));
@zivce
zivce / ifNotPresent_WrongApproach.java
Last active February 17, 2022 14:16
How to not create ifNotPresent in Java
Optional.of(opt).map(value -> { System.out.println(value);
return value; })
.orElseGet(() -> { System.out.println("not present");
return -1;});
@wwerner
wwerner / docker-tomcat_remote-debugging.adoc
Last active June 3, 2021 18:16
Set up remote debugging for Tomcat in Docker

Set up remote debugging in dockerized Tomcat

Start Container, stock tomcat 8.5 in this example
$  docker run \
    -eJPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=n" \
    -p8080:8080 \
// Primitive hash function that for a string returns a positive 32 bit int
// Do not use in production, use murmur3 or fnv1
// You can improve this by changing 5 to 31
Object.defineProperty(String.prototype, 'hashCode', {
value: function() {
var hash = 0, i, chr;
for (i = 0; i < this.length; i++) {
chr = this.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
@johnpmitsch
johnpmitsch / a.md
Last active June 25, 2024 17:10
Bradfield CS Distributed Systems

Distributed Systems

Lesson 1 - Introduction

  • Systems today are generally distributed, both in-house and third-party systems
  • Stream processing is batch processing but in smaller increments, it isn't real-time, but is quick
  • Project, work as pre and post work
  • Reliability
  • Scalability
  • Maintainability
@bennadel
bennadel / test.cfm
Created April 28, 2020 11:35
Creating A Partially-Transparent Overlay Using GraphicsMagick And Lucee CFML 5.2.9.31
<cfscript>
startedAt = getTickCount();
inputFilepath = expandPath( "../images/beach-small.jpg" );
// In the first approach to drawing a partially-transparent image over another, we're
// going to create an intermediary image that represents the image overlay. This will
// the SCALED and PARTIALLY-TRANSPARENT image.
// --
@clrung
clrung / clone_all_repos.sh
Last active December 11, 2023 14:34
Clones all repos in a GitHub organization
#!/bin/bash
# Usage: clone_all_repos.sh [organization] <output directory>
ORG=$1
PER_PAGE=100
GIT_OUTPUT_DIRECTORY=${2:-"/tmp/${ORG}_repos"}
if [ -z "$GITHUB_TOKEN" ]; then
echo -e "Variable GITHUB_TOKEN isn't set! Please specify your GitHub token.\n\nMore info: https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/"
exit 1
@coolreader18
coolreader18 / segfault.py
Last active March 30, 2024 08:05
CPython segfault in 5 lines of code
class E(BaseException):
def __new__(cls, *args, **kwargs):
return cls
def a(): yield
a().throw(E)

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

@mistermichaelll
mistermichaelll / m1_googlesheets.R
Last active April 11, 2024 00:59
Entire script for my small M1 Finance project.
# ==================================================================================
# M1 Finance/Google Sheets Tracker
# --------------------------------
# Author: Michael Johnson
# Last updated: May 25, 2020
#
# This script works in tandem with a Python script to easily
# access and update information relating to my M1 Finance portfolio
# in a Google Sheet.
#