Skip to content

Instantly share code, notes, and snippets.

View jpa-second-level-cache-test.java
// Testing the jpa (hibernate) second level cache by running different way of findById method
public UserSession findById(String id) {
System.out.println("Running UserSession.findById");
Session session = getEntityManager().unwrap(Session.class);
SessionFactory sessionFactory = session.getSessionFactory();
String rName = "test.ear/model.jar#model.com.test.app.authentication.model.UserSession";
long oldMissCount = sessionFactory.getStatistics().getSecondLevelCacheStatistics(rName).getMissCount();
long oldHitCount = sessionFactory.getStatistics().getSecondLevelCacheStatistics(rName).getHitCount();
View essential-javascript-links.md
@ramsrib
ramsrib / fields.py
Last active Oct 29, 2020 — forked from ambivalentno/svgimagefield.py
A form field to handle validation of image + svg in Django 3
View fields.py
import sys
import xml.etree.cElementTree as et
from io import BytesIO
from django.core.exceptions import ValidationError
from django.core.validators import (
FileExtensionValidator,
get_available_image_extensions,
)
from django.forms import ImageField as DjangoImageField
@ramsrib
ramsrib / allow_paste.js
Created Sep 7, 2020
allow paste using javascript
View allow_paste.js
var allowPaste = function(e){
e.stopImmediatePropagation();
return true;
};
document.addEventListener('paste', allowPaste, true);
@ramsrib
ramsrib / JDBCTestDropwizardApp.java
Created Apr 28, 2018 — forked from asamaraw/JDBCTestDropwizardApp.java
Distributed JDBC session store for Dropwizard 1.2.2
View JDBCTestDropwizardApp.java
@Override
public void run(TestDropwizardConfiguration configuration, Environment environment)
throws Exception
{
env.lifecycle().addLifeCycleListener(new AbstractLifeCycleListener()
{
@Override
public void lifeCycleStarting(LifeCycle event)
{
if (!(event instanceof Server))
@ramsrib
ramsrib / db_backup.sh
Created Jun 24, 2020 — forked from bendavis78/db_backup.sh
A simple database backup / rotation / prune script
View db_backup.sh
#!/bin/bash
# for use with cron, eg:
# 0 3 * * * postgres /var/db/db_backup.sh foo_db
if [[ -z "$1" ]]; then
echo "Usage: $0 <db_name> [pg_dump args]"
exit 1
fi
View bt.py
#http://googledevjp.blogspot.com/2011/04/google-code-jam-2011.html
def solve(rest, boards, counts):
if boards == []:
return rest == 0
board = boards[-1]
count = rest / board
rest = rest % board
while count >= 0:
if solve(rest, boards[0:-1], counts):
View setup port forwarding to enable remote debugging in vagrant vm.md

Vagrant vm network config

In the Vagrantfile, do :

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  config.vm.network :public_network
View Tensorflow for Poets.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ramsrib
ramsrib / ngrxintro.md
Last active Nov 25, 2017 — forked from btroncone/ngrxintro.md
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series
View ngrxintro.md

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents