Skip to content

Instantly share code, notes, and snippets.

View BaljeetSandhu's full-sized avatar

Baljeet S BaljeetSandhu

View GitHub Profile
@markwhitaker
markwhitaker / MimeTypes.java
Last active August 17, 2021 10:21
Standard MIME type constants ready to use in a Java project. Now a library: see https://github.com/markwhitaker/MimeTypes.Java
public final class MimeTypes
{
public static final class Application
{
public static final String ATOM_XML = "application/atom+xml";
public static final String ATOMCAT_XML = "application/atomcat+xml";
public static final String ECMASCRIPT = "application/ecmascript";
public static final String JAVA_ARCHIVE = "application/java-archive";
public static final String JAVASCRIPT = "application/javascript";
public static final String JSON = "application/json";
@sbcoba
sbcoba / JpaEntityDdlExport.java
Last active March 13, 2023 16:04
JPA Entity to DDL Generator ( Hibernate 5.x )
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.MySQL5InnoDBDialect;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
@jonico
jonico / Jenkinsfile
Last active February 6, 2025 20:47
Example for a full blown Jenkins pipeline script with CodeQL analysis steps, multiple stages, Kubernetes templates, shared volumes, input steps, injected credentials, heroku deploy, sonarqube and artifactory integration, Docker containers, multiple Git commit statuses, PR merge vs branch build detection, REST API calls to GitHub deployment API, …
#!groovy
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
def label = "mypod-${UUID.randomUUID().toString()}"
podTemplate(label: label, yaml: """
spec:
containers:
- name: mvn
image: maven:3.3.9-jdk-8
@gnarf
gnarf / Vagrantfile
Last active February 7, 2023 15:39
multi-vagrant-ansible-setup
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
config_yml = YAML.load_file(File.open(File.expand_path(File.dirname(__FILE__)) + "/vagrant-config.yml"))
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
@dtelaroli
dtelaroli / DbSchemaDiffTest.java
Created July 24, 2015 18:38
Get Hibernate Schema Diff Script SQL
public class DbSchemaDiffTest {
@Test
public void load() {
HibernateUtil db = new HibernateUtil();
Session session = db.getSession();
session.doWork(new Work() {
@Override
public void execute(Connection connection) throws SQLException {
Configuration configuration = new Configuration();
@ajaegers
ajaegers / git-move-files-in-subfolder.md
Last active February 9, 2025 19:25
Git: move files in an subfolder keeping history

Change structure of project folder with Git

I have this structure:

 project-folder/
     .git
     wp-admin/
     wp-content/
     wp-includes/

.htaccess

@ignaciolg
ignaciolg / nginx_proxy_pass_examples
Created June 17, 2014 23:14
Nginx proxy_pass examples
server {
#listening ip:port
listen 0.0.0.0:80 default_server;
#public data path
root /var/www/nginx/public/;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name subdomain.domain;
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@jboner
jboner / latency.txt
Last active March 5, 2025 14:17
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD