Skip to content

Instantly share code, notes, and snippets.

View bekatom's full-sized avatar
🎯
Focusing

Beka Tomashvili bekatom

🎯
Focusing
View GitHub Profile
<script src="https://cdnjs.cloudflare.com/ajax/libs/trianglify/0.2.1/trianglify.min.js"></script>
<style>
width:500px;
height:500px;
</style>
<div id="main" class="main">
<script>
function addTriangleTo(target) {
@bekatom
bekatom / list_to_dict.py
Created July 21, 2015 15:57
list_to_dict.py
#SQL alchemy object to list method
def to_dict(data):
"""
:param data:
:returns objects list in dictionary :
"""
return [u.__dict__ for u in data]
@bekatom
bekatom / flask-test.py
Created July 28, 2015 11:00
flask-test.py
from flask import Flask
from flask.ext.testing import TestCase
from mtportal.app import create_app
class TestConfig(object):
DEBUG = False
TESTING = True
@bekatom
bekatom / card_shuffle.py
Created August 4, 2015 13:45
Custom card shuffle withouy shuffle method
from random import randrange
class Card():
def __init__(self, rank, suit):
self.rank = rank
self.suit = suit
card_list = [Card("HEARTS", 4),
@bekatom
bekatom / mutability.py
Created August 4, 2015 13:49
Mutable list problems
# first version
def boo1(l=[]):
l = list(l)
l.append(1)
return l
# second version
def boo2(l=[]):
result = []
result.extend(l)
@bekatom
bekatom / consul.sh
Created March 19, 2016 07:09
/etc/init.d/consul
#
# Daemon for Consul
#
# chkconfig: 345 99 20
# description: Daemon for vault
# processname: vault
### BEGIN INIT INFO
# Provides: consul
# Required-Start: $network
@bekatom
bekatom / vault.sh
Created March 19, 2016 07:09
/etc/init.d/vault
#
# Daemon for vault
#
# chkconfig: 345 99 20
# description: Daemon for vault
# processname: vault
### BEGIN INIT INFO
# Provides: vault
# Required-Start: $network
@bekatom
bekatom / app.jsx
Created March 28, 2016 09:21
react.js loop with object
var MenuCategories = React.createClass({
getInitialState: function() {
return {
data: [],
temp : "beka tomashvili"
};
},
componentDidMount: function() {
this.serverRequest = $.get(this.props.source, function (result) {
@bekatom
bekatom / util.js
Created April 11, 2016 07:40
my util.js , some helpers for javascript modules
/**
* Created by beka on 4/10/16.
*/
module.exports = {
base64_encode: function (file){
var fs = require('fs');
var bitmap = fs.readFileSync(file);
return new Buffer(bitmap).toString('base64');
@bekatom
bekatom / app.js
Created April 12, 2016 05:28
AllowCrossDomain Request , in multiple site only
function allowCrossDomain(req, res, next) {
res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.header('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
res.header('Access-Control-Allow-Credentials', true);
var origin = req.headers.origin;
if (_.contains(config.allowed_origins, origin)) {
res.setHeader('Access-Control-Allow-Origin', origin);