Skip to content

Instantly share code, notes, and snippets.

View loretoparisi's full-sized avatar
🐍
NightShift

Loreto Parisi loretoparisi

🐍
NightShift
View GitHub Profile
@loretoparisi
loretoparisi / jquery_injection.js
Created October 18, 2017 21:15
Jquery Code Injection
script = document.createElement('script');script.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js";document.getElementsByTagName('head')[0].appendChild(script);
@loretoparisi
loretoparisi / fasttext_lid_training.sh
Last active January 28, 2018 09:28
FastText Language Detection - Training on macOS
#!bin/bash
# grab labeled dataset
wget http://downloads.tatoeba.org/exports/sentences.tar.bz2
bunzip2 sentences.tar.bz2
tar xvf sentences.tar
# macos only for gshuf
brew install coreutils
awk -F"\t" '{print"__label__"$2" "$3}' < sentences.csv | gshuf > all.txt
@loretoparisi
loretoparisi / fairseq-torch-install.sh
Last active June 12, 2017 12:36
FairSeq Torch Installation macOS
#torchnet
git clone https://github.com/torchnet/torchnet.git && cd torchnet
~/torch/install/bin/luarocks install rocks/torchnet-scm-1.rockspec
#torch-rnn
git clone https://github.com/facebookresearch/torch-rnnlib.git && cd torch-rnnlib/
~/torch/install/bin/luarocks make rocks/rnnlib-0.1-1.rockspec .
#argcheck
~/torch/install/bin/luarocks build https://raw.github.com/torch/argcheck/master/rocks/argcheck-scm-1.rockspec/Users/loretoparisi/torch/install/bin/luarocks build https://raw.github.com/torch/nn/master/rocks/nn-scm-1.rockspec
#moses
~/torch/install/bin/luarocks build https://raw.github.com/torch/moses/master/rockspec/moses-1.6.1-1.rockspec
@chretm
chretm / gist:fdcefce520ddfa1b66af3c730d4928c0
Created April 13, 2017 09:16
semantic-similarity-for-short-sentence_python3
#author : Sujit Pal
#Note: this is a python3 updated version of http://sujitpal.blogspot.fr/2014/12/semantic-similarity-for-short-sentences.html
# by mathieu Chrétien ([email protected])
#contributor : Mathieu Chrétien
from __future__ import division
import nltk
from nltk.corpus import wordnet as wn
@loretoparisi
loretoparisi / ffmpeg_frames.sh
Last active December 17, 2024 15:17
Extract all frames from a movie using ffmpeg
# Output a single frame from the video into an image file:
ffmpeg -i input.mov -ss 00:00:14.435 -vframes 1 out.png
# Output one image every second, named out1.png, out2.png, out3.png, etc.
# The %01d dictates that the ordinal number of each output image will be formatted using 1 digits.
ffmpeg -i input.mov -vf fps=1 out%d.png
# Output one image every minute, named out001.jpg, out002.jpg, out003.jpg, etc.
# The %02d dictates that the ordinal number of each output image will be formatted using 2 digits.
ffmpeg -i input.mov -vf fps=1/60 out%02d.jpg
@loretoparisi
loretoparisi / spread-op+camelcase+ucwords.js
Created December 1, 2016 13:59
JavaScript ucWords and CamelCase plus spread operator Array Concat example
var toCamelCase = function(str) {
return str
.replace(/\s(.)/g, function($1) { return $1.toUpperCase(); })
.replace(/\s/g, '')
.replace(/^(.)/, function($1) { return $1.toLowerCase(); });
}
var ucWords = function(str) {
return str.toLowerCase().replace(/\b[a-z]/g, function(letter) {
return letter.toUpperCase();
@Sorix
Sorix / WebViewWithProgressIndicatorController.swift
Last active April 4, 2024 19:23
NSViewController with WKWebView and progress indicator
//
// WebViewWithProgressIndicatorController
//
// Created by Vasily Ulianov on 29.11.16.
// Copyright © 2016 Vasily Ulianov. All rights reserved.
//
import Cocoa
import WebKit
@loretoparisi
loretoparisi / object+cycling.js
Created November 18, 2016 23:38
A cycling JavaScript object
XO=arr.reduce((obj,v) => obj.this=obj,new Object() )
@loretoparisi
loretoparisi / array_count+reduce.js
Created November 17, 2016 22:19
Count repeating occurences of Bag of Words in JavaScript by reduce
var r,words="We don't talk anymore\nWe don't talk anymore\nWe don't talk anymore\nLike we used to do\nWe don't love anymore\nWhat was all of it for?\nOh, we don't talk anymore\nLike we used to do\n\nI just heard you found the one you've been looking\nYou've been looking for"
words=words.split(/[\s]+/g);
r=[...words.reduce( (m, v) => m.set(v, (m.get(v) || 0) + 1), new Map() )];
console.log(r)
@loretoparisi
loretoparisi / bad-words.js
Last active September 15, 2018 20:44
combined regex for bad words match
[ /(cash[.,;:']?\s*[.!?]?\s*up[.,;:']?\s*[.!?]?\s*nigga[.,;:']?\s*[.!?]?\s*you)/,
/(up[.,;:']?\s*[.!?]?\s*nigga[.,;:']?\s*[.!?]?\s*you[.,;:']?\s*[.!?]?\s*aint)/,
/(nigga[.,;:']?\s*[.!?]?\s*you[.,;:']?\s*[.!?]?\s*aint[.,;:']?\s*[.!?]?\s*got)/,
/(my[.,;:']?\s*[.!?]?\s*cash[.,;:']?\s*[.!?]?\s*up[.,;:']?\s*[.!?]?\s*nigga)/,
/(cash[.,;:']?\s*[.!?]?\s*up[.,;:']?\s*[.!?]?\s*nigga[.,;:']?\s*[.!?]?\s*you)/,
/(up[.,;:']?\s*[.!?]?\s*nigga[.,;:']?\s*[.!?]?\s*you[.,;:']?\s*[.!?]?\s*aint)/,
/(nigga[.,;:']?\s*[.!?]?\s*you[.,;:']?\s*[.!?]?\s*aint[.,;:']?\s*[.!?]?\s*got)/,
/(for[.,;:']?\s*[.!?]?\s*a[.,;:']?\s*[.!?]?\s*ransom[.,;:']?\s*[.!?]?\s*nigga)/,
/(a[.,;:']?\s*[.!?]?\s*ransom[.,;:']?\s*[.!?]?\s*nigga[.,;:']?\s*[.!?]?\s*i)/,
/(ransom[.,;:']?\s*[.!?]?\s*nigga[.,;:']?\s*[.!?]?\s*i[.,;:']?\s*[.!?]?\s*aint)/,