Skip to content

Instantly share code, notes, and snippets.

View memolog's full-sized avatar

Yutaka Yamaguchi memolog

View GitHub Profile
@memolog
memolog / format changed files
Last active December 21, 2022 06:08
Format changed files in git with prettier
git diff --name-only HEAD | xargs -I$0 npx prettier --write $0
@memolog
memolog / karatsuba.js
Last active June 20, 2019 23:39
Karatsuba algorithm in JavaScript
function add(a, b) {
a = a.toString();
b = b.toString();
const re = /^-/;
if (re.test(a) && re.test(b)) {
a = a.substring(1);
b = a.substring(1);
} else if(re.test(a)) {
a = a.substring(1);
--- themes/little-code-bricks/source/css/prism.css 2018-08-17 22:04:12.000000000 +0900
+++ themes/little-code-bricks/source/css/prism-default-a11.css 2018-08-17 22:05:53.000000000 +0900
@@ -71,11 +71,11 @@
.token.prolog,
.token.doctype,
.token.cdata {
- color: slategray;
+ color: #5f6d7b;
}
@memolog
memolog / prism-default-a11.css
Created August 17, 2018 12:54
Prism default CSS plus contrast for a11y
/* PrismJS 1.9.0
http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+bash+ruby+diff+json+perl+python+jsx+scss+swift+typescript&plugins=line-numbers */
/**
* prism.js default theme plus contrast for a11y
* Based on default theme, dabblet (http://dabblet.com)
* @author Lea Verou
*/
code[class*="language-"],
pre[class*="language-"] {
function test(method, array, showArray){
let arrayLength;
if (typeof array === 'number') {
arrayLength = array;
array = [];
for (let i=0; i<arrayLength; i++) {
array.push(Math.floor(Math.random()*10000));
}
} else {
arrayLength = array.length;
const stringHash = require("string-hash");
module.exports = class MyHashTable {
constructor(numberOfBucket) {
this.numberOfBucket = parseInt(numberOfBucket, 10);
this.hashTable = new Array(this.numberOfBucket);
}
get(key) {
key = '' + key;
const hashTableIndex = this.getHashTableIndex(key);
@memolog
memolog / es5build.js.diff
Created May 16, 2015 16:24
ad hoc fix for es5build.js
diff --git a/tools/build/es5build.js b/tools/build/es5build.js
index b16f9d9..25b5ae6 100755
--- a/tools/build/es5build.js
+++ b/tools/build/es5build.js
@@ -56,7 +56,10 @@ function run(config) {
.pipe(sourcemaps.init())
.pipe(through2.obj(function(file, encoding, done) {
var self = this;
- fs.readFile(file.path.replace('.js', '.map'), function(error, buffer) {
+ var filePath = file.path.replace('.js', '.map');
@memolog
memolog / gist:7866919
Created December 9, 2013 03:17
local task for replacing icons and splash with prepared images.xcassets directory
module.exports = function (grunt) {
// Please see the Grunt documentation for more information regarding task
// creation: http://gruntjs.com/creating-tasks
'use strict';
grunt.registerMultiTask('useXCAssets', 'operating node-xcode', function () {
var xcode = require('xcode');
var _ = require('lodash') || grunt.util._;
var fs = require('fs');
@memolog
memolog / gist:7855866
Last active December 30, 2015 16:39
sample local grunt task: change project build configuration, like IPHONEOS_DEPLOYMENT_TARGET using node-xcode
module.exports = function (grunt) {
// Please see the Grunt documentation for more information regarding task
// creation: http://gruntjs.com/creating-tasks
'use strict';
grunt.registerMultiTask('nodexcode', 'operating node-xcode', function () {
var xcode = require('xcode');
var _ = require('lodash') || grunt.util._;
var fs = require('fs');