Skip to content

Instantly share code, notes, and snippets.

View set_cookie_on_django_class_base_view
View set_cookie_on_django_function
sleepless-se / postRequest.js
Created Dec 15, 2019
POST request by XMLHttpRequest
View postRequest.js
function getCookie(key) {
var cookies = document.cookie.split(';');
for (var _i = 0, cookies_1 = cookies; _i < cookies_1.length; _i++) {
var cookie = cookies_1[_i];
// console.log(`cookie ${cookie}`);
var cookiesArray = cookie.split('=');
if (cookiesArray[0].trim() == key.trim()) {
// console.log(`cookiesArray ${cookiesArray}`);
let value = cookiesArray[1]; // (key[0],value[1])
sleepless-se / env.txt
Created Oct 4, 2019
Docker env settings for Django
View env.txt
export PYTHONPATH=/usr/bin/python3
export TERM=xterm
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export PWD=/root
export TZ=Asia/Tokyo
export SHLVL=1
export HOME=/root
export LESSOPEN=|
export LESSCLOSE=/usr/bin/lesspipe
sleepless-se / kivy_sample.kv
Created Aug 3, 2019
Sample: Kiby input text update label with button
View kivy_sample.kv
name: "manual"
id: name
text: root.text
text: "Update"
sleepless-se /
Last active Jul 8, 2019
Crom image from white background image. #python #opencv #PIL
import cv2
import numpy as np
from PIL import Image
def nparray_to_rgb(nparry:np.array):
return (int(nparry[0]),int(bg_color[1]),int(bg_color[2]))
def find_edge(img_path:str):
img = cv2.imread(img_path,0)
blur = cv2.blur(img,(5,5))
sleepless-se / pagination.html
Last active Apr 8, 2020
django template for pagenation
View pagination.html
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center pagination-lg g-mt-28 g-mb-28">
<!-- 前へ の部分 -->
{% if page_obj.has_previous %}
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.previous_page_number }}">
<span aria-hidden="true">&laquo;</span>
sleepless-se /
Created May 22, 2019
numpy to json. Object of type int32 is not JSON serializableiMac:object_detection_api_imageai
import numpy as np
import json
import flask
class MyEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, np.integer):
return int(obj)
elif isinstance(obj, np.floating):
return float(obj)
elif isinstance(obj, np.ndarray):
sleepless-se /
Last active May 16, 2019
inputTextByJavascriptExcuter in java for selenium
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
* @param xpath
* Please select text box element
* @param text
sleepless-se /
Last active May 13, 2019
This file for setup GPU on docker in GPUEater.
wget -O - | bash or
You can’t perform that action at this time.