Skip to content

Instantly share code, notes, and snippets.

Sébastien Stormacq sebsto

Block or report user

Report or block sebsto

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sebsto
sebsto / code-stack.ts
Created Aug 20, 2019
CDK Create EC2 instace in private subnet. Install Nginx.
View code-stack.ts
import ec2 = require('@aws-cdk/aws-ec2');
import cdk = require('@aws-cdk/core');
import { Fn, Tag } from '@aws-cdk/core';
import { AmazonLinuxImage, UserData, InstanceType } from '@aws-cdk/aws-ec2';
import { Role, ServicePrincipal, ManagedPolicy, CfnInstanceProfile } from '@aws-cdk/aws-iam'
export class CodeStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
@sebsto
sebsto / gist:19b99f1fa1f32cae5d00
Created Aug 8, 2014
Install Maven with Yum on Amazon Linux
View gist:19b99f1fa1f32cae5d00
sudo wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
sudo sed -i s/\$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo
sudo yum install -y apache-maven
mvn --version
@sebsto
sebsto / gist:20e550876db521710186
Created Feb 12, 2015
Block users access to AWS EC2 meta data
View gist:20e550876db521710186
sudo iptables -A OUTPUT -m owner ! --uid-owner root -d 169.254.169.254 -j DROP
@sebsto
sebsto / gist:6441df09e97c4cbbd22b8ba313b8d642
Last active Aug 10, 2019
Amazon Linux 2 first boot on Virtual Box
View gist:6441df09e97c4cbbd22b8ba313b8d642
# Download the VDI from https://cdn.amazonlinux.com/os-images/latest/
# Doc is at http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-linux-2-virtual-machine.html
# Be sure you have config/meta-data and config/user-data ready as per the below
# change ec2-user's password to your password
$ cat config/meta-data
local-hostname: amazonlinux.onprem
# eth0 is the default network interface enabled in the image. You can configure
@sebsto
sebsto / gist:468670c7c0d5feeade69
Created Mar 20, 2015
AWS CLI : discover your service limits from the command line
View gist:468670c7c0d5feeade69
aws support describe-trusted-advisor-check-result --check-id eW7HH0l7J9 --query 'result.sort_by(flaggedResources[?status!="ok"],&metadata[2])[].metadata' --output table --region us-east-1
@sebsto
sebsto / menubar.swift
Created Jul 10, 2019
List MacOS MenuBar items
View menubar.swift
import Foundation
import CoreGraphics
let windowInfos = CGWindowListCopyWindowInfo(CGWindowListOption.optionOnScreenOnly, kCGNullWindowID) as! Array<CFDictionary>
for item in windowInfos {
if let dict = item as? [CFString: AnyObject] {
if ( dict[kCGWindowLayer] as! Int == 25 && dict[kCGWindowOwnerName] as! String != "SystemUIServer" ) {
print("StatusBar Item \(dict)")
}
@sebsto
sebsto / async4.js
Created Jun 25, 2019
Async - AWS SDK for Javascript
View async4.js
function updatePlayCount(your_object) {
return new Promise((resolve, reject) => {
const LAST_PLAYED_TIME = Math.round(new Date() / 1000);
var params = {
TableName: "your_table",
Key: {
"cognitoid": your_object.userId,
@sebsto
sebsto / async3.js
Created Jun 25, 2019
Async - the good
View async3.js
async function asyncWorker() {
return new Promise( (resolve, reject) => {
setTimeout(resolve, 2000);
});
}
async function main() {
console.debug('Started');
@sebsto
sebsto / async2.js
Created Jun 25, 2019
Async - the bad
View async2.js
function asyncWorker() {
return new Promise( (resolve, reject) => {
setTimeout(resolve, 2000);
});
}
function main() {
callback = () => {
@sebsto
sebsto / async1.js
Created Jun 25, 2019
Async - the ugly
View async1.js
function asyncWorker(callback) {
setTimeout(callback, 2000);
}
function main() {
callback = () => {
console.debug('callback !');
}
You can’t perform that action at this time.