Skip to content

Instantly share code, notes, and snippets.

View 2garryn's full-sized avatar

Artem Golovinsky 2garryn

  • Russia, Saint-Petersburg
View GitHub Profile
@2garryn
2garryn / gist:1468643
Created December 12, 2011 19:15
Test code to create tree
fill_elem_tree(C, AppIntId, ElemId) ->
case db:get(C, AppIntId, ElemId) of
{error, not_found} ->
{error, {?MODULE, no_value}};
Value ->
ResultRec = wac_lib:from_binary(term, Value),
ChildsRec = [fill_elem_tree(C, AppIntId, ChildElId) ||
ChildElId <- ResultRec#elem.childs],
#elem_info{id = ResultRec#elem.id,
name = ResultRec#elem.name,
%%%-------------------------------------------------------------------
%%% @author Artem Golovinsky <artemgolovinsky@gmail.com>
%%% @copyright (C) 2012, Artem Golovinsky
%%% @doc Header file for epatom.
%%%
%%% Name of element/attribute is element_name()/attr_name(),
%%% when it is defined in RFC4287 and presented
%%% in http://www.w3.org/2005/Atom namespace.
%%% Otherwise, name of element/attribute is string()
%%%
-module(example).
-behaviour(gen_server).
%% API
-export([start_link/0]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
package HelloPackage;
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
-module(nasoc_conn_handler2).
-export([]).
-record(state, {cli_socket :: inet:socket(),
ext_socket :: inet:socket(),
cli_ip_port :: {ip_address(), ip_port()},
var Calcs = React.createClass({
getInitialState: function() {
return {count: ''};
},
handleClickNum: function(index) {
console.log("Adsads", index);
this.setState({count: index});
},
var Calcs = React.createClass({
getInitialState: function() {
return {count: ''};
},
handleClickNum: function(index) {
this.setState({count: index});
},
render: function() {
1> F = fun(N) -> list_to_atom(integer_to_list(N)), timer:sleep(infinity) end.
17> [spawn(fun() -> F(N) end) || N <- lists:seq(1, 100000)].
[<0.751.0>,<0.752.0>,<0.753.0>,<0.754.0>,<0.755.0>,
<0.756.0>,<0.757.0>,<0.758.0>,<0.759.0>,<0.760.0>,<0.761.0>,
<0.762.0>,<0.763.0>,<0.764.0>,<0.765.0>,<0.766.0>,<0.767.0>,
<0.768.0>,<0.769.0>,<0.770.0>,<0.771.0>,<0.772.0>,<0.773.0>,
<0.774.0>,<0.775.0>,<0.776.0>,<0.777.0>,<0.778.0>,<0.779.0>|...]
18> erlang:memory(atom_used).
2255590
19> erlang:memory(atom).
def user_register(session, username, password, email):
try:
new_user = User(name=username, email=email)
session.add(new_user)
session.commit()
return True, 'ok'
except exc.IntegrityError as e:
session.rollback()
code, msg = e.orig
print msg
@2garryn
2garryn / req.py
Last active August 29, 2015 14:18
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
name = Column(String(32), unique=True, nullable=False)
email = Column(String(64), unique=True, nullable=False)
password = Column(String(64), nullable=False)
class Device(Base):
__tablename__ = 'devices'
id = Column(Integer, primary_key=True)