Skip to content

Instantly share code, notes, and snippets.

View monsat's full-sized avatar

TANAKA Kohji monsat

View GitHub Profile
@monsat
monsat / README.md
Last active October 3, 2015 16:47
wrap string

USAGE

    'your text'.wrap('[]');  // [your text]
    'your text'.wrap('<li></li>');  // <li>your text</li>
    'your text'.wrap('<li class="foo"><!-- sep --></li>', '<!-- sep -->');  // <li class="foo">your text</li>
    (1234).wrap('<li></li>');  // <li>1234</li>
@monsat
monsat / split3.js
Created April 25, 2012 09:12
number format by javascript
(function(){
var split3 = function(prefix, suffix){
prefix = prefix || '';
suffix = suffix || '';
var m = this < 0;
var str = String(this * ( m ? -1 : 1)).split('.');
var arr = String(str[0]).split(''), len = Math.ceil(arr.length / 3), res = [];
for (var i = 0; i < len; ++i) {
res.unshift(arr.splice(-3, 3).join(''));
}
@monsat
monsat / jquery.h.js
Last active November 5, 2017 07:43
htmlspecialchars by javascript (using jQuery)
String.prototype.h = function() {
return jQuery('<div />').html(this).text();
}
@monsat
monsat / gist:2403026
Created April 17, 2012 02:33
Another image replacement
<div id="foo" class="hide-text">This is a hidden text.</div>
<style type="text/css">
.hide-text {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
#foo {
height: 200px;
width: 400px;
@monsat
monsat / jquery.pluginName.js
Created March 23, 2012 05:57
jQuery Plugin Skeleton
!function( $ ){
var PluginName = function ( element, options ) {
this.$element = $(element);
this.options = $.extend({}, $.fn.pluginName.defaults, options);
}
PluginName.prototype = {
constructor: PluginName
, methodName: function () {
return this;
}
@monsat
monsat / setup.sh
Created March 14, 2012 03:56
Set up new servers
#!/bin/bash
#
# CentOS6.2
#
#
# vars
#
UNAME=`uname -i`
@monsat
monsat / basics.sh
Created March 13, 2012 03:53
Create a user
#!/bin/sh
#
# CentOS6.2
#
#
# vars
#
UNAME=`uname -i`
@monsat
monsat / default_version.js.html
Created March 10, 2012 01:00
Compare with hatena bookmark buttons
<a href="http://b.hatena.ne.jp/entry/http://tipshare.info/" class="hatena-bookmark-button" data-hatena-bookmark-title="tipshare" data-hatena-bookmark-layout="vertical" title="このエントリーをはてなブックマークに追加">
<img src="http://b.st-hatena.com/images/entry-button/button-only.gif" alt="このエントリーをはてなブックマークに追加" width="20" height="20" style="border: none;" />
</a>
<script type="text/javascript" src="http://b.st-hatena.com/js/bookmark_button.js" charset="utf-8" async="async"></script>
@monsat
monsat / code_highlighter_for_gist.user.js
Created March 8, 2012 07:29 — forked from yuya-takeyama/paste_your_code_your_color.user.js
Changes style of Gist's syntax highlight to paste into some presentation tools like Keynote.
// ==UserScript==
// @name code_highlighter_for_gist.user.js
// @namespace http://www.direct-serarch.jp/
// @description Changes style of Gist's syntax highlight
// @include https://gist.github.com/*
// ==/UserScript==
// forked from https://gist.github.com/1254056
(function () {
var styles = {
@monsat
monsat / gist:1983724
Created March 6, 2012 05:10
ViewBlock in CakePHP勉強会 2012春