Skip to content

Instantly share code, notes, and snippets.

Avatar

nanofi nanofi

  • Japan
View GitHub Profile
@nanofi
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) {
parent.closeDrawer(navigationView)
@nanofi
nanofi / count.sty
Created Feb 5, 2015
The macros for exporting and importing the counters by using `zref`
View count.sty
\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 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)
end
end
def process(*)
_catch_warden {super} || @response
end
@nanofi
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: nanogenomu@gmail.com
%%
%
ENTRY
{ address
author
@nanofi
nanofi / Readme.apt.md
Created Jun 2, 2014
Patch pyipopt (https://github.com/xuy/pyipopt) so that its dependencies install with apt.
View Readme.apt.md

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{\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 Dec 25, 2013
The code be enabled to pickle the function
View pickle.py
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 Sep 26, 2012
Generics Test class
View Test.java
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 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
nanofi / mecab.rb
Created Jun 14, 2012
Call libmecab.dll from Ruby
View mecab.rb
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*)"
You can’t perform that action at this time.