Skip to content

Instantly share code, notes, and snippets.

View tai-sho's full-sized avatar
🏠
Working from home

ShoheiTai tai-sho

🏠
Working from home
View GitHub Profile
@aeurielesn
aeurielesn / gist:2511005
Created April 27, 2012 17:23
Retrying a jQuery.ajax() call
$.ajax({
url: '/echo/error/',
async: true,
// retryCount and retryLimit will let you retry a determined number of times
retryCount: 0,
retryLimit: 10,
// retryTimeout limits the total time retrying (in milliseconds)
retryTimeout: 10000,
// timeout for each request
timeout: 1000,
@gregrickaby
gregrickaby / html5-schema.org-markup.html
Last active August 2, 2022 00:05
Proper SCHEMA.ORG markup
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noodp, noydir" />
<link rel="dns-prefetch" href="//cdnjs.cloudflare.com">
<link rel="canonical" href="http://mysite.com/" />
<link rel="stylesheet" href="http://mysite.com/style.css" type="text/css" />
@komasaru
komasaru / google_maps_dist.js
Last active December 19, 2015 08:19
JavaScript file to calc distance between two spots with Google Maps API v3.
// ページ読み込み完了時に実行する関数
function init() {
// 初期値位置定数
const LAT_1 = 35.472222; // 島根県庁・緯度
const LNG_1 = 133.050556; // 島根県庁・経度
const LAT_2 = 35.468056; // 松江市役所・緯度
const LNG_2 = 133.048611; // 松江市役所・経度
// 初期位置表示
document.getElementById('lat-1').value = LAT_1;
@aaronhalford
aaronhalford / chromeos-crosh-custom-setup.md
Created November 28, 2014 19:59
Customize ChromeOS Crosh Terminal with Custom Fonts and Solarized Dark Theme

Customize Chromebook Chrosh Shell Environment

Requirement: Chromebook, Common Sense, Commandline Ablity, 1 hour of time

Dear developers with a spare Chromebook lets inject a little personalization into your Crosh shell with custom fonts, the solarized theme, and extra secure shell options.

Also, keep in mind that the terms Chrosh, Chrosh Window, and Secure Shell all refer to various versions and extentions built around the ChromeOS terminal. Settings that affect the ChromeOS terminal are global.

Custom Fonts

@davidblewett
davidblewett / lp-ssh-add.sh
Last active December 12, 2021 11:12
Allow storage of SSH private keys in LastPass, and use lpass CLI to retrieve and load into ssh-agent. The general idea is to store the private key armored ASCII in an "SSH Key" Secure Note, in a specific folder (i.e.: "Secure Notes\SSH" ).
#!/bin/sh
#
# Import all SSH keys from LP
#
PREFIX=~
SSH_ASKPASS=$PREFIX/bin/lp-askpass.sh
export SSH_ASKPASS
# This is needed to force ssh-add to honor our SSH_ASKPASS.
DISPLAY=foo
export DISPLAY
@mgng
mgng / resize_exif_delete.php
Created August 17, 2015 05:54
画像リサイズおよびexifの削除処理
<?php
$blob = getResizedImageBlob("./sample.png", 100, 200);
file_put_contents("sample_100x200.png", $blob);
/**
* @param string $img_path 画像ファイルパス
* @param string int $w_re リサイズ後の幅
* @param string int $h_re リサイズ後の高さ
* @return string
@slayerfat
slayerfat / phpmd-ruleset.xml
Last active April 9, 2024 03:09
php mess detector ruleset for laravel and similar frameworks
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Laravel and similar phpmd ruleset"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
Inspired by https://github.com/phpmd/phpmd/issues/137
using http://phpmd.org/documentation/creating-a-ruleset.html
</description>
@gregrickaby
gregrickaby / social-sharing-with-javascript-popup.php
Last active October 21, 2019 02:33
Social Sharing with Javascript Pop-up
<?php
/**
* Social sharing links.
*/
function wds_client_get_social_share_links( ) {
$facebook_url = 'https://www.facebook.com/sharer/sharer.php?u=' . rawurlencode ( get_the_permalink() );
$twitter_url = 'https://twitter.com/intent/tweet?text=?text=' . urlencode( html_entity_decode( get_the_title() ) ) . '&amp;url=' . rawurlencode ( get_the_permalink() );
$linkedin_url = 'https://www.linkedin.com/shareArticle?mini=true&amp;url=' . rawurlencode ( get_the_permalink() ) . '&amp;title=' . urlencode( html_entity_decode( get_the_title() ) );
@uramonk
uramonk / mnist_for_ml_beginners.py
Created May 12, 2016 02:31
TensorFlow MNIST For ML Beginners チュートリアルのコード
# -*- coding: utf-8 -*-
# TensowFlowのインポート
import tensorflow as tf
# MNISTを読み込むためinput_data.pyを同じディレクトリに置きインポートする
# input_data.pyはチュートリアル内にリンクがあるのでそこから取得する
# https://tensorflow.googlesource.com/tensorflow/+/master/tensorflow/examples/tutorials/mnist/input_data.py
import input_data
import time
@keirwhitaker
keirwhitaker / srcset.liquid
Created July 12, 2017 14:42
An example of how to use srcset in Shopify themes
{% for product in collection.products %}
<a href="{{ product.url | within: collection }}">
{% assign image = product.featured_image %}
<img src="{{ image.src | img_url: '480x' }}" alt="{{ image.alt | escape }}"
srcset="
{% if image.width > 640 %}{{ image.src | img_url: '640x' }} 640w{% endif %}
{% if image.width > 720 %},{{ image.src | img_url: '720x' }} 720w{% endif %}
{% if image.width > 900 %},{{ image.src | img_url: '900x' }} 900w{% endif %}
"
sizes="(min-width: 960px) 450px, (min-width: 720px) 50vw, 100vw"