Skip to content

Instantly share code, notes, and snippets.

View behrangsa's full-sized avatar
💾

Behrang Saeedzadeh behrangsa

💾
View GitHub Profile
@behrangsa
behrangsa / self-signed-certificate-with-custom-ca.md
Created November 10, 2018 14:30 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
"UserData": {
"Fn::Base64": { "Fn::Join":["", [
"#!/bin/bash -ex\n",
"apt-get update\n",
"apt-get -y install python-setuptools\n",
"mkdir aws-cfn-bootstrap-latest\n",
"curl https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz | tar xz -C aws-cfn-bootstrap-latest --strip-components 1\n",
"easy_install aws-cfn-bootstrap-latest\n",
"/usr/local/bin/cfn-init --stack ", { "Ref":"AWS::StackName" }, " --resource WebServer", " --region ", { "Ref": "AWS::Region" }, "\n",
"\n",
@behrangsa
behrangsa / java-kotling.md
Last active January 21, 2018 13:56
Java vs Kotlin

Here are two examples:

Example 1

In version 3.1.4 of the RabbitMQ client for Java, Connection does not implement Closeable so you can't use try-with-resources when creating a new connection.

You can't do this either:

@Data
@Component
@ConfigurationProperties(prefix = "sample")
@Validated
public class SampleProperties {
@NotNull
private String sample1;
}
@behrangsa
behrangsa / 01 - home.js
Last active October 7, 2017 12:36
Stuck implementing Cognito Federated Authentication for a Web App using Lambda, API Gateway, and Twitter
module.exports.handler = function (event, context, callback) {
let body = `
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Serverless Home</title>
<style>
.hidden {
@behrangsa
behrangsa / gist:746d7e31973488102d05985caa419e8c
Created January 29, 2017 12:25
PlantUML Example: Firewall Rules
@startuml
node "VPC A" as VpcA
node "VPC B" as VpcB
VpcA -> VpcB : TCP/4407
VpcB -> VpcA : TCP/3306
@enduml
@behrangsa
behrangsa / Main.java
Last active September 22, 2021 14:48
Console based Spring Boot app
@SpringBootApplication
public class Main {
public static void main(String[] args) {
final ConfigurableApplicationContext context = SpringApplication.run(Main.class, args);
final AppBean app = context.getBean(AppBean.class);
app.run(args);
}
}
@behrangsa
behrangsa / description.md
Last active August 29, 2015 14:10
Mobile Safari issue

Right now I managed to reproduce another issue that has affected my device for some time and it might be related:

  • Close all the tabs in Mobile Safari
  • Close Safari and wait a few seconds
  • Make sure the Google+ app is installed
  • Open Safari
  • Go to reddit.com/domain/plus.google.com
  • Click on any of the links (e.g. Material Linux distro is now Quantum OS...)
  • When the page loads, it is blank until it is scrolled a bit
@behrangsa
behrangsa / gitbr.sh
Created August 29, 2014 01:29
Git Branches
for proj in ~/Projects/* ; do
if [[ -d "$proj" && -d "$proj/.git" ]]; then
echo -n "$proj: "
cd $proj && git branch | sed -n '/\* /s///p'
fi
done
@behrangsa
behrangsa / TablePanel.java
Last active August 29, 2015 14:05
TablePanel (retrieved via web.archive.org)
import javax.swing.*;
import javax.swing.event.TableColumnModelListener;
import javax.swing.event.TableColumnModelEvent;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumn;
import javax.swing.table.DefaultTableColumnModel;
import java.awt.*;