Skip to content

Instantly share code, notes, and snippets.

Naing Lin Aung nainglinaung

View GitHub Profile
@stekhn
stekhn / prepareElastic.js
Last active May 4, 2020
Creates and prepares an Elasticsearch index, using the Node.js client. Closes the index before putting settings and mappings. The response and error handlers are optional, remove them if necessary.
View prepareElastic.js
var elastic = require('elasticsearch');
var client = new elastic.Client({ host: 'localhost:9200' });
var index = 'myindex';
var type = 'document';
(function init() {
Promise.resolve()
.then(deleteIndex, handleError)
@greenlikeorange
greenlikeorange / const_function
Last active Aug 29, 2015
CONST Example under ES6
View const_function
function CONST (obj, key, value){
Object.defineProperty(obj, key, {
enumerable: false,
configurable: false,
writable: false,
value: value
});
}
@addyosmani
addyosmani / README.md
Last active Jul 7, 2020 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger
View README.md

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@tamoyal
tamoyal / gist:10441108
Created Apr 11, 2014
Create super user and database user in Mongo 2.6
View gist:10441108
# Create your superuser
$ mongo
> use admin
> db.createUser({user:"someadmin",pwd:"secret", roles:[{role:"root",db:"admin"}]})
> exit
# Alias for convenience (optional and at your own risk)
$ echo 'alias mongo="mongo --port 27017 -u someadmin -p secret --authenticationDatabase admin"' >> ~/.bash_profile
$ source ~/.bash_profile
@rantav
rantav / README.md
Created Aug 23, 2012
Find slow queries in mongo DB
View README.md

A few show tricks to find slow queries in mongodb

Enable profiling

First, you have to enable profiling

> db.setProfilingLevel(1)

Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...

@dawsontoth
dawsontoth / app.js
Created May 10, 2011
Loading images in @appcelerator #Titanium
View app.js
/* The images for this example can be downloaded from http://j.mp/loadingimagesforti */
var win = Ti.UI.createWindow({ backgroundColor: '#f00'});
var loading = Ti.UI.createImageView({
images: [
'images/loading/00.png', 'images/loading/01.png', 'images/loading/02.png',
'images/loading/03.png', 'images/loading/04.png', 'images/loading/05.png',
'images/loading/06.png', 'images/loading/08.png', 'images/loading/09.png',
'images/loading/10.png', 'images/loading/11.png'
],
width: 33, height: 33
@mschmulen
mschmulen / TableViewNeverending.js
Created Feb 1, 2011
Titanium tableView with a continuous amount of data.
View TableViewNeverending.js
//
// in this demo, we simply show how you could dynamically scroll
// with a continuous amount of data in the tableview by detecting
// when the user's scroll position gets near the end of the table
// and start a background fetch of new data and seamlessly append
// the new data to the table automatically
//
var win = Ti.UI.createWindow();
You can’t perform that action at this time.