Skip to content

Instantly share code, notes, and snippets.

@Narsil
Narsil / gist:4023812
Created November 6, 2012 10:01
Project euler
// Tested on http://writecodeonline.com/php/
$triangle = array(
array(
3
),array(
7, 4
),array(
2, 4, 6
),array(
8, 5, 9, 3
package main
import (
"time"
"net/http"
"net/smtp"
"fmt"
)
func sendMail(body string) error{
Standard BPE eBPE
'th' '\r\n'
'the ' ', '
'an' 'd '
'in' 'Th'
'ou' 've'
'er' 'y '
'ed ' '; '
'ar' 'f '
'hi' ',\r\n'
Promotion # Token created
338 "Mr. Fogg"
357 "Phileas Fogg"
360 "Passepartout"
635 "ir Franc" (Sir Francis)
781 "It was"
900 '" asked' (contains a quote character)

Keybase proof

I hereby claim:

  • I am narsil on github.
  • I am narsil (https://keybase.io/narsil) on keybase.
  • I have a public key ASA0iSmgSGy3xxf0r7decSA-ORbe1JE3EzQDA-m_SAnGmAo

To claim this, I am signing this object:

@Narsil
Narsil / word_count.rs
Created May 22, 2020 18:11
Small example to get lower bound of word counting of a file.
use rayon::prelude::*;
use std::collections::HashMap;
fn main() {
let buf = std::fs::read_to_string("data/big.txt").unwrap();
let word_count = buf
.par_lines()
.map(|line| {
let mut frequency: HashMap<&str, u32> = HashMap::new();
for word in line.split(' ') {
# Scripts-9.0.0.txt
# Date: 2016-06-01, 10:34:37 GMT
# © 2016 Unicode®, Inc.
# Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the U.S. and other countries.
# For terms of use, see http://www.unicode.org/terms_of_use.html
#
# Unicode Character Database
# For documentation, see http://www.unicode.org/reports/tr44/
# For more information, see:
# UAX #24, Unicode Script Property: http://www.unicode.org/reports/tr24/
#!/usr/bin/perl
# Copyright 2016 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
from transformers import pipeline
import time
n = 50
nlp_token_class_cpu = pipeline("ner")
start = time.time()
resp = nlp_token_class_cpu(["Hugging Face is a French company based in New-York."] * n)
print("Device: CPU")
print(f"No. examples: {n}")
@Narsil
Narsil / drift.py
Created May 26, 2021 16:40
Drift of GPT2 when reusing cache too much
TEXT = """Mr. Phileas Fogg lived, in 1872, at No. 7, Saville Row, Burlington
Gardens, the house in which Sheridan died in 1814. He was one of the
most noticeable members of the Reform Club, though he seemed always to
avoid attracting attention; an enigmatical personage, about whom little
was known, except that he was a polished man of the world. People said
that he resembled Byron--at least that his head was Byronic; but he was
a bearded, tranquil Byron, who might live on a thousand years without
growing old.
Certainly an Englishman, it was more doubtful whether Phileas Fogg was