Skip to content

Instantly share code, notes, and snippets.

View sundaycrafts's full-sized avatar

sundaycrafts

View GitHub Profile
@sundaycrafts
sundaycrafts / .zshrc
Created November 19, 2017 16:51
My zsh setting
# Init Antigen https://github.com/zsh-users/antigen zsh plugin manager
source ~/.antigen.zsh
# Init Nvm https://github.com/creationix/nvm node version manager
export NVM_DIR="$HOME/.nvm"
. "/usr/local/opt/nvm/nvm.sh"
# Init Pure https://github.com/sindresorhus/pure zsh prompt
autoload -U promptinit; promptinit
prompt pure
@sundaycrafts
sundaycrafts / make-flexible-col.scss
Created May 16, 2016 02:36
make flexible col mixin
@mixin make-col($ref, $margin, $col, $reverse: false) {
$marginSum: $margin*($col - 1);
$itemWidth: floor(($ref -$marginSum)/$col);
width: percentage($itemWidth/$ref);
@if ($reverse == true) {
float: right;
margin-left: percentage($margin/$ref);
&:last-child {
margin-left: 0;
@sundaycrafts
sundaycrafts / Twitter Like
Created November 6, 2015 14:54 — forked from agektmr/Twitter Like
Copy and paste this code to your browser URL bar. (URLバーにコピペしてね)
data:text/html,<script>i=0;setInterval(function(){i=(i+100)%252000;document.querySelector('div').style.backgroundPositionX='-'+i+'px';},30);</script><div%20style="width:100px;height:100px;background:url(https://goo.gl/6nq9n5)">
@sundaycrafts
sundaycrafts / load.ts
Last active September 5, 2015 14:32
jq, js: Load HTML fragment with JQuery ajax() without $.load()
// この実装は$.load()に限りなく近い
// http://james.padolsey.com/jquery/#v=2.1.3&fn=jQuery.fn.load
// http://stackoverflow.com/questions/16885538/how-to-load-an-html-fragment-with-jquery-ajax
$.ajax({
url: 'page.html',
dataType: 'html'
}).done(responsText =>
// 空のdiv要素に追加
var $el = $('<div>').append($.parseHTML(responsText)).find('.selector');
// この処理は逐次的に行う必要がある。
$maxWidth: 1330px
$col: 100px/$maxWidth * 100%
$margin: 10px/$maxWidth * 100%
@mixin col($contentCol:1, $marginCol-left:0, $marginCol-right:0)
width: $col*$contentCol + $margin*($contentCol - 1)
margin-left: ($col+$margin)*$marginCol-left + $margin
margin-right: ($col+$margin)*$marginCol-right + $margin
@sundaycrafts
sundaycrafts / data.json
Created June 6, 2015 04:16
js: AJAX load JSON very simple example
{
"name": "sundaycrafts",
"age": 18,
"gender": "male",
"msg": "<h1>Hello World!</h1>"
}
@sundaycrafts
sundaycrafts / ajax.html
Created June 4, 2015 11:17
js: AJAX load html very simple example
<h1>Hello world!</h1>
@sundaycrafts
sundaycrafts / regex.pl
Last active August 29, 2015 14:22
useful regular expression
# get 4 spaces indents(it is not works perfectly but enough)
/(?<!\S) {4}/
# erace padding text such as ctrl char when logging bash log by [script] command
s/((?![\n\t])[[:cntrl:]])|(\[.*?(m|k))//g
@sundaycrafts
sundaycrafts / vCentering.scss
Created May 28, 2015 09:07
sass: vertical centering
%vCentering {
// https://css-tricks.com/centering-in-the-unknown/
text-align: center;
white-space: nowrap;
overflow-x: hidden;
&:before {
content: "";
display: inline-block;
height: 100%;
vertical-align: middle;
@sundaycrafts
sundaycrafts / getLineHeight.scss
Created May 28, 2015 09:05
sass: getLineHeight function
$FontSize: 14px;
$LineHeight: $FontSize * 1.5;
@function getLineHeight($fontSize) {
$height: $LineHeight;
@while $height < $fontSize {
$height: $height + $height;
}
@return $height;
}