Skip to content

Instantly share code, notes, and snippets.

View yv84's full-sized avatar
๐Ÿ’
Focusing

Vladimir Yudintsev yv84

๐Ÿ’
Focusing
View GitHub Profile
@akostadinov
akostadinov / timebench.groovy
Last active May 10, 2021 04:26
Benchmark Java Thread-Safe Time Formatter Implementations
@Grapes([
@Grab(group='org.gperfutils', module='gbench', version='[0.4,)'),
@Grab(group='org.apache.commons', module='commons-lang3', version='[3.7,)'),
@Grab(group='joda-time', module='joda-time', version='[2.9.9,)')
])
/**
* Java 8 DateTimeFormatter
*/
import java.util.Date;
  • What do Etcd, Consul, and Zookeeper do?
    • Service Registration:
      • Host, port number, and sometimes authentication credentials, protocols, versions numbers, and/or environment details.
    • Service Discovery:
      • Ability for client application to query the central registry to learn of service location.
    • Consistent and durable general-purpose K/V store across distributed system.
      • Some solutions support this better than others.
      • Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state.
  • Centralized locking can be based on this K/V store.
@prasanthj
prasanthj / native-mem-tracking.md
Last active June 5, 2024 12:48
Native memory tracking in JVM

Enable native memory tracking in JVM by specifying the following flag

-XX:NativeMemoryTracking=detail

Know the <PID> of the java process

jps

To print ps based RSS

ps -p <PID> -o pcpu,rss,size,vsize

To print native memory tracking summary

@nameoftherose
nameoftherose / tk_async_demo.py
Created November 17, 2016 18:14
embedding tkinter in asyncio
# This demo is a transliteration of the below referenced demo to use the async/await syntax
#
#https://www.reddit.com/r/Python/comments/33ecpl/neat_discovery_how_to_combine_asyncio_and_tkinter/
#
# For testing purposes you may use the following command to create a test daemon:
# tail -f /var/log/messages | nc -l 5900
# Enter localhost:5900 in the entry box to connect to it.
from tkinter import *
@blaisep
blaisep / jenkins-pipeline-git-cred.md
Created October 20, 2016 23:33
Insert git credentials into Jenkins Pipeline Script projects

Suppose you want to inject a credential into a Pipeline script. The cloudbees note does not include Pipeline script examples. https://support.cloudbees.com/hc/en-us/articles/203802500-Injecting-Secrets-into-Jenkins-Build-Jobs

The Jenkins Pipeline Docs' description of the git pushmethod doesn't have an example using injected credentials. (https://jenkins.io/doc/pipeline/examples/#push-git-repo)

The Snippet generator is helpful, but not not if you try to follow the instructions at: https://wiki.jenkins-ci.org/display/JENKINS/Credentials+Binding+Plugin

@yv84
yv84 / replacer.py
Last active February 19, 2018 10:02 — forked from meddulla/replacer.py
Script to recursively replace string in filename and contents
"""
Usage: python script.py search_string replace_string dir
Eg. python batchreplace.py galleries productions /Sites/cjc/application/modules/productions/
And it will search recursively in dir
and replace search_string in contents
and in filenames.
Case-sensitive
"""
from sys import argv
@soucekv
soucekv / build.gradle
Last active July 26, 2024 22:37
Gradle checkstyle with suppression filter module
//Gist note this is snippet from root build.gradle in project with subprojects
checkstyle {
// use one common config file for all subprojects
configFile = project(':').file('config/checkstyle/checkstyle.xml')
configProperties = [ "suppressionFile" : project(':').file('config/checkstyle/suppressions.xml')]
}
@JarenGlover
JarenGlover / gist:d7ffab312ea756834218
Last active August 9, 2024 06:08
Nginx - Reverse Proxy | Backend & Front End Example
upstream fuel {
# Defines a group of servers. Servers can listen on different ports.
server IP:PORT fail_timeout=0;
}
upstream frontend {
server IP:PORT fail_timeout=0;
}
@huskercane
huskercane / python_java_time.py
Created July 29, 2014 15:08
Convert from java timestamp to python datetime and vice versa
def _convert_java_millis(java_time_millis):
"""Provided a java timestamp convert it into python date time object"""
ds = datetime.datetime.fromtimestamp(
int(str(java_time_millis)[:10])) if java_time_millis else None
ds = ds.replace(hour=ds.hour,minute=ds.minute,second=ds.second,microsecond=int(str(java_time_millis)[10:]) * 1000)
return ds
def _convert_datetime_java_millis(st):
"""Provided a python datetime object convert it into java millis"""
@yv84
yv84 / loan.py
Last active June 8, 2017 03:33
loan
def differ(loan, rate, t, accuracy=2):
list_pay_per_month = []
body_of_loan = loan
month_count = t * 12
body_per_month = loan / month_count
sum = 0
for _ in range(month_count):
interest = body_of_loan * rate / 12
pay_per_month = interest + body_per_month