Skip to content

Instantly share code, notes, and snippets.

Damir Mustafin frenchbread

Block or report user

Report or block frenchbread

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View hackathon.js
const _ = require('lodash')
const components = {
blaster: {
tasks: [
{ name: 'ystanovka_lazera_blastera_v_korpus', worker: 'shturmoviki' },
{ name: 'polirovka_rukoyati_blastera', worker: 'sborshiki' },
{ name: 'zaryad_batarey_blastera', worker: 'akkumulyatori' },
{ name: 'pristrelka', worker: 'shturmoviki' }
],
@frenchbread
frenchbread / example.md
Last active Jun 18, 2017
curl POST request with JSON data example
View example.md
curl -H "Content-Type: application/json" -X POST -d '{"username":"xyz","password":"xyz"}' http://localhost:3000/api/login
curl -XGET 'http://127.0.0.1:8000/api/some' -H 'Authorization: JWT <some_token>'
@frenchbread
frenchbread / emqttd-setup.md
Last active Mar 24, 2017 — forked from phanimahesh/emqttd-setup.md
Instructions to set up emqttd
View emqttd-setup.md

Instructions to set up emqttd

  • Clone the repo github.com/emqtt/emq-relx
  • Edit the Makefile:
    • Add emq_plugin_elasticsearch to DEPS
    • Add a line dep_emq_plugin_elasticsearch = git https://github.com/phanimahesh/emq_plugin_elasticsearch preview
  • Edit relx.config file
    • Add following to release tuple:
View example-method.js
getAPIKeys () {
const esClient = new ElasticSearch.Client({ host: 'http://nightly.apinf.io:14002' });
const params = {
size: 10,
body: {
sort: [
{
request_at: {
order: 'desc',
},
@frenchbread
frenchbread / srpt.js
Created Mar 2, 2017
Iterate through files in dir
View srpt.js
const fs = require('fs')
var walk = function (dir, done) {
fs.readdir(dir, (error, list) => {
if (error) {
return done(error)
}
let i = 0;
@frenchbread
frenchbread / migrate-script.js
Created Feb 28, 2017
Migrate stuff from one sails server to another
View migrate-script.js
migrate () {
this.notify.info('success')
axios.get(`http://127.0.0.1:1337/servers?limit=1000`)
.then(res => {
const servers = res.data
this.notify.info('Success', `Found ${servers.length} servers.`)
_.forEach(servers, server => {
this.apiServers.add(server)
.then(res => console.log(res))
.catch(err => console.error(err))
@frenchbread
frenchbread / script-example.js
Last active Mar 16, 2017
NodeJS script to generate bunch of sample data for elasticsearch
View script-example.js
import moment from 'moment'
import es from 'elasticsearch'
import uuid from 'node-uuid'
import _ from 'lodash'
import config from '/config'
const client = new es.Client({
host: config.host
})
View nginx.config.md
server {
    listen 80;

    server_name <public_IP>;

    location / {
        proxy_pass http://localhost:18083;
        proxy_http_version 1.1;
@frenchbread
frenchbread / howto.md
Created Jan 17, 2017
Show/hide hidden files on mac
View howto.md

Show/hide hidden files on mac

$ defaults write com.apple.finder AppleShowAllFiles YES

or

@frenchbread
frenchbread / howto.md
Last active Feb 25, 2019
Update Node.js with NVM and keep packages
View howto.md

Update Node.js with NVM and keep packages

Usually when new version of Node.js comes out and you update it by just installing new and removing old one, all of your global NPM packages are gone. Here is how to update to new version of Node and reinstall packages:

Command

$ nvm install NEW_VERSION --reinstall-packages-from=OLD_VERSION
You can’t perform that action at this time.