Skip to content

Instantly share code, notes, and snippets.

View oxydron's full-sized avatar

Ben Hur Bahia do Nascimento oxydron

  • COCUS Portugal
View GitHub Profile
def tokenizer(p, n=2):
p = '$' + p +'#'
tk_index = {}
tokens = []
for i in range(len(p)-1):
tk = p[i:i+n]
if tk in tk_index:
tk_index[tk] += 1
tokens.append(tk+str(tk_index[tk]))
def tokenizer(p, n=2):
p = '$' + p +'#'
tk_index = {}
tokens = []
for i in range(len(p)-1):
tk = p[i:i+n]
if tk in tk_index:
tk_index[tk] += 1
tokens.append(tk+str(tk_index[tk]))
else:
@oxydron
oxydron / pubsub_google_cloud_example.dart
Created December 10, 2019 12:57
Google Cloud Dart API pubsub example code. I'm sharing this code to help those that will try to use this lib on dart and maybe will find the docs poor to achieve this example.
import 'package:googleapis/pubsub/v1.dart';
import 'package:googleapis_auth/auth_io.dart';
import 'credentials.dart';
const _SCOPES = const [PubsubApi.PubsubScope];
Future<PublishResponse> pubsubExample(Map<String, String> data) =>
clientViaServiceAccount(PUBLISH_PUBSUB_CREDENTIALS, _SCOPES).then((http) {
PubsubMessage msg = PubsubMessage();
msg.attributes = data;