Skip to content

Instantly share code, notes, and snippets.

@beall49
beall49 / home.terminal
Created June 26, 2018 02:20
export PS1="\$(date +%H:%M:%S)-\u: 🔴 "
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NGMCAw
IDAAEAKAAtIQERITWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xvcqISFFhOU09iamVj
dF8QD05TS2V5ZWRBcmNoaXZlctEXGFRyb290gAEIERojLTI3O0FITltiaWttcn2GjpGa
@beall49
beall49 / validate-token.ts
Last active January 11, 2024 00:03
How to validate a jwt in typescript
import { Response, Request, Router } from 'express';
import jwt from 'jsonwebtoken';
import jwksClient from 'jwks-rsa';
const router: Router = Router();
const BEARER = 'Bearer ';
const jwkClient = jwksClient({
strictSsl: true,
jwksUri: process.env['JWK_URL'] //or wherever you have your configs
interface CommonData {
data: any;
meta: any,
[propName: string]: any;
}
function getCommonData(common: CommonData) {
return common;
}
//https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-msearch
//https://www.elastic.co/guide/en/elasticsearch/reference/6.2/search-multi-search.html
//https://github.com/elastic/elasticsearch-js/issues/414
GET _msearch
{"index" : "packetbeat-*"}
{ "query": { "multi_match": { "query":"" } } }
{"index" : "packetbeat-*"}
{ "query": { "multi_match": { "query":"" } } }
<html>
<head>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
</head>
<body>
@beall49
beall49 / lambda.java
Created March 29, 2018 03:26
filtler map collect
List<Employee> employees = persons
.stream()
.filter(p -> !p.getLastName().equals("e1"))
.map(p -> new Employee(p.getName(), p.getLastName(), 1000))
.collect(Collectors.toList());
@beall49
beall49 / tail_logs.py
Created March 9, 2018 20:11
tail logs in python
from subprocess import call
from datetime import datetime
import os
class Logs:
LR_HOME = 'LIFERAY_HOME'
LR_DEFAULT = '/opt/home/{}/liferay-current/'
LOG_DIR = '{}logs/liferay.{}.log'
DT_FORMAT = '%Y-%m-%d'
@beall49
beall49 / template_gen.py
Created February 26, 2018 03:48
Build Project Template Script
import os
import glob
PROJECT_NAME = 'template-builder'
PKG_NAME = 'gov.llnl.iweb.liferay'
UNIQUE_PKG_NAME = 'my.template.builder'
CLASS_NAME = 'MySpecialClass'
DIRECTORY = '/Users/rbeall/dev/temps/{}'
@beall49
beall49 / build_script.py
Last active February 16, 2018 21:52
Java build script written in python
import os
import glob
import fnmatch
import datetime
from subprocess import call
VERSION_FILE = './gradle.properties'
VERSION = '1.0.0-SNAPSHOT'
VERSION_STR = 'version='
LR_HOME = 'LIFERAY_HOME'
@beall49
beall49 / migrate.svn.git.md
Last active June 27, 2018 19:24
How to migrate svn to git
  1. Create New Volume
    • If you're on OS X you'll have to do this. It creates a new volume (named migration) on your machine under ~ that's 1GB

      java -jar ~/svn-migration-scripts.jar create-disk-image 1  migration