Skip to content

Instantly share code, notes, and snippets.

View rockymanobi's full-sized avatar

TAKANORI KOROKI rockymanobi

View GitHub Profile
@rockymanobi
rockymanobi / copy_github_issue.js
Last active August 14, 2020 07:46
Bookmarklet that copies URL, title, content of Github Issue
javascript:(function(){ function copyTextToClipboard(textVal){ const copyFrom = document.createElement("textarea"); copyFrom.textContent = textVal; const bodyElm = document.getElementsByTagName("body")[0]; bodyElm.appendChild(copyFrom); copyFrom.select(); const retVal = document.execCommand('copy'); bodyElm.removeChild(copyFrom); return retVal; } const href = location.href; const title = document.querySelector('.js-issue-title').innerHTML.trim(); const issue = document.querySelector('textarea[name="issue[body]"]').value; const text = [href, title, issue].join('\n\n#######\n\n'); alert(text); copyTextToClipboard(text); }())
function startListeningKeyDownEvent(){
$(window).keydown(function(e){
// put the keycode pressed to console
console.log(e.keyCode);
// if it's Enter key, trigger click event on mic button
if( e.keyCode + '' === '13' ){
$('button[mic-id="all"]').trigger('click')
}
return false;
});
@rockymanobi
rockymanobi / capture_image.js
Created December 3, 2014 10:30
Show Image from HTML5 File API
$(document)
.on('change', "#image-file", function() {
if (!this.files.length) {
return;
}
var file = this.files[0];
var $_img = $("#image");
var fileReader = new FileReader();
fileReader.onload = function(event) {
return $_img.attr("src", event.target.result);
@rockymanobi
rockymanobi / CSS3_Drawer_Navigation.md
Last active August 29, 2015 14:02
CSS3 Drawer Navigation

Overview

A sample implementation of drawer navigation for Safari on iPad. The basic specification is following...

  • By pressing the navigation buttons, sub contents will appear from left and bottom of the window.
  • The image always fit the main window by using transition: scale, even when the main window is squashed by the sub contents.

GetStarted

You can just download this gist and open index.html with your browser, or upload them to some where, and access to index.html from your iPad.

@rockymanobi
rockymanobi / espruino_query_string.js
Last active August 29, 2015 14:01
Espruino, build query string from object
function queryString( a ) {
var prefix,
s = [],
add = function( key, value ) {
value = value === null ? "" : value;
s[ s.length ] = key + "=" + value;
};
var buildParams = function( prefix, obj, add ) {
var name;
if ( Array.isArray( obj ) ) {
@rockymanobi
rockymanobi / espruino_post.js
Last active August 29, 2015 14:01
A wrapper function of "http.request" to execute POST request.
// Wrapper function of "http.request" to execute POST request.
function post( options, queryString, callback ){
var http = require("http"); // should be an argument???
// complete the options
options.headers = options.headers || {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': queryString.length
};