Skip to content

Instantly share code, notes, and snippets.

@nlothian
nlothian / fasttext_to_tensorboard.py
Created November 23, 2017 23:28
Convert a FastText model to a form suitable for viewing in Tensorboard
from tensorflow.contrib.tensorboard.plugins import projector
import tensorflow as tf
import numpy as np
import os
meta_file = "g2x_metadata.tsv"
output_path = "./projections"
# read embedding file into list and get the size
with open('./ft_model.vec', 'r') as embedding_file:
@DawidMyslak
DawidMyslak / vue.md
Last active April 22, 2024 12:49
Vue.js and Vuex - best practices for managing your state

Vue.js and Vuex - best practices for managing your state

Modifying state object

Example

If you have to extend an existing object with additional property, always prefer Vue.set() over Object.assign() (or spread operator).

Example below explains implications for different implementations.

@philleepflorence
philleepflorence / directus.endpoint.combine.php
Last active February 11, 2019 04:01
Directus Custom Endpoint - Combining Multiple Responses into One
<?php
use Directus\Bootstrap;
use Directus\View\JsonView;
use Directus\Database\TableGateway\RelationalTableGateway;
use Directus\Util\ArrayUtils;
use Directus\Util\DateUtils;
use Directus\Util\StringUtils;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mommi84
mommi84 / awesome-kge.md
Last active April 14, 2025 11:27
Awesome Knowledge Graph Embedding Approaches
@JosephRedfern
JosephRedfern / YouTube 8m Video ID scraper.py
Last active April 8, 2025 13:24
Scrapes the youtube video IDs for the youtube-8m data set. Probably buggy. Could be threaded.
import requests
from collections import defaultdict
csv_prefix = "https://research.google.com/youtube8m/csv"
r = requests.get("{0}/verticals.json".format(csv_prefix))
verticals = r.json()
block_urls = defaultdict(list)
count = 0
@philleepflorence
philleepflorence / urlstring.sql
Last active February 11, 2019 04:06
MySQL function for creating URL Safe Strings
CREATE FUNCTION `URLSTRING`( str VARCHAR(255) ) RETURNS varchar(255) CHARSET utf8
DETERMINISTIC
BEGIN
DECLARE result VARCHAR(255) DEFAULT '';
DECLARE i, len SMALLINT DEFAULT 1;
DECLARE c VARCHAR(1);
SET len = CHAR_LENGTH( str );
SET str = TRIM( str );
SET str = REPLACE( str, '-', ' ' ); # Replace all - with space
@infusion
infusion / create-mediawiki.sql
Created June 20, 2016 12:26
Mediawiki MySQL Table layout
-- SQL to create the initial tables for the MediaWiki database.
-- This is read and executed by the install script; you should
-- not have to run it by itself unless doing a manual install.
-- This is a shared schema file used for both MySQL and SQLite installs.
--
-- For more documentation on the database schema, see
-- https://www.mediawiki.org/wiki/Manual:Database_layout
--
-- notes:
@goodmami
goodmami / quotes.py
Created February 16, 2016 20:53
List of unicode quote symbols
# quote list: https://en.wikipedia.org/wiki/Quotation_mark
QUOTES = (
'\u0022' # quotation mark (")
'\u0027' # apostrophe (')
'\u00ab' # left-pointing double-angle quotation mark
'\u00bb' # right-pointing double-angle quotation mark
'\u2018' # left single quotation mark
'\u2019' # right single quotation mark
'\u201a' # single low-9 quotation mark
'\u201b' # single high-reversed-9 quotation mark
@philleepflorence
philleepflorence / utilities.js
Created January 4, 2016 23:06
Collection of utilities and helpers
/*
Dependencies: jQuery(v1.8), Underscore.js
Last Edited: 02/23/2015
*/
"use strict";
var UTILITIES = function()
{
var utils = this;