Skip to content

Instantly share code, notes, and snippets.

View akirattii's full-sized avatar

Akira TANAKA akirattii

View GitHub Profile
@akirattii
akirattii / sublime-text-like.css
Created January 18, 2014 08:57
Sublime Text Like Theme for Brackets. It's inspired by 'Monokai Dark Soda' Theme in 'Themes' plugin. Installation: copy to ~/.config/Brackets/extensions/user/themes/theme/ and restart Brackets.
.cm-s-sublime-text-like.CodeMirror {
background-color: #242424;
color: #fff;
}
.CodeMirror div.CodeMirror-cursor {
border-left: 1px solid #f8f8f0;
z-index: 3;
}
@akirattii
akirattii / SimplifiedXMLHttpRequest.js
Last active March 31, 2017 04:53
Simplified function of XMLHttpRequest process on Chrome Apps.
/**
* pure js simplified XMLHttpRequest function
*
* @param {Object} p
* {
* url:
* required.
* method:
* ('GET' | 'POST')
* default is "GET"
@akirattii
akirattii / app.js
Created February 23, 2014 02:32
Draggable & Movable popup example using pure javascript.
(function(){
var SCROLL_WIDTH = 24;
var btn_popup = document.getElementById("btn_popup");
var popup = document.getElementById("popup");
var popup_bar = document.getElementById("popup_bar");
var btn_close = document.getElementById("btn_close");
var smoke = document.getElementById("smoke");
@akirattii
akirattii / drawer-slide-menu-example.html
Created March 2, 2014 06:44
Example of drawer slide menu using jQuery
<!DOCTYPE html>
<html>
<head>
<title>Layout Example</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
html, body {
const Sanitizer = {
encode: function(str) {
if (!str) return;
str = "" + str;
return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;');
},
decode: function(str) {
if (!str) return;
str = "" + str;
return str.replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&quot;/g, '"').replace(/&#39;/g, '\'').replace(/&amp;/g, '&');
@akirattii
akirattii / gist:460b6c507d9c5b6f51caea985a12da27
Created June 21, 2016 11:39
CamelCase <-> HyphenCase converter
// camelCase -> hyphenCase
function camelToHyphenCase: function(str) {
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
}
// hyphenCase -> camelCase
function hyphenToCamelCase(str) {
return str.replace(/-([a-z])/g, function(g) {
return g[1].toUpperCase();
});
}
@akirattii
akirattii / JapaneseUtil.js
Last active June 28, 2017 06:17
日本語をバラバラに分解する。
JapaneseUtil = function() {
const charMode = {
none: null,
ascii: "ascii",
alphaNumMark: "alphaNumMark",
surroundMark: "surroundMark", // "'{} etc.
alphaNum: "alphaNum",
alpha: "alpha",
@akirattii
akirattii / gist:efb54a532d6c8ee0c5cbc5747ca6cbf0
Last active June 24, 2016 22:59
Getting some related words from wikipedia(ja) on Meteor
// server/hoge.js
const re = /\[\[(.+?)\]\]/g; // matches '*[[hoge]]' or '* [[hoge]]'
const reRedirect = /^\#REDIRECT\s?\[\[(.+)\]\]/; // matches '#REDIRECT [[hoge]]'
const reRelatedHeader = /\=\=\s?関連項目\s?\=\=/;
function getEndpoint(title) {
title = encodeURIComponent(title);
return `https://ja.wikipedia.org/w/api.php?action=query&titles=${title}&prop=revisions&rvprop=content&format=json`;
}
@akirattii
akirattii / array_op.js
Created June 24, 2016 23:01
配列操作のsnippets
// 配列の重複を削除
var arr = ["", "", "hoge", "baa", "hogege", "", "foo", "", ""];
var newArr = arr.filter((x, i, self) => self.indexOf(x) === i);
// newArr -> ["", "hoge", "baa", "hogege", "foo"]
@akirattii
akirattii / webworker.example.js
Created June 29, 2016 22:57
WebWorker example using importScript
Webworker
// worker.js
var ju;
addEventListener('message', function(e) {
if (e.data == "dummy") {
importScripts('./JapaneseUtil.js');
console.log("this worker on message...", e);