Skip to content

Instantly share code, notes, and snippets.

@d-demirci
d-demirci / python-po-translator.py
Created May 28, 2020 10:16
translate po file using google translator with python
#!/usr/env/bin python
from googletrans import Translator
import polib
translator = Translator(service_urls=[
'translate.google.com',
'translate.google.co.kr',
])
#source file
@d-demirci
d-demirci / clearable_file_input.html
Created May 26, 2020 07:56
clearable_file_input.html django/forms/widgets/ file upload bootstrap css
<!-- https://stackoverflow.com/questions/44675550/django-widget-override-template -->
{% load i18n %}{% if widget.is_initial %}{{ widget.initial_text }}: <a href="{{ widget.value.url }}">{{ widget.value }}</a>{% if not widget.required %}
<input type="checkbox" name="{{ widget.checkbox_name }}" id="{{ widget.checkbox_id }}">
<label for="{{ widget.checkbox_id }}">{{ widget.clear_checkbox_label }}</label>{% endif %}<br>
{{ widget.input_text }}:{% endif %}
<label class="btn btn-primary">{% trans 'Upload' %}<input type="{{ widget.type }}" name="{{ widget.name }}" hidden {% include "django/forms/widgets/attrs.html" %}> </label>
#include <iostream>
#include <vector>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/opencv_modules.hpp>
#include <opencv2/cudaobjdetect.hpp>
#include <opencv2/cudaimgproc.hpp>
@d-demirci
d-demirci / upgrade_all.sh
Created November 17, 2019 20:31
upgrade all packages in requirements.txt using pip
cat requirements.txt | cut -d "=" -f 1 | while read line ; do pip install -U $line; done
@d-demirci
d-demirci / generate_users.py
Created November 10, 2019 13:15
django generate random users
#!/usr/bin/python
__author__ = 'lawrencealan+github@gmail.com'
#edited by d3n1z to conform with python3 and django >2
"""
Generates random users, profiles and game entries for testing.
aioredis==1.1.0
asgi-redis==1.4.3
asgiref==2.3.2
async-timeout==2.0.1
attrs==18.1.0
autobahn==18.6.1
Automat==0.6.0
certifi==2018.4.16
channels==2.1.1
channels-redis==2.2.1
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: osx-64
aioredis=1.1.0=pypi_0
asgi-redis=1.4.3=pypi_0
asgiref=2.3.2=pypi_0
async-timeout=2.0.1=pypi_0
attrs=18.1.0=pypi_0
autobahn=18.6.1=pypi_0
automat=0.6.0=pypi_0
@d-demirci
d-demirci / sinewaves.py
Created May 14, 2019 20:06
fourrier series sine waves to make square wave
from sys import platform as sys_pf
if sys_pf == 'darwin':
import matplotlib
matplotlib.use("TkAgg")
from matplotlib import pyplot as plt
import numpy as np
x = np.arange(-np.pi,np.pi,0.01)
@d-demirci
d-demirci / fakeftpserver.py
Created January 29, 2019 21:39
fake ftp server, getting credentials of ftp, good for BGP at Carrier@htb
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
#https://homework.nwsnet.de/releases/10c4/ to python3
Fake FTP Server
~~~~~~~~~~~~~~~
This is a simple fake FTP daemon. It stores the login data (username and
password) given to it and then terminates the connection.
@d-demirci
d-demirci / euclidean_distance_sort.json
Last active December 12, 2018 10:22
painless script to sort by calculating Euclidean distance in elastic search 6.4
//can be used with -> curl -XGET -H "Content-Type:application/json" http://es_host:es_port/image_index/_search -d@euclidean_distance_sort.json
{
"sort" : {
"_score" : "asc"
},
"query": {
"function_score" : {
"script_score" : {
"script" : {