Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View wesleyegberto's full-sized avatar
🎯
Exploring

Wesley Egberto wesleyegberto

🎯
Exploring
View GitHub Profile
@rmpestano
rmpestano / Jenkinsfile.adoc
Last active April 23, 2019 21:46
Java maven jenkinsfile
pipeline {
    agent any
    tools {
        maven 'apache-maven-3.3.9'
        jdk 'jdk1.8'
    }
    stages {
        stage('Build') {
            steps {
@jeremypruitt
jeremypruitt / sns-publish
Last active August 19, 2022 18:09
AWS Lambda function to publish to SNS topic
console.log('Loading function');
var AWS = require('aws-sdk');
AWS.config.region = 'us-west-2';
exports.handler = function(event, context) {
console.log("\n\nLoading handler\n\n");
var sns = new AWS.SNS();
sns.publish({
@luizgpsantos
luizgpsantos / Exemplo completo
Last active November 25, 2022 23:27
Analyzer para plural e acentos no elasticsearch
// Ao [criar o índice][0], especifique um [analyzer customizado][1] responsável por tratar palavras
// com caracteres especiais e o plural da lingua Portuguesa. Algumas palavras precisarão de uma
// sintonia fina, o que pode ser feito através de [stemmer overrides][2]. Além disso, ao criar um
// campo atribua o analyzer a ele.
PUT produtos
{
"settings": {
"analysis": {
"analyzer": {
@MarquisLP
MarquisLP / pygame_test.py
Last active December 3, 2022 17:50
A simple game loop for testing PyGame code.
"""This module contains all of the necessary PyGame components for
running a simplified game loop.
Use it for test cases on PyGame-related code.
"""
import sys
import pygame
from pygame.locals import *
# Import additional modules here.
@trongthanh
trongthanh / mojave.xml
Last active January 26, 2023 19:04
macOS Mojave dynamic background re-implement as GTK+ background slideshow. Background images are changed to reflect the time of the day.
<!-- Instructions:
- Download and unzip Mojave dynamic background here: https://files.rb.gd/mojave_dynamic.zip
- Rename the extracted folder as "mojave-background" (Excuse the trouble but I renamed it on my machine and already use that path in the XML file)
- Save this xml file next to the Mojave background files
- Fix the path to the background images below (better using absolute path)
- Lastly, either:
+ GNOME: Use gnome-tweaks tool to select this XML as wallpaper (as default wallpaper settings won't let you choose wallpaper from custom path)
+ MATE: Go to background setting (in Appearance) > Choose +Add... > make sure **All files** filter is selected at the bottom right > Then choose mojave.xml
-->
<background>
from pyspark.sql.functions import col, explode_outer, from_json, lit, concat
from pyspark.sql.types import StructType, ArrayType
def get_json_df(input_df, primary_partition_column, json_column_name, spark_session):
'''
Description:
This function provides the schema of json records and the dataframe to be used for flattening
:param input_df: [type: pyspark.sql.dataframe.DataFrame] input dataframe
@ryanflorence
ryanflorence / static_server.js
Last active March 13, 2024 08:05
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@rponte
rponte / StringUtils.java
Last active April 10, 2024 23:01
Removing accents and special characters in Java: StringUtils.java and StringUtilsTest.java
package br.com.triadworks.rponte.util;
import java.text.Normalizer;
public class StringUtils {
/**
* Remove toda a acentuação da string substituindo por caracteres simples sem acento.
*/
public static String unaccent(String src) {

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