Skip to content

Instantly share code, notes, and snippets.

View pedroct92's full-sized avatar
🤠

Pedro Torres pedroct92

🤠
View GitHub Profile
@ygotthilf
ygotthilf / jwtRS256.sh
Last active May 4, 2025 08:04
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@anataliocs
anataliocs / Application.java
Last active September 1, 2022 18:21
Validation messages in messages.properties file for i18n internationalization by locale in spring boot
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@RequestMapping("/")
@ResponseBody
String home() {
@kjorg50
kjorg50 / PlayDynamicCustomForms.md
Last active July 21, 2017 17:48
Java Play Framework - Dynamic, Custom Forms

Play Framework Dynamic Forms

This post is intended to summarize my efforts in creating a dynamic form with custom data objects in the Java Play Framework. The version I am working with is 2.3.7. This example proved to be very useful

Motivation

I have a CSVData class in my app, and I want to create instances of this class via form input. Here are the basic attributes of this class, with annotations removed for brevity:

public class CSVData extends VirtualSensor implements CSVWrappable {

 // used by play to save it in the DB
@icchan
icchan / RegexCardValidator.java
Last active May 16, 2024 04:13
Java Credit Card Number Validator
package net.bubblemix.cardcheck;
/**
* Validator for credit card numbers
* Checks validity and returns card type
*
* @author ian.chen
*/
public class RegexCardValidator {
@sangeeths
sangeeths / github-to-bitbucket
Created March 10, 2014 15:24
Forking a Github repo to Bitbucket
Go to Bitbucket and create a new repository (its better to have an empty repo)
git clone [email protected]:abc/myforkedrepo.git
cd myforkedrepo
Now add Github repo as a new remote in Bitbucket called "sync"
git remote add sync [email protected]:def/originalrepo.git
Verify what are the remotes currently being setup for "myforkedrepo". This following command should show "fetch" and "push" for two remotes i.e. "origin" and "sync"
git remote -v
@irumiha
irumiha / Application.scala
Last active January 23, 2017 21:53
play-2.1.0-chat
// This is the part in the Controller that creates the EventSource connection
def liveListen(event: String) = Action { request =>
AsyncResult {
implicit val timeout: Timeout = 5.seconds
(MegaRoomActor.ref ? (MegaRoomActor.Join(event)) ).
mapTo[Enumerator[JsValue]].map(startEventStream)
}
}
@monteiro
monteiro / Application.java
Last active February 14, 2017 21:54
Adding Play! Framework 2.0 (2.0.4-Java) pagination with Bootstrap (http://twitter.github.com/bootstrap/) tables using EHCache (http://ehcache.org/).
package controllers;
public class Application extends Controller {
// in cache during 1800 seconds (30 min)
@Cached(key = "pagingList", duration = 1800)
public static Result index(Integer page) {
String uuid = session("uuid");
if (uuid == null) {
uuid = java.util.UUID.randomUUID().toString();
@mguillermin
mguillermin / Company.java
Created October 22, 2012 07:47
PlayFramework 2.0 Ebean Test with YAML data
package models;
@Entity
public class Company extends Model {
@Id
public Long id;
public String name;
public static Finder<Long, Company> find = new Finder<Long, Company>(Long.class, Company.class);
@matthewlehner
matthewlehner / autopgsqlbackup
Created July 11, 2012 16:10
Auto PostgreSQL backup script.
#!/bin/bash
#
# PostgreSQL Backup Script Ver 1.0
# http://autopgsqlbackup.frozenpc.net
# Copyright (c) 2005 Aaron Axelsen <[email protected]>
#
# This script is based of the AutoMySQLBackup Script Ver 2.2
# It can be found at http://sourceforge.net/projects/automysqlbackup/
#
# The PostgreSQL changes are based on a patch agaisnt AutoMySQLBackup 1.9
@benmccann
benmccann / SchemaGen.java
Created March 16, 2012 04:24
Liquibase integration for Play 2.0
package com.benmccann.example.schema;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.net.URL;
import java.util.Arrays;