Skip to content

Instantly share code, notes, and snippets.

@diem1
diem1 / 0_reuse_code.js
Created August 25, 2016 19:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@diem1
diem1 / component.js
Created August 5, 2016 13:00
взяття параметрів з адресної строки в react-router
ownerId = this.props.location.query.friend; // get params
ownerId = this.props.params.id;
@diem1
diem1 / some_js_file.js
Created June 22, 2016 09:31
Webpack config to support environment variables in JS app
var domain = process.env.DOMAIN || null;
console.log(domain);
@diem1
diem1 / nodejs-legacy.txt
Last active May 5, 2016 14:46
NPM /usr/bin/env: ‘node’: No such file or directory
sudo apt-get install nodejs-legacy
@diem1
diem1 / hello.html
Last active April 28, 2016 17:21
React Hello Word
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>React JS</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser.js"></script>
</head>
<body>
@diem1
diem1 / app.js
Last active April 14, 2016 07:20
Очень быстрый старт с Ember.js
// http://stepansuvorov.com/blog/2014/04/%D0%BE%D1%87%D0%B5%D0%BD%D1%8C-%D0%B1%D1%8B%D1%81%D1%82%D1%80%D1%8B%D0%B9-%D1%81%D1%82%D0%B0%D1%80%D1%82-%D1%81-ember-js/
App = Ember.Application.create({});
App.ApplicationController = Ember.Controller.extend({
message: 'А эту строку выведет в шаблон'
});
App.Router.map(function() {
this.route("index", { path: "/" });
this.route("list", { path: "/list" });
});
@diem1
diem1 / get_vk_access_token.coffee
Created March 11, 2016 08:34
NodeJS VK API Get Access token for app
clientId = '' # ID додатка
clientSecret = '' # Захисний ключ
vkRequest = require 'request-json'
client = vkRequest.createClient 'https://oauth.vk.com/'
params = 'access_token' +
'?client_id=' + clientId +
'&client_secret=' + clientSecret +
'&grant_type=client_credentials'
data =
@diem1
diem1 / random.coffee
Last active March 13, 2016 19:10
JS Random Number
n = Math.floor(Math.random() * 10 + 1)
console.log n
@diem1
diem1 / json_parse.js
Created March 9, 2016 13:34
NodeJS Json Parse (http.get)
var url = 'http://graph.facebook.com/517267866/?fields=picture';
var http = require('http');
http.get(url, function(res){
var body = '';
res.on('data', function(chunk){
body += chunk;
});
@diem1
diem1 / download_file_from_url.js
Last active August 5, 2016 12:56
Скачати файл з URL
var fs = require('fs'),
request = require('request');
request.get('http://res.cloudinary.com/hyper1/video/upload/v1453822340/blame_khmv2j.mp3').on('error', function(err) {
// handle error
}).pipe(fs.createWriteStream('2.mp3'));