Skip to content

Instantly share code, notes, and snippets.

@antonioiksi
antonioiksi / babel-react-html.html
Last active December 11, 2018 15:33
babel react example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>React Local</title>
<script type="application/javascript" src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script>
<script type="application/javascript" src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script>
@antonioiksi
antonioiksi / get-locale.html
Created October 8, 2018 16:50
get browser locale or lang
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
Hello
<script>
function getLang()
@antonioiksi
antonioiksi / python.py
Last active December 14, 2017 09:24
update dictionary in one string! shorten loop
# for item in graph_data:
# item.data['group'] = model_name
# arr_data.append(item.data)
arr_data = [dict(item.data, **{'group':model_name}) for item in graph_data]
@antonioiksi
antonioiksi / git
Created December 1, 2017 20:03
git init repo and make first push
# SERVER SIDE
cd /opt/git
mkdir project.git
cd project.git
git --bare init
#CLIENT SIDE
cd myproject
git init
git add .
@antonioiksi
antonioiksi / javascript-regexp
Created November 24, 2017 18:13
add symbol '+' to every word in string
//TODO using regexp to add '+' for every word in string
value = value.replace(/(\w+)/g,"+$1");
@antonioiksi
antonioiksi / django.py
Created November 10, 2017 19:31
add 'TEST' into settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'user171030',
'USER': 'user171030',
'PASSWORD': 'user171030',
'HOST': 'localhost',
'PORT': '5432',
# for testing views
'TEST': {
@antonioiksi
antonioiksi / django.py
Created November 10, 2017 08:02
decode Simple JWT token
header = request.META.get('HTTP_AUTHORIZATION')
if header:
token = header.split(' ')[1]
print(token_backend.decode(token, verify=True))
@antonioiksi
antonioiksi / django.py
Created November 10, 2017 07:59
get JWT token from HEADER for SimpleJWT django rest framework
token = sub('Bearer ', '', request.META.get('HTTP_AUTHORIZATION', None))
@antonioiksi
antonioiksi / elasticsearch
Created November 8, 2017 11:41
multifield search match
{
'query': {
'bool': {
'should': [
{
'match': {
'value': '4352435342532'
}
},
{
GET /_search
{
"query": {
"match_all": {}
}
}