Skip to content

Instantly share code, notes, and snippets.

View drissamri's full-sized avatar

Driss Amri drissamri

View GitHub Profile
@drissamri
drissamri / gist:ecd19c394540e19d3048e243e6450a66
Created September 25, 2022 17:29
Pre-request Postman script for Cognito
const echoPostRequest = {
url: 'https://cognito-idp.eu-central-1.amazonaws.com/',
method: 'POST',
header: {
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AWSCognitoIdentityProviderService.InitiateAuth'
},
body: {
mode: 'application/json',
raw: JSON.stringify(
@drissamri
drissamri / serverless-deploy-user.yaml
Created December 22, 2018 12:29 — forked from bsamuel-ui/serverless-deploy-user.yaml
Cloudformation template to deploy permissions for deploying a serverless project.
AWSTemplateFormatVersion: 2010-09-09
Description: >
Constructs a managed IAM policy to deploy a serverless project.
This template assumes the stack is being deployed in the current region and account.
You can then attach this policy to other IAM objects, such as users or roles.
Based on the work done in: https://github.com/serverless/serverless/issues/1439
@drissamri
drissamri / notifySlack.groovy
Last active December 1, 2021 07:45 — forked from dschaaff/notifySlack.groovy
jenkins pipeline library for slack notifications with nice formatting
#!/usr/bin/env groovy
/**
* notify slack and set message based on build status
*/
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import hudson.tasks.test.AbstractTestResultAction;
import hudson.model.Actionable;
@Bean
public JwtParser jwtParser()
{
Security.addProvider(new BouncyCastleProvider());
final X509EncodedKeySpec spec = new X509EncodedKeySpec(Base64.getUrlDecoder().decode(PUBLIC_KEY));
final KeyFactory factory;
try {
factory = KeyFactory.getInstance("ECDSA", "BC");
final PublicKey publicKey = factory.generatePublic(spec);
#!/bin/bash
set -e
JAVA_HOME=${1-text}
[ $# -eq 0 ] && { echo "Usage: sudo $0 \$(/usr/libexec/java_home -v '1.8*')" ; exit 1; }
KEYSTORE=$JAVA_HOME/jre/lib/security/cacerts
wget https://letsencrypt.org/certs/isrgrootx1.der
wget https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.der
@drissamri
drissamri / ContainerConfiguration.java
Last active November 17, 2018 05:33
Enable HTTPS in Spring Boot
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory() {
@Override
protected void postProcessContext(Context context) {
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
SecurityCollection collection = new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
package be.ibizz.bluenote;
import org.springframework.data.mongodb.repository.MongoRepository;
public interface NotesRepository extends MongoRepository<Note, Long> {
}
@drissamri
drissamri / LinkController.java
Created January 21, 2015 21:39
Java client for the Linkshortener REST API
@RestController
public class LinkController {
private LinkService linkService;
@Autowired
public LinkController(LinkService linkService) {
this.linkService = linkService;
}
@RequestMapping("/links")
@drissamri
drissamri / LinkController.js
Last active August 29, 2015 14:13
Linkshortener initialize AngularJS app
(function (angular) {
'use strict';
angular
.module('linkApp')
.controller('LinkController', ['$scope', '$log', 'LinkService', function LinkController($scope, $log, LinkService) {
$scope.longUrl = null;
$scope.link = null;
$scope.shorten = function (url) {
@drissamri
drissamri / index.html
Last active August 29, 2015 14:13
Thymeleaf homepage
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"/>
<title>opt.is linkshortener</title>
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.1/css/bootstrap.min.css"
th:href="@{/webjars/bootstrap/3.3.1/css/bootstrap.min.css}" rel="stylesheet" media="screen"/>