Skip to content

Instantly share code, notes, and snippets.

View tuchk4's full-sized avatar
🇺🇦
Focusing

Valerii Sorokobatko tuchk4

🇺🇦
Focusing
View GitHub Profile
@tuchk4
tuchk4 / index.js
Last active December 14, 2017 19:11 — forked from zkat/index.js
npx is cool
#!/usr/bin/env node
console.log('yay gist');
console.log(process.argv);
@tuchk4
tuchk4 / index.js
Last active December 14, 2017 19:10
#!/usr/bin/env node
const fetch = require('node-fetch');
const cheerio = require('cheerio');
const chalk = require('chalk');
fetch('http://kharkivjs.org/')
.then(response => response.text())
.then(html => {
const $ = cheerio.load(html);
@tuchk4
tuchk4 / index.js
Created December 7, 2017 10:27
#1 ― async / await (KharkivJS)
function squareAfter2Seconds(x) {
return new Promise(resolve => {
setTimeout(() => {
resolve(x * x);
}, 2000);
});
}
async function calc() {
const a = await squareAfter2Seconds(10);
@tuchk4
tuchk4 / any-component.js
Created February 11, 2017 11:37
Aphrodite as CSS Modules
import styles from './styles.js';
redner() {
const props = this.props;
const classList = classname(props.className, css.button, {
[css.primary]: props.primary
});
@tuchk4
tuchk4 / stateless-static-props-inside-function.js
Last active May 30, 2016 08:39
PropTypes for stateless components. Would be great If static keyword inside function block - is a link to function object (constructor). So we can write as at the first example.
export default (props) => {
// this is not possible, but I think this is more readable that next example
static propTypes = {
name: PropsTypes.string.requried
};
return <Div>{props.name}</Div>;
}
@tuchk4
tuchk4 / angularjs-configuration.js
Last active December 1, 2015 09:44
Configuration - Valentjs vs AngularJS
angular.module('example').provider('app.route', ['$routeProvider', function($routeProvider) {
return {
when: function(path, config) {
if (!config.resolve) {
config.resolve = {};
}
// Add resolver for each registered route
config.resolve.permission = function() {
// ...
@tuchk4
tuchk4 / angularjs-directive.js
Created December 1, 2015 09:04
Directive - Valentjs vs AngularJS
angular.module('example').directive('helloWorld', function() {
return {
restrict: 'E',
template: '<div> {{ name }} </div>',
link: function(scope, element) {
// scope.name = 1;
element.addClass('orange')l
},
controller: ['$scope', funtion($scope) {
$scope.name = 1;
@tuchk4
tuchk4 / angularjs-route.js
Created December 1, 2015 09:00
Route - Valentjs vs AngularJS
angular.module('example').config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/home', {
controller: 'home',
template: '<div> {{ name }} </div>'
});
}]);
@tuchk4
tuchk4 / angularjs-controller.js
Last active December 1, 2015 08:38
Valentjs vs AngularJS
angular.module('example').controller('home', ['$scope', function($scope) {
$scope.name = 'home';
});
angular.module('example').config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/home', {
controller: 'home',
template: '<div> {{ name }} </div>'
});
}]);
@tuchk4
tuchk4 / bootstrap.js
Last active November 24, 2015 11:55
Valentjs simple examples
import Angular from 'valent/angular';
let framework = new Angular({
module: 'your-application-name'
});
valent.bootstrap(framework);