Skip to content

Instantly share code, notes, and snippets.

@stekhn
stekhn / prepareElastic.js
Last active April 13, 2023 00:52
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.
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)
@ygotthilf
ygotthilf / jwtRS256.sh
Last active April 17, 2024 04:10
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@greenlikeorange
greenlikeorange / const_function
Last active August 29, 2015 14:10
CONST Example under ES6
function CONST (obj, key, value){
Object.defineProperty(obj, key, {
enumerable: false,
configurable: false,
writable: false,
value: value
});
}
@addyosmani
addyosmani / README.md
Last active April 2, 2024 20:18 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

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 April 11, 2014 04:39
Create super user and database user in Mongo 2.6
# 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
@martinrusev
martinrusev / imap-search
Last active March 22, 2024 06:50
IMAP Search criteria
@rantav
rantav / README.md
Created August 23, 2012 06:13
Find slow queries in mongo DB

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 14:05
Loading images in @appcelerator #Titanium
/* 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 February 1, 2011 02:07
Titanium tableView with a continuous amount of data.
//
// 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();