Skip to content

Instantly share code, notes, and snippets.

View tnj's full-sized avatar

Yuki Fujisaki tnj

View GitHub Profile
@tnj
tnj / find_closest_created_at.rb
Last active November 12, 2019 07:44
Efficiently finds a record by creation time in a huge table even without having index on created_at
class ActiveRecord::Base
# @param [Time] created_at
# @return [ActiveRecord::Base]
def self.find_closest_created_at(created_at)
return if self.last.created_at < created_at
high = self.last.id
low = self.first.id
while low <= high
@tnj
tnj / gist:a00bdb43dcbc2a0e1f2d
Created April 2, 2015 07:35
Opening DeployGate application details activity from your app
public void openDeployGateApp() {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setPackage("com.deploygate");
// set your app URL
i.setData(Uri.parse("https://deploygate.com/users/YOURNAME/apps/com.example.test"));
// or for distribution page
// i.setData(Uri.parse("https://deploygate.com/distributions/abcdef1234567890"));
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
}
@tnj
tnj / vagrant-wrapper.sh
Last active October 15, 2015 08:20
Vagrant ssh-config cache wrapper for IntelliJ Vagrant plugin
#!/bin/sh
# This script is a quick hack/workaround for
# https://youtrack.jetbrains.com/issue/PY-12711
#
# Open settings and set this script as an alternative to `vagrant` command
# to minimize lag in Vagrant plugin of IntelliJ IDEA (RubyMine, etc.)
VAGRANT="/usr/bin/vagrant"
CACHE_BASE="/tmp/vagrant-ssh-config"
@tnj
tnj / Mac
Created July 1, 2014 16:55
15分ではじめるAndroid Wear開発 - 実機を使った開発環境の作り方 ref: http://qiita.com/tnj/items/83c41872125f01588068
$ cd /Applications/Android\ Studio.app/sdk/platform-tools/
$ ./adb forward tcp:4444 localabstract:/adb-hub
$ ./adb connect localhost:4444
connected to localhost:4444
@tnj
tnj / gist:4193280
Created December 3, 2012 07:10
DeployGate with Unity

Preparation

Code (C#)

On your app startup, install DeployGate into your process:

@tnj
tnj / SharedPreferencesPatch.java
Created June 22, 2012 08:08
Samsung Galaxy S 2.2.1 broken /dbdata/databases workaround
/*
* Copyright (C) 2012 Yuki Fujisaki
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software