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
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
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 DEBCONF_NOWARNINGS=yes
export LESSOPEN=|
export LESSCLOSE=/usr/bin/lesspipe
@sleepless-se
sleepless-se / kivy_sample.kv
Created Aug 3, 2019
Sample: Kiby input text update label with button
View kivy_sample.kv
<Manual_insert>:
name: "manual"
BoxLayout:
TextInput:
id: name
Label:
text: root.text
Button:
text: "Update"
on_release:
@sleepless-se
sleepless-se / get_crop_img.py
Last active Jul 8, 2019
Crom image from white background image. #python #opencv #PIL
View get_crop_img.py
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
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>
</a>
</li>
@sleepless-se
sleepless-se / numpy_to_json.py
Created May 22, 2019
numpy to json. Object of type int32 is not JSON serializableiMac:object_detection_api_imageai
View numpy_to_json.py
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
sleepless-se / inputTextByJavascriptExcuter.java
Last active May 16, 2019
inputTextByJavascriptExcuter in java for selenium
View inputTextByJavascriptExcuter.java
//import
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
sleepless-se / setup_gpu_docker.sh
Last active May 13, 2019
This file for setup GPU on docker in GPUEater.
View setup_gpu_docker.sh
#!/bin/bash
wget -O - https://gist.githubusercontent.com/wdullaer/f1af16bd7e970389bad3/raw/install.sh | bash or
open https://gist.github.com/Brainiarc7/a8ab5f89494d053003454efc3be2d2ef
You can’t perform that action at this time.