Skip to content

Instantly share code, notes, and snippets.

View junetech's full-sized avatar

Juntaek HONG junetech

  • Pohang, Korea
  • 00:43 (UTC +09:00)
View GitHub Profile
@junetech
junetech / error_test.py
Created December 4, 2019 04:01
Python error raising & args passing
for j in range(2):
try:
for i in range(10):
print(i)
if i == 3:
raise StopIteration
except:
print("raised successfully")
continue
@junetech
junetech / sum_max_min_combo_gen.py
Created December 4, 2019 13:50
Python yield example: integer combination generator
from typing import List, Any, Generator
def minmaxpartition(_sum: int, _count: int, _min: int, _max: int
) -> Generator[List[Any], None, None]:
if _min > _max:
yield []
return
if _sum < _count * _min:
yield []
@junetech
junetech / create_write_csv.py
Created February 24, 2020 06:37
Create and write to csv file using DictWriter in Python
from typing import Any, Dict, List
def create_write_csv(formatted_list: List[Dict[str, Any]],
fieldnames: List[str],
filepath: str,
encoding: str):
"""row 정보를 가진 dictionary의 list를 받아 filepath에 csv로 저장
Arguments:
formatted_list {List[Dict[str, str]]} -- column head를 key, 값을 value로 하는 dictionary의 list
@junetech
junetech / profiles.json
Last active February 26, 2021 10:06
Windows Terminal(preview) profile in JSON format
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
// You can add more global application settings here.
@junetech
junetech / if_test.py
Created December 4, 2020 02:40
Python if statement test
def if_bool_value(any_input):
_str = f"For if statement, {any_input} of {type(any_input)} is"
if any_input:
print(_str, True)
else:
print(_str, False)
if_bool_value(1)
if_bool_value(2)
@junetech
junetech / fedora_server_init_settings.md
Last active March 4, 2021 02:04
Fedora Server initial settings

Initial settings for Fedora Server

based on version 33

Static IP address using CLI

  • Find interface name(e.g. enp42s0) by $ ifconfig -a
  • Make & edit the interface's config file by $ sudo nano /etc/sysconfig/network-scripts/ifcfg-enp42s0
    • put the informations by the following format:
@junetech
junetech / silencer.py
Created March 5, 2021 01:35
Suppress console output of python codes & FFI
"""http://thesmithfam.org/blog/2012/10/25/temporarily-suppress-console-output-in-python/
https://stackoverflow.com/questions/36956083/how-can-the-terminal-output-of-executables-run-by-python-functions-be-silenced-i
"""
import sys
import os
import contextlib
print(f"package\t{__name__}\tloaded")
@junetech
junetech / python.jsonc
Last active September 9, 2021 04:12
Python snippets
{
// Snippets for Python
"Private Member Getter": {
"prefix": [
"pmg",
"ㅔㅡㅎ"
],
"description": "Create private class member with getter",
"body": [
"__${1:Name}: ${2:Type}",
@junetech
junetech / gist:b6b374ce5ca20c34feb18ad58399d027
Last active June 13, 2023 02:43 — forked from djsmith42/gist:3956189
Console output suppressor for Python code
"""http://thesmithfam.org/blog/2012/10/25/temporarily-suppress-console-output-in-python/
https://stackoverflow.com/questions/36956083/how-can-the-terminal-output-of-executables-run-by-python-functions-be-silenced-i
"""
import os
import sys
from contextlib import contextmanager
@contextmanager
def suppress_stdout():
@junetech
junetech / nextcloud_on_fedora_38.md
Last active October 25, 2023 06:01
Nextcloud on Fedora Workstation 38

Nextcloud on Fedora Workstation 38

Initialization

  • Configuration of self generated SSL certificate
    • Append export ssl_name="my_domain_name" to ~/.bashrc
      • Replace "my_domain_name" with the domain name(e.g. lists.fedoraproject.org)
    • # dnf install openssl
    • # mkdir ~/certs
    • # cd ~/certs