Skip to content

Instantly share code, notes, and snippets.

View julien-c's full-sized avatar
Real artists ship

Julien Chaumond julien-c

Real artists ship
View GitHub Profile
@julien-c
julien-c / ec2instances.md
Created April 3, 2020 20:12
simple markdown table of AWS instance types with vCPU/RAM/price (us-east-1)
API Name Memory vCPUs Physical Processor Network Performance Linux On Demand cost Linux Reserved cost
a1.2xlarge 16.0 GiB 8 vCPUs AWS Graviton Processor Up to 10 Gigabit $148.92 monthly $93.80 monthly
a1.4xlarge 32.0 GiB 16 vCPUs AWS Graviton Processor Up to 10 Gigabit $297.84 monthly $187.61 monthly
a1.large 4.0 GiB 2 vCPUs AWS Graviton Processor Up to 10 Gigabit $37.23 monthly $23.43 monthly
a1.medium 2.0 GiB 1 vCPUs AWS Graviton Processor Up to 10 Gigabit $18.61 monthly $11.75 monthly
a1.metal 32.0 GiB 16 vCPUs AWS Graviton Processor Up to 10 Gigabit $297.84 monthly $187.61 monthly
a1.xlarge 8.0 GiB 4 vCPUs AWS Graviton Processor Up to 10 Gigabit $74.46 monthly $46.93 monthly
c1.medium 1.7 GiB 2 vCPUs Intel Xeon Family Moderate $94.90 monthly $66.43 monthly
Map(98) {
'unspecified' => 6519,
'unknown' => 230,
'cc-by-4.0' => 131,
'cc-by-sa-4.0' => 76,
'mit' => 73,
'apache-2.0' => 41,
'cc0-1.0' => 40,
'cc-by-nc-sa-4.0' => 36,
'cc-by-nc-4.0' => 21,
import os
import subprocess
from huggingface_hub.hf_api import HfApi
from huggingface_hub.repository import Repository
os.makedirs("./Helsinki-NLP/", exist_ok=True)
os.environ["GIT_LFS_SKIP_SMUDGE"] = "1"
# Important, to not download the large files
@julien-c
julien-c / ModelInfo.ts
Last active October 15, 2020 20:46
Model tag <=> pipeline type logic, for public reference
export class ModelInfo {
/**
* Key to config.json file.
*/
key: string;
etag: string;
lastModified: Date;
size: number;
modelId: ModelId;
author?: AuthorId;
import logging
from transformers.modeling_bart import BartForSequenceClassification
from transformers.pipelines import TextClassificationPipeline
from transformers.tokenization_bart import BartTokenizer
logging.basicConfig(level=logging.INFO)
To get it to work please follow the steps:
1) Create test user by toggling the Authorize test users for this app and grant permissions "manage_pages" and "page_messaging".
2) Use the Edit Button and get an access token for this user (using v2.6). Please save this for later.
3) Use edit button to login as the test user
4) After login, create page as the test user
5) Use the user access token for the test user to get the page access token for this user. You can do this with the following call:
~~~
https://graph.facebook.com/v2.6/me/accounts?access_token=<TEST_USER_ACCESS_TOKEN>
~~~
@julien-c
julien-c / spacy.py
Created August 30, 2017 15:50
Spacy NER
import spacy
nlp = spacy.load('en')
doc = nlp(text)
# At this point entity annotations are in `doc.ents`
for token in doc:
print tok.ent_iob_ + '-' + mapping[tok.ent_type_] # `I-PER`, etc.
@julien-c
julien-c / nlp2.swift
Created August 30, 2017 13:57
Nlp Swift
func handleSentence(s: [Token]) {
let text = s.map { $0.text }.joined(separator: " ")
tagger.string = text
var charIdx = 0
var prevDescr = "O"
for tok in s {
let iosTag = tagger.tag(at: charIdx, unit: .word, scheme: .nameType, tokenRange: nil)
let iosDescr = iosTag?.canonical ?? "O"
let outputLine = "\(tok.text) \(tok.goldTag) \(iob(iosDescr, prevDescr))"
output.append(outputLine)
@julien-c
julien-c / nlp.swift
Created August 30, 2017 13:53
iOS 11 NLP demo
let tagger = NSLinguisticTagger(tagSchemes: [.nameType], options: 0)
let dataset: Dataset = .test
let url = Bundle.main.url(forResource: dataset.rawValue, withExtension: "txt")!
let content = try! String(contentsOf: url, encoding: .utf8).components(separatedBy: ["\n"])
var output: [String] = []
/// Map ios nlp tags to canonical tags.
extension NSLinguisticTag {
var canonical: String {
switch self {
@julien-c
julien-c / gist:7470166
Created November 14, 2013 16:49
Mongo crash
Thu Nov 14 17:47:37.470 [conn2] command reaaad.$cmd command: { mapreduce: "annotations", query: { document: ObjectId('51753af7d228eb21cab1ba1d') }, map: CodeWScope( function() {
var score = 1 + (this.score || 0) + (this.reposters ? this.reposters.length : 0);
emit(this.user, score);
}, {}), reduce: CodeWScope( function(k, values) {
return Array.sum(values);
}, {}), out: { inline: true } } ntoreturn:1 keyUpdates:0 locks(micros) r:41960 reslen:125 125ms
Thu Nov 14 17:47:37.910 [conn2] command reaaad.$cmd command: { mapreduce: "annotations", query: { document: ObjectId('51c8127cd228eb02862c8d38') }, map: CodeWScope( function() {
var score = 1 + (this.score || 0) + (this.reposters ? this.reposters.length : 0);
emit(this.user, score);
}, {}), reduce: CodeWScope( function(k, values) {