Skip to content

Instantly share code, notes, and snippets.

View adohe-zz's full-sized avatar

TonyAdo adohe-zz

View GitHub Profile
@trevnorris
trevnorris / perf-flame-graph-notes.md
Last active March 18, 2026 03:38
Quick steps of how to create a flame graph using perf

The prep-script.sh will setup the latest Node and install the latest perf version on your Linux box.

When you want to generate the flame graph, run the following (folder locations taken from install script):

sudo sysctl kernel.kptr_restrict=0
# May also have to do the following:
# (additional reading http://unix.stackexchange.com/questions/14227/do-i-need-root-admin-permissions-to-run-userspace-perf-tool-perf-events-ar )
sudo sysctl kernel.perf_event_paranoid=0
@adohe-zz
adohe-zz / Makefile
Created March 13, 2014 09:13
A common Makefile used in Node project
TESTS = test/*.test.js
REPORTER = spec
TIMEOUT = 10000
MOCHA_OPTS =
install-test:
@NODE_ENV=test npm install
test: install-test
@NODE_ENV=test ./node_modules/.bin/mocha \
@adohe-zz
adohe-zz / minimum.java
Created March 5, 2014 06:14
find minimum K numbers solution
public class Art {
public static void main(String[] args) {
int[] array = new int[]{9, 8, 6, 4, 1, 2, 3, 0};
int k = 4;
findMinimumK(array, k);
for(int i = 0; i < k; i++) {
@adohe-zz
adohe-zz / Utils.js
Last active August 29, 2015 13:56
add a javascript util module
var http = require('http')
, parse = require('url').parse
, sep = require('path').sep;
exports.error = function(msg, code) {
var err = new Error(msg || http.STATUS_CODES[code]);
err.status = code;
return err;
}
@adohe-zz
adohe-zz / heapsort.java
Created March 4, 2014 03:24
add heap sort implementation in java
public class HeapSort {
private static int[] array = new int[]{5, 3, 6, 4, 8, 9 , 1, 10};
public static void main(String[] args) {
heapSort();
for(int i : array) {
System.out.println(i);
}
#!/usr/bin/env node
var args = process.argv.slice(2)
var path = require('path')
var fs = require('fs')
var private = false
var description = ''
var opener = require('opener')
var copy = process.platform === 'darwin'
var open = true
var stdin = true
@adohe-zz
adohe-zz / arraylist.java
Created March 1, 2014 17:12
useful arraylist in java
//How does the size of Arraylist increases automatically?
//We need to deep into the source code to get the answer
private void ensureCapacity(int minCapacity) {
modCount++;
int oldCapacity = elementData.length;
if(minCapacity > oldCapacity) {
Object[] oldData = elementData;
int newCapacity = (oldCapacity * 3)/2 + 1;
if(minCapacity > newCapacity) {
newCapacity = minCapacity;
@adohe-zz
adohe-zz / hashCode.js
Created February 28, 2014 03:13
JS hashCode function implementation
//JS String hashCode function implementation(maybe the best solution)
String.prototype.hashCode = function() {
if(Array.prototype.reduce) {
return this.split('').reduce(function(a,b) {
a = ((a<<5) - a) + b.charCodeAt(0);
return a & a;
}, 0);
}
@adohe-zz
adohe-zz / page_view.txt
Last active August 29, 2015 13:56
add the difference between page view & unique view
Page View && Unique View
1.Page View
A page view or page impression is a request to load a single HTML file of
an Internet sit. It refers to the number of times visitors to your site have
looked at your pages. Every time a visitor loads one of your pages, a page view
is counted. But with the increasing pervasiveness of AJAX, the metric of page views
has lost some significance since AJAX requests often have JSON or XML payloads.
2. Unique View
@adohe-zz
adohe-zz / kill.txt
Created February 24, 2014 08:23
useful linux command usage
Useless Use of Kill -9 form letter
(Quote abomination)
No no no. Don't use kill -9.
It doesn't give the process a chance to cleanly:
1) shut down socket connections
2) clean up temp files