Skip to content

Instantly share code, notes, and snippets.

nanofi / Helper.kt
Last active Oct 27, 2019
Workaround for fixing the issue where NavigationView does not correctly control `IsChecked` of the submenus
View Helper.kt
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) {
nanofi / count.sty
Created Feb 5, 2015
The macros for exporting and importing the counters by using `zref`
View count.sty
[2015/2/6 v0.01 Import and Export counters ]
nanofi / controller_helpers.rb
Created Dec 23, 2014
Controller test helpers for `rails_warden`. Almost of this code is extracted from Devise::TestHelpers.
View controller_helpers.rb
module ControllerHelpers
def self.included(base)
base.class_eval do
setup :setup_controller_for_warden, :warden if respond_to?(:setup)
def process(*)
_catch_warden {super} || @response
nanofi / jplainnat.bst
Created Oct 10, 2014
A modification of `plainnat.bst` for japanese citations
View jplainnat.bst
%% File: `jplainnat.bst'
%% A modification of `plainnat.bst' for japanese citations
%% Copyright 2014 Kazuto Fukuchi
%% E-mail:
{ address
nanofi /
Created Jun 2, 2014
Patch 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 
View gist:8313448
\newcommand{\p}[1]{{\rm Pr}(#1)}
\renewcommand{\vec}[1]{{\boldsymbol #1}}
\newcommand{\mat}[1]{{\boldsymbol #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 /
Created Dec 25, 2013
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 <>"
__version__ = "1.0.0"
__date__ = "2013/12/25"
__license__ = "MIT License"
nanofi /
Created Sep 26, 2012
Generics Test class
public class Test{
public static interface FA<T extends Runnable> {
void hello();
T get();
public static interface FB {
void world();
nanofi / ClassNameDataTemplateSelector.cs
Created Sep 21, 2012
DataTemplateSelector condition with item class name
View ClassNameDataTemplateSelector.cs
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 / mecab.rb
Created Jun 14, 2012
Call libmecab.dll from Ruby
View mecab.rb
require "dl/import"
module MecabImporter
extend DL::Importer
path = 'C:/Program Files (x86)/MeCab/bin/libmecab.dll'
dlload path
extern "mecab_t* mecab_new2(const char*)"