Skip to content

Instantly share code, notes, and snippets.

View naotone's full-sized avatar
🤓
.•

Naoto Yoshimoto naotone

🤓
.•
View GitHub Profile
device = navigator.userAgent.toLowerCase()
Mac = device.match(/(mac)/)
Windows = device.match(/(windows)/)
iPhone = device.match(/(iphone|ipod)/)
iPad = device.match(/(ipad)/)
iOS = device.match(/(iphone|ipad|ipod)/)
android = device.match(/(android)/)
@naotone
naotone / iOSZoomDetect.js
Last active December 16, 2015 13:59
Hide position: fixed; elements after pinch zoom.
//Copyright 2013 NAOTONE
//Please use under MIT license.
jQuery(window).resize(function() {
iOSClearFixed();
});
jQuery('html').on("touchend", touchHandler);
touchHandler = function(event) {
return iOSClearFixed;
@naotone
naotone / hide_text_and_replace_Image.sass
Created April 24, 2013 03:29
Hide text and replace image mixin.
@mixin at2x($image_name, $extention: '.png')
background: image_url($image_name + $extention) no-repeat center center
background-size: image-width($image_name + $extention) image-height($image_name + $extention)
width: image-width($image_name + $extention)
height: image-height($image_name + $extention)
display: block
$x2img : $image_name + '@2x' + $extention
@media all and (-webkit-min-device-pixel-ratio : 1.5)
background-image: image_url($x2img)
background-size: image-width($image_name + $extention) image-height($image_name + $extention)
@naotone
naotone / retinacanvas.coffee
Created May 8, 2013 12:29
Optimize html5 canvas for retina display.
retinaCanvas = ->
if window.devicePixelRatio > 1
canvas.width = W * window.devicePixelRatio
canvas.height = H * window.devicePixelRatio
ctx.scale(window.devicePixelRatio, window.devicePixelRatio)
else
canvas.width = W
canvas.height = H
@naotone
naotone / jQuery hover for appended objects.coffee
Last active December 17, 2015 12:59
jQuery hover for appended objects
jQuery('.content').on('mouseover', ->
jQuery(this).stop().css(opacity: 0.3).animate
opacity: 0.8
, 300
).on 'mouseout', ->
jQuery(this).stop().animate
opacity: 1
, 300
@naotone
naotone / brewfile
Last active August 29, 2015 13:58
brewfile
tap phinze/homebrew-cask
update
install brew-cask
install zsh
install ag
install apple-gcc42
install autoconf
install automake
install boost
@naotone
naotone / gulpfile.js
Last active August 29, 2015 14:01
gulpfile.js
//npm install --save-dev gulp gulp-watch gulp-livereload gulp-header gulp-concat gulp-coffee gulp-compass gulp-minify-css gulp-notify gulp-uglify gulp-order gulp-ruby-sass
var gulp = require('gulp'),
watch = require('gulp-watch'),
livereload = require('gulp-livereload'),
header = require('gulp-header'),
concat = require('gulp-concat'),
coffee = require('gulp-coffee'),
compass = require('gulp-compass'),
minifyCSS = require('gulp-minify-css'),
apple-gcc42
autoconf
automake
bison
boost
boost-build
boot2docker
brew-cask
cmake
curl
@naotone
naotone / setMovIcon.sh
Last active August 29, 2015 14:08
Auto set thumbnail icons to .mov.
#!/bin/sh
# Based on http://stackoverflow.com/questions/8371790/how-to-set-icon-on-file-or-directory-using-cli-on-os-x
# Usage
# cd path/to/moviesAndImagesDir/
# thisFileName.sh ./ [jpg|png]
dirPath=$1
thumbExt=$2
IFS=$'\n'
@naotone
naotone / wp_search_wpdb_taxonomy_term.php
Created December 3, 2014 15:28
Wordpress search - wpdb taxonomy term
<?php
$search_query = get_search_query();
$results = $wpdb->get_results("SELECT *
FROM $wpdb->terms AS wt
INNER JOIN $wpdb->term_taxonomy AS wtt ON wt.term_id=wtt.term_id
INNER JOIN $wpdb->term_relationships AS wtr ON wtr.term_taxonomy_id=wtt.term_taxonomy_id
LEFT JOIN $wpdb->posts wp ON wp.ID=wtr.object_id
WHERE taxonomy='$taxonomy' AND name LIKE '%%$search_query%%'
" );