Skip to content

Instantly share code, notes, and snippets.

⛵️
Real artists ship

Julien Chaumond julien-c

⛵️
Real artists ship
Block or report user

Report or block julien-c

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:7895c3d39052c31d08e70ed0dfcf3c9b
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>
~~~
View spacy.py
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.
View nlp2.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 Aug 30, 2017
iOS 11 NLP demo
View nlp.swift
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 {
View patch.transmission.js
Index: web/javascript/transmission.js
===================================================================
--- web/javascript/transmission.js (revision 14528)
+++ web/javascript/transmission.js (working copy)
@@ -519,43 +519,43 @@
},
dragenter: function(ev) {
- if (ev.dataTransfer && ev.dataTransfer.types) {
- var types = ["text/uri-list", "text/plain"];
@julien-c
julien-c / jquery-ui.custom.min.js
Created May 1, 2015
Custom build of jQuery UI sortable
View jquery-ui.custom.min.js
/*! jQuery UI - v1.11.4 - 2015-05-01
* http://jqueryui.com
* Includes: core.js, widget.js, mouse.js, sortable.js
* Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */
(function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e(jQuery)})(function(e){function t(t,s){var n,a,o,r=t.nodeName.toLowerCase();return"area"===r?(n=t.parentNode,a=n.name,t.href&&a&&"map"===n.nodeName.toLowerCase()?(o=e("img[usemap='#"+a+"']")[0],!!o&&i(o)):!1):(/^(input|select|textarea|button|object)$/.test(r)?!t.disabled:"a"===r?t.href||s:s)&&i(t)}function i(t){return e.expr.filters.visible(t)&&!e(t).parents().addBack().filter(function(){return"hidden"===e.css(this,"visibility")}).length}e.ui=e.ui||{},e.extend(e.ui,{version:"1.11.4",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),e.fn.extend({scrollParent:function(t){var i=this.css("position"),s="absolute"===i,n=t?/(auto|scroll|hidden)/:/(auto
@julien-c
julien-c / BrowseNodes-flat.json
Last active Aug 29, 2015
BrowseNodes-flat.json
View BrowseNodes-flat.json
{
"1000": {
"Name": "Books",
"Children": [
{
"BrowseNodeId": 1,
"Name": "Arts & Photography",
"hasChildren": true
},
{
View queue.py
class Queue:
def __init__(self):
self.stacks = ([], [])
self.reversed = False
def _reverse(self):
i, j = (0, 1) if self.reversed else (1, 0)
while len(self.stacks[i]):
@julien-c
julien-c / queue.py
Created Feb 28, 2014
Queue using two stacks
View queue.py
class Queue:
def __init__(self):
self.stack1 = []
self.stack2 = []
self.reversed = False
def enqueue(self, item):
if self.reversed is False:
View gist:7470166
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) {
You can’t perform that action at this time.