Skip to content

Instantly share code, notes, and snippets.

View dohvis's full-sized avatar
📝

Kim Dohyeon dohvis

📝
View GitHub Profile
@vanpelt
vanpelt / upsert.py
Created March 20, 2018 06:33
Flask SqlAlchemy MySQL ON DUPLICATE KEY UPDATE returning auto increment id UPSERT HOTNESS
from app import db
from sqlalchemy import func
from sqlalchemy.dialects.mysql import insert
def upsert(model, insert_dict):
"""model can be a db.Model or a table(), insert_dict should contain a primary or unique key."""
inserted = insert(model).values(**insert_dict)
upserted = inserted.on_duplicate_key_update(
id=func.LAST_INSERT_ID(model.id), **{k: inserted.inserted[k]
for k, v in insert_dict.items()})
@allieus
allieus / 1_django_form_drf_example.py
Last active November 28, 2019 09:27
장고 외부에서 Form, Serializer 활용하기
from django.conf import settings
settings.configure(USE_I18N=False)
from django import forms
from rest_framework import serializers
class PostForm(forms.Form):
email = forms.EmailField()
@puilp0502
puilp0502 / install-uwsgi-nginx.sh
Last active January 15, 2018 07:42
Install uWSGI and nginx
#!/bin/bash
# uWSGI & nginx installation script
# Created at 2017-06-27 by Frank Yang (https://github.com/puilp0502)
# Tested on Ubuntu Server 16.04 LTS
# Check if user is root
if [[ $UID -ne '0' ]]; then
echo "This script needs to be run as root; exiting..."
exit 0
@puilp0502
puilp0502 / uwsgi.ini
Created June 26, 2017 15:37
Sample uwsgi ini configuration
[uwsgi]
# Django-related settings
# the base directory (full path)
chdir = /home/ubuntu/(project-dir)
# Django's wsgi file
module = (project-name).wsgi:application
# the virtualenv (full path)
home = /home/ubuntu/.venv/(venv-name)/
@puilp0502
puilp0502 / uwsgi.service
Created June 26, 2017 15:02
uwsgi emperor mode systemd definition
[Unit]
Description=uWSGI Emperor service
[Service]
RuntimeDirectory=uwsgi
RuntimeDirectoryMode=755
User=emperor
Group=www-data
ExecStart=/usr/local/bin/uwsgi --emperor /etc/uwsgi/sites
Restart=always
@harrydrippin
harrydrippin / all.py
Last active May 3, 2020 13:15
증분법, 이분법, 가위치법, Newton-Raphson법, 할선법의 Python Code 정리 및 설명
# -*- coding: utf-8 -*-
# 수치해석, 김상철 교수님
# 1. Incremental Search, Bisection, False Position,
# Newton-Raphson, Secant Method 정리
# 20163179 홍승환
import numpy as np
import math
from scipy.optimize import fsolve
@rokugasenpai
rokugasenpai / how_to_download_streaming_jp.md
Last active December 17, 2023 09:50
各ストリーミング配信のダウンロード方法(要curl・ffmpeg・rtmpdump・chrome・limechat・wireshark)

ツイキャス

@kyo504
kyo504 / CustomToastModule.java
Last active November 10, 2020 05:52
[React Naitve] Native module for android
package com.your.package.name;
import android.widget.Toast;
import android.app.Activity;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
# -*- coding: utf-8 -*-
# 절대 임포트 설정
from __future__ import absolute_import
from __future__ import print_function
# 필요한 라이브러리들을 임포트
import collections
import math
import os
@perhapsspy
perhapsspy / django-test-easy-and-fast.md
Last active May 20, 2022 05:06
Django에서 Test 쉽고 빠르게 하기