Skip to content

Instantly share code, notes, and snippets.

View yyoshiki41's full-sized avatar
📻

Yoshiki Nakagawa yyoshiki41

📻
View GitHub Profile
@yyoshiki41
yyoshiki41 / countDown.js
Created March 9, 2014 04:14
function countdown();
function countDown() {
var startDateTime = new Date();
var endDateTime = new Date("March 9,2015 18:00:00");
var left = endDateTime - startDateTime;
var a_day = 24 * 60 * 60 * 1000;
var h = Math.floor((left % a_day) / (60 * 60 * 1000)),
m = Math.floor((left % a_day) / (60 * 1000)) % 60,
s = Math.floor((left % a_day) / 1000) % 60 % 60;
@yyoshiki41
yyoshiki41 / notification.php
Last active August 29, 2015 13:57
Facebook notifications
$accessToken = $app_Id.'|'.$app_accessToken;
$url = "https://graph.facebook.com/{$facebookId}/notifications"; // API URL
$linkUrl = "index.php"; // app内の相対URL
$notificationTemplate = "Test";
// POST params
$params = "access_token={$accessToken}";
$params .= "&href={$linkUrl}";
$params .= "&template={$notificationTemplate}";
@yyoshiki41
yyoshiki41 / reset.css
Created March 9, 2014 04:31
Remove tap_shadow
a {
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
-moz-tap-highlight-color: rgba(0, 0, 0, 0);
tap-highlight-color: rgba(0, 0, 0, 0);
}
@yyoshiki41
yyoshiki41 / min_contents.js
Created March 14, 2014 15:17
Set min_height
// #contents { min-height: }
function getBrowserHeight() {
if ( window.innerHeight ) {
return window.innerHeight;
}
else if ( document.documentElement && document.documentElement.clientHeight != 0 ) {
return document.documentElement.clientHeight;
}
else if ( document.body ) {
return document.body.clientHeight;
@yyoshiki41
yyoshiki41 / cal_age.sql
Last active December 19, 2015 12:21
Calculate age from date (1900-01-01)
SELECT (YEAR(current_date())-YEAR(`dob`)) - (RIGHT(current_date(),5) < RIGHT(`dob`,5)) AS age
FROM `table_name`
@yyoshiki41
yyoshiki41 / var_display_max.php
Created August 29, 2014 02:00
xdebug で var_dump 省略されるのを防ぐ
ini_set('xdebug.var_display_max_data', 4096);
ini_set('xdebug.var_display_max_depth', 20);
var_dump();
<?php
// Create connection
$mysqli = new mysqli('HOST', 'USER', 'PW');
// Check connection
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
// Check DB server
if ($mysqli->ping()) {
@yyoshiki41
yyoshiki41 / num.txt
Last active December 19, 2015 12:17
┏━━┓
┗┓ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┏┛ ┗┓
┗━━━┛
┏━━━┓
┃┏━┓┃
@yyoshiki41
yyoshiki41 / slack.rb
Last active December 19, 2015 12:23
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("https://hooks.slack.com/services/****")
payload = {
text: "こんなかんじでいける",
channel: "@dareka",
username: "oreore",
icon_emoji: ":ghost:"
@yyoshiki41
yyoshiki41 / fmt_nginx-V.sh
Last active December 19, 2015 13:44
Format "$ nginx -V"
# format all
$ nginx -V 2>&1 | sed 's/--/\n--/g'
# format module only
$ nginx -V 2>&1 | sed 's/--with/\n--with/g'