Skip to content

Instantly share code, notes, and snippets.

@serithemage
serithemage / ec2_auto_stop.py
Last active June 1, 2021 01:13
Finds ec2 of all regions and stops instances where the tag AutoStopProtect is not set to True.
import boto3
import logging
# setup simple logging for INFO
logger = logging.getLogger()
logger.setLevel(logging.INFO)
client = boto3.client('ec2')
runningInstanceFilter = [
@npearce
npearce / install-docker.md
Last active April 19, 2024 12:35
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@codecorsair
codecorsair / request.ts
Last active April 23, 2024 17:08
Simple TypeScript XMLHttpRequest
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
export interface RequestOptions {
ignoreCache?: boolean;
headers?: {[key: string]:string};
// 0 (or negative) to wait forever
timeout?: number;
@tamas-molnar
tamas-molnar / kubectl-shortcuts.sh
Last active March 3, 2024 09:09
aliases and shortcuts for kubectl
alias kc='kubectl'
alias kclf='kubectl logs --tail=200 -f'
alias kcgs='kubectl get service -o wide'
alias kcgd='kubectl get deployment -o wide'
alias kcgp='kubectl get pod -o wide'
alias kcgn='kubectl get node -o wide'
alias kcdp='kubectl describe pod'
alias kcds='kubectl describe service'
alias kcdd='kubectl describe deployment'
alias kcdf='kubectl delete -f'
@JonCatmull
JonCatmull / file-size.pipe.ts
Last active April 14, 2024 14:27
Angular2 + TypeScript file size Pipe/Filter. Convert bytes into largest possible unit. e.g. 1024 => 1 KB
/**
* @license
* Copyright (c) 2019 Jonathan Catmull.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
@allieus
allieus / README.md
Last active January 20, 2021 02:23
네이버 블로그 크롤링

네이버 블로그 크롤링

  • 파이썬3 에서 동작합니다.
  • requests, beautifulsoup4 라이브러리가 필요합니다.
pip install requests beautifulsoup4

AskDjango

@yeondudad
yeondudad / conf.php
Last active August 29, 2015 14:20
Changeable configuration in php
<?php
global $conf;
if (!isset($conf)) {
$pathTemplate = dirname(__FILE__) . '/conf_%s.php';
$configFile = sprintf($pathTemplate, 'script');
$currentConfigFile = sprintf($pathTemplate, gethostname());
if (file_exists($currentConfigFile)) {
$configFile = $currentConfigFile;
} elseif (array_key_exists('HTTP_HOST', $_SERVER)) {
$currentConfigFile = sprintf($pathTemplate, $_SERVER['HTTP_HOST']);
from flask import Flask, request, session, g, redirect, url_for
from flask import abort, render_template, flash
app = Flask(__name__)
app.config.from_object(__name__)
hosts = {
'b': "https://code.google.com/p/android/issues/"
's': "https://android.googlesource.com/",
'r': "https://android-review.googlesource.com/",
@haje01
haje01 / pi.py
Created February 2, 2015 11:50
원주율 외우기
def sfn1(na, o):
a, b, c = na[o-2], na[o-1], na[o]
if a == b and b == c:
return 1
df = b - a
if df == c - b:
return 2 if abs(df) == 1 else 5
elif a == c:
return 4
return 10