Skip to content

Instantly share code, notes, and snippets.

View ajaxsys's full-sized avatar
🎯
Focusing

Andy Fang ajaxsys

🎯
Focusing
  • Yokohama, Japan
View GitHub Profile
@ajaxsys
ajaxsys / javascript-override-element-native-function
Last active August 29, 2015 14:04
javascript-override-element-native-function
// From http://webreflection.blogspot.jp/2007/02/could-i-extend-native-function.html
// Basic example
document.createElement = (function(createElement, Element) {
return function(nodeName) {
var element, key;
try {
element = createElement(nodeName)
} catch (e) {
element = createElement.call(document, nodeName)
};
@ajaxsys
ajaxsys / isPrimeNumber
Created August 4, 2014 09:37
JS check is Prime Number
function isPrime(number) {
var start = 2, end = Math.sqrt(number);
while (start <= end) {
start++;
if (number % start < 1)
return false;
}
return number > 1;
}
// AVLTree ///////////////////////////////////////////////////////////////////
// This file is originally from the Concentré XML project (version 0.2.1)
// Licensed under GPL and LGPL
//
// Modified by Jeremy Stephens.
// Pass in the attribute you want to use for comparing
function AVLTree(n, attr) {
this.init(n, attr);
}
@ajaxsys
ajaxsys / music.pac
Last active October 14, 2015 04:31
pac for music.163.com https://goo.gl/E1s7Yt
function FindProxyForURL(url, host)
{
if (host == "music.163.com")
return "PROXY 124.126.126.105:80;PROXY 122.72.0.242:8080;PROXY 123.59.25.227:80;PROXY 122.96.59.99:83;PROXY 115.182.83.38:8080;";
return "DIRECT";
}
@ajaxsys
ajaxsys / osx-mongodb-rlimits-fix.md
Created November 23, 2015 13:06 — forked from tamitutor/osx-mongodb-rlimits-fix.md
Fix Mongodb "soft rlimits" Warning On Mac OS X (Yosemite)

If you are seeing Mongo soft rlimits warnings in your logs, or a WARNING: soft rlimits too low. Number of files is 256, should be at least 1000 when you login to mongo shell via mongo from the commandline, or any mysterious/unexplained mongo connection errors... follow this how-to exactly and it will resolve the issue for you.

(Source of this how to found at basho/basho_docs#1402)

First file: sudo vi /Library/LaunchDaemons/limit.maxfiles.plist

...containing:

@ajaxsys
ajaxsys / dd.log
Created May 11, 2016 09:49 — forked from ktheory/dd.log
EC2 EBS-SSD vs instance-store performance on an EBS-optimized m3.2xlarge
# /tmp/test = EBS-SSD
# /mnt/test = instance-store
root@ip-10-0-2-6:~# dd bs=1M count=256 if=/dev/zero of=/tmp/test
256+0 records in
256+0 records out
268435456 bytes (268 MB) copied, 3.26957 s, 82.1 MB/s
root@ip-10-0-2-6:~# dd bs=1M count=256 if=/dev/zero of=/tmp/test
256+0 records in
256+0 records out
@ajaxsys
ajaxsys / sprintdatajpa.md
Created July 25, 2016 17:42 — forked from ryo-murai/sprintdatajpa.md
Spring DATA JPA概要

Spring DATA JPA

はじめに

  • Spring DATA JPAは、Spring Frameworkの拡張ライブラリ。springframework-jdbcシリーズか springframework-ormシリーズのようだが、安定したら本流に組み込まれるのかもしれない。
  • この記事の執筆時点のバージョンは SPRING DATA JPA 1.1.0 GA
  • Spring DATA JPAは、JPAの機能をベースに 汎用的な Repositoryの機能を提供する。
  • ちなみに、Repositoryというのは、ドメイン駆動設計(Domain Driven Design)のパターンのひとつで、ドメインのEntityのCollectionのように振舞う責務を持つ。例えば CustomerRepositoryならば、システムに存在するCustomer EntityたちをCollectionに保持するかのように振舞う。
  • PoEAAにもある。参照
  • もちろん本当のCollectionに保持したら大変なことになるので、バックエンドではデータベースアクセスが行われたりするわけだが、そういったことを抽象化する。
# packstack --allinone --provision-demo=n --os-neutron-ovs-bridge-mappings=extnet:br-ex --os-neutron-ovs-bridge-interfaces=br-ex:em1 --os-neutron-ml2-type-drivers=vxlan,flat
/etc/sysconfig/network-scripts/ifcfg-em1
DEVICE=em1
TYPE=OVSPort
DEVICETYPE=ovs
BOOTPROTO=none
ONBOOT=yes
BOOTPROTO=none
DNS1=8.8.8.8
@ajaxsys
ajaxsys / fix maven https error.txt
Created July 20, 2018 04:21
Just add this config to mirrors tag at %USER_PROFILE%\.m2\setting.xml
<mirror>
<id>central-no-ssl</id>
<name>Central without ssl</name>
<url>http://repo.maven.apache.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
@ajaxsys
ajaxsys / ngx-scanner-center-scan-patch.js
Created September 5, 2018 07:16
Patch for ngx scanner, only center areas are valid for scanning.
// Patch for node_modules/@zxing/ngx-scanner/esm5/zxing-ngx-scanner.js
BrowserCodeReader.prototype.createBinaryBitmap = function (mediaElement) {
if (undefined === this.canvasElementContext) {
this.prepareCaptureCanvas();
}
this.canvasElementContext.drawImage(mediaElement, 0, 0);
// FIXME byHo
// var luminanceSource = new HTMLCanvasElementLuminanceSource(this.canvasElement);
// var hybridBinarizer = new HybridBinarizer(luminanceSource);
// return new BinaryBitmap(hybridBinarizer);