This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE public.mytable SET | |
jsonfieldname = jsonb_set( jsonfieldname, '{json_obj_key}', array_to_json( | |
ARRAY( | |
SELECT DISTINCT( UNNEST( ARRAY( | |
SELECT json_array_elements_text( COALESCE( jsonfieldname::json->'json_obj_key', '[]' ) ) | |
) || ARRAY['Element to add'] ) ) | |
) | |
)::jsonb ) | |
WHERE id = 23 | |
RETURNING *; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE public.mytable SET | |
jsonfieldname = jsonb_set( jsonfieldname, '{json_obj_key}', array_to_json( | |
ARRAY( | |
SELECT DISTINCT( UNNEST( ARRAY( | |
SELECT json_array_elements_text( COALESCE( jsonfieldname::json->'json_obj_key', '[]' ) ) | |
) || ARRAY['Element to add'] ) ) | |
) | |
)::jsonb ) | |
WHERE id = 23 | |
RETURNING *; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(join_binries). | |
-export([join/2]). | |
join(TitleList, Sep) -> | |
Fun = fun(<<>>, Acc) -> | |
Acc; | |
(Word, Acc) -> | |
<<Acc/binary, Sep, Word/binary>> | |
end, | |
lists:foldl(Fun, hd(TitleList), tl(TitleList)). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
collections.map(function(coll) { | |
return { | |
type: "checkbox" | |
, callback: function() { console.log('this', this.checked) } | |
, checked: false | |
, text: coll.title | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################### | |
## Get timestamp with TZ | |
########################################### | |
from datetime import datetime | |
import time, pytz | |
mytz = pytz.timezone('Europe/Moscow') | |
print( int(time.mktime(mytz.localize(datetime.now()).timetuple())) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEBUG: Worker compilation failed: [{error, | |
{'EXIT', | |
{undef, | |
[{leex,file, | |
["src/protobuffs_scanner.xrl", | |
[{scannerfile, | |
"src/protobuffs_scanner.erl"}, | |
{return,true}]], | |
[]}, | |
{rebar_erlc_compiler,compile_xrl_yrl, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (data.result == 'ok'){ | |
for (var i = 0; i < self.type_results().length; i++) { | |
var el = self.type_results()[i]; | |
if (el.id == id) { | |
self.type_results.remove(el); | |
el.approved = true; | |
self.type_results.splice(i, 0, el); | |
break; // we found our id so can break the loop | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf8 | |
import pymongo | |
connection = pymongo.MongoClient('localhost', 27017) | |
db = connection.photos | |
albums = db.albums | |
images = db.images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ok, Viewers} = eredis:q(State#state.redis_pool, ["HGET", "channel:clients", Key]), | |
ViewersInt = list_to_integer(binary_to_list(Viewers)), | |
case ViewersInt > 0 of | |
true -> | |
eredis:q(State#state.redis_pool, ["HSET", "channel:clients", Key, 0]), | |
?D([Key, ViewersInt]), | |
net_pinger:set_billing(binary_to_list(Key), ViewersInt); | |
_ -> ok | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%%------------------------------------------------------------------- | |
%%% @author greg <> | |
%%% @copyright (C) 2012, greg | |
%%% @doc | |
%%% | |
%%% @end | |
%%% Created : 29 Nov 2012 by greg <> | |
%%%------------------------------------------------------------------- | |
-module(ring). |
NewerOlder