Skip to content

Instantly share code, notes, and snippets.

@tslmy
tslmy / install_mosh_locally.sh
Last active November 21, 2017 14:47 — forked from lazywei/install_mosh_locally.sh
Install mosh server without root permission
#!/bin/sh
# this script does absolutely ZERO error checking. however, it worked
# for me on a RHEL 6.3 machine on 2012-08-08. clearly, the version numbers
# and/or URLs should be made variables. cheers, [email protected]
mkdir mosh
cd mosh
@tslmy
tslmy / x_means.py
Last active November 17, 2017 22:24 — forked from yasaichi/x_means.py
Implementation of X-means clustering in Python
"""
以下の論文で提案された改良x-means法の実装
クラスター数を自動決定するk-meansアルゴリズムの拡張について
http://www.rd.dnc.ac.jp/~tunenori/doc/xmeans_euc.pdf
"""
import numpy as np
from scipy import stats
from sklearn.cluster import KMeans
@tslmy
tslmy / kth-smallest-element-in-union-of-two-sorted-arrays.md
Last active September 25, 2017 21:25 — forked from kentor/kth-smallest-element-in-union-of-two-sorted-arrays.md
kth smallest element in the union of two sorted arrays

Given two sorted arrays, A of length N where N in [0, inf), and B of length M in [0, inf), find the kth smallest element in the union U = A u B in sub O(k) time.

Most of the solutions that I have googled do not consider the case where N and M can be as small as 0, but this solution does.

The strategy to this problem is to chop off part of the arrays that we know can't be the kth element. In doing so, when we recurse on the smaller arrays, the number 'k' will change to reflect tossing out elements smaller than the kth element. The base case is when either one of the arrays is empty, the kth smallest element is the the non-empty array at index k-1:

def kth_smallest(k, a, b)
  return b[k-1] if a.empty?
  return a[k-1] if b.empty?
@tslmy
tslmy / README.md
Last active August 11, 2018 18:03 — forked from mmasashi/README.md
Install Oracle instant client (sqlplus) v12.1 on macOS

Install Oracle instant client (sqlplus) on MacOSX

  1. Get Oracle instant client for MacOSX
  1. Unarchive downloaded zip files into a same directory
  • ex: $HOME/Downloads/instantclient_12_1
  1. Create install.sh inside this instantclient_12_1 folder and copy the following code and past it on that file.
@tslmy
tslmy / Bullseye.js
Last active July 9, 2016 14:15 — forked from ttscoff/Bullseye.bookmarklet
A bookmarklet for grabbing just a piece of a web page and converting it to Markdown using heckyesmarkdown.com.
// version 0.5
// Uses nvALT.
// Not using remote/external loading because it is often blocked by allowed-origin.
// Now serves under HTTPS.
// version 0.4
// Bugfix for Firefox
//
// Bullseye 0.3
// Add escape key to cancel
@tslmy
tslmy / css_resources.md
Created April 9, 2016 20:23 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@tslmy
tslmy / python_resources.md
Created April 9, 2016 20:23 — forked from jookyboi/python_resources.md
Python-related modules and guides.

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides

@tslmy
tslmy / javascript_resources.md
Created April 9, 2016 20:23 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@tslmy
tslmy / scrollbar_example.css
Last active January 6, 2022 12:45 — forked from tpitale/scrollbar_example.css
Supports horizontal scrollbar now. I removed the scrollbar buttons.
::-webkit-scrollbar {
width: 5px;
height:5px;
}
::-webkit-scrollbar-thumb {
background-color: #999;
border-radius: 5px;
}