Skip to content

Instantly share code, notes, and snippets.

View leopard627's full-sized avatar
๐ŸŽฏ
Focusing

Leopard627 leopard627

๐ŸŽฏ
Focusing
View GitHub Profile
use std::fs::File;
use std::io;
use std::io::Read;
fn beginner() -> Result<String, io::Error> {
let f = File::open("hello.txt");
let mut f = match f {
Ok(file) => file,
Err(e) => return Err(e),
@leopard627
leopard627 / fzf_bat.sh
Created August 2, 2019 10:14
fzf + bat magic
export FZF_DEFAULT_OPTS="--ansi --preview-window 'right:60%' --preview 'bat --color=always --style=header,grid --line-range :300 {}'"
try:
assert requests.get("googlgg.com").status_code == 200
assert requests.get("abcx.com").status_code == 200
except AssertionError:
print("?!")
@leopard627
leopard627 / deleteCharHandler.js
Created October 25, 2019 05:13
react ์—์„œ array์˜ index๋ฅผ ์‚ญ์ œํ•˜๋Š” ํ•ธ๋“ค๋Ÿฌ ํŒจํ„ด
deleteCharHandler = (index) => {
const text = this.state.content.split('');
text.splice(index, 1);
const updatedText = text.join('');
this.setState({content: updatedText});
}
@leopard627
leopard627 / allow_sql_query_history.py
Created December 10, 2019 05:59
django ์—์„œ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค ๋Œ๋ฆด๋•Œ ์ฟผ๋ฆฌ ๊ฐ™์ด ๋ฝ‘๋Š” ๋ฐฉ๋ฒ• :P
## reference
## https://stackoverflow.com/questions/13162771/django-how-to-see-sql-query-when-running-tests
from django.db import connection, reset_queries
from django.test import override_settings, TransactionTestCase
class TransactionTests(TransactionTestCase):
@override_settings(DEBUG=True)
def test_sql(self):
@leopard627
leopard627 / docker-prom-stack.yml
Last active January 11, 2020 12:14 — forked from subicura/docker-prom-stack.yml
docker-prom-stack.yml
version: "3"
networks:
monitoring:
app-backend:
services:
cadvisor:
image: google/cadvisor:${CADVISOR_VERSION:-v0.26.1}
networks:
ECR=$(docker exec -it guide-aws sh -c 'aws ecr get-login --no-include-email --region ap-northeast-2')
echo "creating login temp file"
_ECR=$(echo ${ECR} | tr -d '\r')
echo ${_ECR} > ecr.out
echo 'login into ecr'
$(cat ecr.out)
echo "removing temp file"
rm ecr.out
@leopard627
leopard627 / docker-stack.yml
Created January 10, 2020 17:22 — forked from subicura/docker-stack.yml
prometheus on swarm
# docker stack deploy --compose-file ./docker-stack.yml prom-stack
version: "3"
services:
prometheus:
image: prom/prometheus:latest
networks:
- monitoring
ports:
- 9001:9090
@leopard627
leopard627 / prometheus.yml
Created January 10, 2020 17:23 — forked from subicura/prometheus.yml
prometheus on swarm (2)
global:
scrape_interval: 30s
evaluation_interval: 30s
external_labels:
monitor: "prometheus-swarm"
rule_files:
scrape_configs:
- job_name: 'prometheus'
@leopard627
leopard627 / run.sh
Created January 11, 2020 12:44
git not found in alpine image
apk update && apk upgrade && \
apk add --no-cache bash git openssh