Skip to content

Instantly share code, notes, and snippets.

View ShinJJang's full-sized avatar
🎯
Focusing

shinjjang ShinJJang

🎯
Focusing
View GitHub Profile
#!/usr/bin/env python
#
# <bitbar.title>Realtime Stock Tracker</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Bogdan Mosincat</bitbar.author>
# <bitbar.author.github>bogdan1304</bitbar.author.github>
# <bitbar.desc>Shows realtime stock price and daily percentage change for each stock in the list.</bitbar.desc>
# <bitbar.image>https://i.imgur.com/hQoCXFL.png</bitbar.image>
# <bitbar.dependencies>python</bitbar.dependencies>
# Ref: https://books.agiliq.com/projects/django-orm-cookbook/en/latest/
# 8. How to filter a queryset with criteria based on comparing their field values
User.objects.filter(name_startswith='R')
User.objects.filter(last_name=F("first_name"))
User.objects.annotate(first=Substr("first_name", 1, 1), last=Substr("last_name", 1, 1)).filter(first=F("last"))
# 9. How to filter FileField without any file?
no_files_objects = MyModel.objects.filter(
import os
import unittest
from unittest import mock
class TestMockOpen(unittest.TestCase):
def test_mock_open(self):
mock_open = mock.mock_open()
with mock.patch('builtins.open', new_callable=mock_open()):
@ShinJJang
ShinJJang / .autoenv.zsh
Last active May 20, 2018 09:58
Example zsh-autoenv for django with pyenv-virtualenv
# When enter project folder
pyenv activate [your-pyenv-virtualenv]
echo $(pyenv versions)
pip freeze > requirements.txt
ll requirements.txt
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Vue - Hello World</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/earlyaccess/notosanskr.css" rel="stylesheet">
<style>
@ShinJJang
ShinJJang / .zshrc
Created September 12, 2017 02:16
my terminal
# Path to your oh-my-zsh installation.
export ZSH=/Users/shinyeongmin/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="agnoster"
# Uncomment the following line to use case-sensitive completion.
@ShinJJang
ShinJJang / currency-tracker-custum.5m.py
Created September 5, 2017 10:04
Bitbar plugin - KRW to JPY Currency tracker from http://finance.daum.net
#!/usr/bin/python
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
from urllib import urlencode
from urllib2 import Request, urlopen
from datetime import datetime
import sys
reload(sys)
@ShinJJang
ShinJJang / simple_proxy.py
Last active April 7, 2022 17:20
Simple proxy server with flask
# -*- coding: utf-8 -*-
from flask import Flask
from flask import Response
from flask import stream_with_context
from flask import request
import json
import requests
import urllib

mariadb audit plugin 설치

무중단이 가능합니다!

플러그인 directory에서 server_audit.so 확인

SHOW GLOBAL VARIABLES LIKE 'plugin_dir';

설치

INSTALL PLUGIN server_audit SONAME 'server_audit.so';

@ShinJJang
ShinJJang / check_gtx1080.py
Created July 20, 2016 03:39
compuzone의 GTX 1080 재고를 확인합니다. 16개의 상품이 있는데, 품절이 아닌 것이 생기면 slack 메세지를 쏩니다.
# -*- coding: utf-8 -*-
#!/usr/bin/python
from bs4 import BeautifulSoup
from urllib.parse import urlencode
from urllib.request import Request, urlopen
from apscheduler.schedulers.blocking import BlockingScheduler
from slackclient import SlackClient
slack_token = "your slack slack_token"