Skip to content

Instantly share code, notes, and snippets.

@nanofi
nanofi / Helper.kt
Last active October 27, 2019 04:25
Workaround for fixing the issue where NavigationView does not correctly control `IsChecked` of the submenus
class Helper {
companion object {
fun setupWithNavController(navigationView: NavigationView, navController: NavController) {
navigationView.setNavigationItemSelectedListener { item ->
val handled = NavigationUI.onNavDestinationSelected(item, navController)
if (handled) {
val parent = navigationView.parent
if (parent is DrawerLayout) {
parent.closeDrawer(navigationView)
@nanofi
nanofi / count.sty
Created February 5, 2015 16:15
The macros for exporting and importing the counters by using `zref`
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{count}
[2015/2/6 v0.01 Import and Export counters ]
\RequirePackage[lastpage,xr]{zref}
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\newtheorem{proposition}{Proposition}
\newtheorem{corollary}{Corollary}
@nanofi
nanofi / controller_helpers.rb
Created December 23, 2014 18:50
Controller test helpers for `rails_warden`. Almost of this code is extracted from Devise::TestHelpers.
module ControllerHelpers
def self.included(base)
base.class_eval do
setup :setup_controller_for_warden, :warden if respond_to?(:setup)
end
end
def process(*)
_catch_warden {super} || @response
end
@nanofi
nanofi / jplainnat.bst
Created October 10, 2014 16:17
A modification of `plainnat.bst` for japanese citations
%% File: `jplainnat.bst'
%% A modification of `plainnat.bst' for japanese citations
%%
%% Copyright 2014 Kazuto Fukuchi
%% E-mail: nanogenomu@gmail.com
%%
%
ENTRY
{ address
author
@nanofi
nanofi / Readme.apt.md
Created June 2, 2014 03:19
Patch pyipopt (https://github.com/xuy/pyipopt) so that its dependencies install with apt.

Install dependencies with apt

Install the library file of ipopt using:

$ sudo apt-get install coinor-libipopt1 coinor-libipopt-dev libmumps-seq-4.9.2

\newcommand{\p}[1]{{\rm Pr}(#1)}
\renewcommand{\vec}[1]{{\boldsymbol #1}}
\newcommand{\mat}[1]{{\boldsymbol #1}}
\newcommand{\set}[1]{#1}
\newcommand{\fset}[1]{{\mathcal #1}}
\newcommand{\family}[1]{{\mathcal #1}}
\newcommand{\Mean}[2][]{{\rm E}_{#1}\left[ #2 \right]}
\newcommand{\Var}[2][]{{\rm Var}_{#1}[#2]}
\newcommand{\Cov}[3][]{{\rm Cov}_{#1}[#2,#3]}
@nanofi
nanofi / pickle.py
Created December 25, 2013 06:12
The code be enabled to pickle the function
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from __future__ import unicode_literals
__author__ = "nanofi <nanogenomu@gmail.com>"
__version__ = "1.0.0"
__date__ = "2013/12/25"
__license__ = "MIT License http://opensource.org/licenses/mit-license.php"
@nanofi
nanofi / Test.java
Created September 26, 2012 12:29
Generics Test class
public class Test{
public static interface FA<T extends Runnable> {
void hello();
T get();
}
public static interface FB {
void world();
}
@nanofi
nanofi / ClassNameDataTemplateSelector.cs
Created September 21, 2012 05:32
DataTemplateSelector condition with item class name
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Markup;
namespace Nanofi.Common{
@nanofi
nanofi / mecab.rb
Created June 14, 2012 00:08
Call libmecab.dll from Ruby
require "dl/import"
#libmecab.dllのpathは自分で変えてね
module MecabImporter
extend DL::Importer
path = 'C:/Program Files (x86)/MeCab/bin/libmecab.dll'
dlload path
extern "mecab_t* mecab_new2(const char*)"