Skip to content

Instantly share code, notes, and snippets.

View champierre's full-sized avatar

Junya Ishihara champierre

View GitHub Profile
@champierre
champierre / gist:2135971
Created March 20, 2012 14:05
Steps to make Android APK file created by App Inventor publishable
# apktool d -s sample.apk sample
# cd sample
# vi AndroidManifest.xml
- Add android:versionCode="1" to manifest tag
- Add android:versionName="1.0" to manifest tag
- Delete android:debuggable="true" from application tag
# apktool b sample sample-m.apk
# jarsigner -keystore sample.keystore -signedjar sample-s.apk sample-m.apk alias
@champierre
champierre / ekitan.user.js
Created May 30, 2012 09:09
ekitan greasemonkey script
// ==UserScript==
// @title ekitan
// @description Automatically fill out the boarding station.
// @namespace http://blog.champierre.com
// @include http://ekitan.com/
// ==/UserScript==
document.getElementById('sfname').value = '柴崎';
document.getElementById('stname').select();
image = UIImage.imageNamed("icon.png")
@image_view = UIImageView.alloc.initWithImage(image)
@image_view.frame = CGRectMake(0, 0, 36, 36)
view.addSubview(@image_view)
@champierre
champierre / app_delegate.rb
Created June 15, 2012 17:07
RubyMotionSamples/Countries.app
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
@window.backgroundColor = UIColor.whiteColor
label = UILabel.alloc.initWithFrame @window.frame
label.textAlignment = UITextAlignmentCenter
label.text = "Tap!"
BubbleWrap::HTTP.get("http://www.geognos.com/api/en/countries/info/all.json") do |response|
@champierre
champierre / gist:3753734
Last active October 10, 2015 21:28
How to change user agent on iOS
NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:@"custom user agent", @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
[dictionary release];
@champierre
champierre / gist:3792867
Created September 27, 2012 08:23
replace a button in appbar on windows 8 app
var appbar = document.getElementById("appbar");
var button = document.createElement("button");
button.setAttribute("data-win-control", "WinJS.UI.AppBarCommand");
// id, label, icon are dynamically set. button.setAttribute("type", "button");
button.setAttribute("data-win-options", "{id:'" + id + "', label:'" + label + "', icon:'" + icon + "'}");
WinJS.UI.process(button); appbar.appendChild(button);
@champierre
champierre / gist:3792928
Created September 27, 2012 08:40
Reload the contents of iframe on Windows Metro Style App
== in the page in iframe
<script type="text/javascript">
window.attachEvent("onmessage", receiveMessage);
function receiveMessage(e) {
if (e.data == "refresh") {
history.go(0);
}
}
@champierre
champierre / gist:4337114
Created December 19, 2012 14:41
Get the brightness of hex color
# e.g.
# brightness("#ffffff") = (255/255.0 + 255/255.0 + 255/255.0)/3.0 = 1.0
# brightness("#000000") = (0/255.0 + 0/255.0 + 0/255.0)/3.0 = 0.0
# brightness("#666666") = (102/255.0 + 102/255.0 + 102/255.0)/3.0 = 0.4
def brightness(color):
rgb = struct.unpack('BBB', color[1:].decode('hex'))
brightness = 0
for x in rgb:
brightness += x / 255.0
return brightness / 3.0
@champierre
champierre / docs.komagata.org.js
Created April 12, 2013 16:35
Freeze the *really* annoying icon of http://docs.komagata.org/. Requires dotjs(https://github.com/defunkt/dotjs).
$('img#icon').attr('src', 'https://si0.twimg.com/profile_images/3340669721/467addf220d4d1383fa025996cb09d49_bigger.png');
require "scratchrsc"
class PrintRSC < RSCWatcher
def on_broadcast(name) # when a broadcast is sent
puts "broadcast #{name}" # print it to the screen
end
def on_sensor_update(name,value) # when a variable or sensor is updated
puts "#{name} = #{value}" # print the change to the screen
if name == "test"
@test = value