Skip to content

Instantly share code, notes, and snippets.

@cobysy
cobysy / uninstall-virtualenv.md
Created September 7, 2018 20:55
How-to uninstall virtualenv

sudo -i
PIP_REQUIRE_VIRTUALENV=false pip uninstall virtualenv

@cobysy
cobysy / orderBy.ts
Created August 25, 2018 13:27
TypeScript orderBy
declare global {
interface Array<T> {
sortBy(selector: (elem: T) => any): T[];
}
}
if (!Array.prototype.sortBy) {
Array.prototype.sortBy = function <T>(selector: (elem: T) => any): T[] {
return this.sort((a, b) => {
return selector(a) < selector(b) ? -1 : 1;
@cobysy
cobysy / JMdict_e.js
Created August 5, 2018 22:30
download JMdict_e.gz with node.js
const http = require('http');
const url = require('url');
const path = require('path');
const fs = require('fs');
function wget(source, { onStart, onProgress } = {}) {
return new Promise(function(y, n) {
const output = path.basename(url.parse(source).pathname);
const req = http.request(source,
@cobysy
cobysy / rsync.sh
Created August 5, 2018 16:51
rsync JMdict_e
#!/bin/sh
# v = verbose
# z = reduce the network transfer by adding compression
# P = combines the flags --progress and --partial.
# The first of these gives you a progress bar for the transfers and the second allows you to resume interrupted transfers
rsync -vzP ftp.edrdg.org::nihongo/JMdict_e .
@cobysy
cobysy / install-tensorflow-anaconda-osx.md
Created March 29, 2018 20:44
install-tensorflow-anaconda-osx

Was facing this stupid error message:

~/anaconda3 ❯❯❯ bin/conda install tensorflow Solving environment: failed

UnsatisfiableError: The following specifications were found to be in conflict:

  • scikit-image -> numpy[version='>=1.13.3,<2.0a0']
  • tensorflow Use "conda info " to see the dependencies for each package.
@cobysy
cobysy / TextFileEncodingDetector.cs
Created August 14, 2017 14:40 — forked from TaoK/TextFileEncodingDetector.cs
Simple class to automatically detect text file encoding, with English-biased "best guess" heuristic based on byte patterns in the absence of BOM.
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
namespace KlerksSoft
{
public static class TextFileEncodingDetector
{
/*
@cobysy
cobysy / AutoFixture-notes.cs
Created June 26, 2017 00:28
AutoFixture notes
// In order to inject dependencies through constructor parameters,
// use greedy constructor selection (versus modest constructor query/ModestConstructorQuery)
// http://blog.ploeh.dk/2011/04/19/ConstructorstrategiesforAutoFixture/
//
// OmitAutoProperties to stop it from mocking out properties
// See https://github.com/AutoFixture/AutoFixture/issues/320 for combo of GreedyConstructorQuery and OmitAutoProperties
AutoFixture.Customize<T>(c => c.FromFactory(new MethodInvoker(new GreedyConstructorQuery())).OmitAutoProperties());
// Trace construction of objects
AutoFixture.Behaviors.Add(new TracingBehavior());
@cobysy
cobysy / Cadence Pyramid Workout.md
Last active April 23, 2017 02:51
Cadence Pyramid Workout

Warm-up 10 minutes. Build up from easy to a steady pace for a few minutes.

Cadence pyramids Do the following progression two to three times with 10 minutes of easy/steady riding in between:

  • 100 r.p.m.
  • 105 r.p.m.
  • 110 r.p.m.
  • 115 r.p.m.
  • 120 r.p.m.
@cobysy
cobysy / how-to-delete-b2c-tenant.txt
Last active June 30, 2016 08:39
not-able-to-delete-b2c-tenant?
https://social.msdn.microsoft.com/Forums/azure/en-US/afbfb7b3-92c9-4af6-9128-ba96795de5a6/not-able-to-delete-b2c-tenant?forum=WindowsAzureAD
Please follow the following steps:
Create Temporary Admin Account
1. Open a browser and login to https://manage.windowsazure.com
2. In the left hand menu navigate to Active Directory, and select your directory
3. Click Users and Groups > Add User
4. Create this user with a username of [email protected] and be sure to grant this user the role Global Administrator