Skip to content

Instantly share code, notes, and snippets.

View AleksandrChukhray's full-sized avatar

Aleksandr Chukhrai AleksandrChukhray

  • Ukraine, Kherson
View GitHub Profile

Free O'Reilly books and convenient script to just download them.

Thanks /u/FallenAege/ and /u/ShPavel/ from this Reddit post

How to use:

  1. Take the download.sh file and put it into a directory where you want the files to be saved.
  2. cd into the directory and make sure that it has executable permissions (chmod +x download.sh should do it)
  3. Run ./download.sh and wee there it goes. Also if you do not want all the files, just simply comment the ones you do not want.
@AleksandrChukhray
AleksandrChukhray / .gitlab-ci.yml
Created September 28, 2018 14:08 — forked from superjose/.gitlab-ci.yml
This is an example of a .gitlab-ci.yml that is required for Continuous Integration on GitLab projects.
# Reference: https://www.exclamationlabs.com/blog/continuous-deployment-to-npm-using-gitlab-ci/
# GitLab uses docker in the background, so we need to specify the
# image versions. This is useful because we're freely to use
# multiple node versions to work with it. They come from the docker
# repo.
# Uses NodeJS V 9.4.0
image: node:9.4.0
# And to cache them as well.
@AleksandrChukhray
AleksandrChukhray / gitlab-ci.yml
Created September 28, 2018 10:45
Publish your create-react-app website via Gitlab CI. tags: #gitlab #git #deploy #ci
image: node:6.5.0 # can be upgraded, depending on your node version used
pages:
stage: deploy
script:
- npm install
- npm run build
- rm -rf public
- mv build public
artifacts:
@AleksandrChukhray
AleksandrChukhray / cache.js
Created September 28, 2018 10:42 — forked from m8r1x/cache.js
Function Cache and Async function timer
function cacheFn(fn) {
const cache = new Map(); // need .has, .get, .set methods.
return (...args) => {
const cacheKey = JSON.stringify(args.reduce((argsObject, arg, index) => { argsObject[index] = arg; return argsObject }, {}));
if (cache.has(cacheKey)) {
return cache.get(cacheKey);
}
const computed = fn(...args);
cache.set(cacheKey, computed);
return computed;
@AleksandrChukhray
AleksandrChukhray / asyncGenerator.js
Created September 28, 2018 10:42 — forked from m8r1x/asyncGenerator.js
Promises + Generators
function async(generatorFn) {
return function () {
var iterator = generatorFn.apply(this, arguments);
function handle(result) {
if (result.done) return Promise.resolve(result.value);
return Promise.resolve(result.value).then(function (res) {
return handle(iterator.next(res));
}, function (err) {
@AleksandrChukhray
AleksandrChukhray / HOC.js
Created July 9, 2018 13:15 — forked from Restuta/HOC.js
React HOC (Higher Order Component) Example
/* HOC fundamentally is just a function that accepts a Component and returns a Component:
(component) => {return componentOnSteroids; } or just component => componentOnSteroids;
Let's assume we want to wrap our components in another component that is used for debugging purposes,
it just wraps them in a DIV with "debug class on it".
Below ComponentToDebug is a React component.
*/
//HOC using Class
//it's a function that accepts ComponentToDebug and implicitly returns a Class
let DebugComponent = ComponentToDebug => class extends Component {
return array(
'Pacific/Midway' => '(UTC-11:00) Midway',
'Pacific/Niue' => '(UTC-11:00) Niue',
'Pacific/Pago_Pago' => '(UTC-11:00) Pago Pago',
'America/Adak' => '(UTC-10:00) Adak',
'Pacific/Honolulu' => '(UTC-10:00) Honolulu',
'Pacific/Johnston' => '(UTC-10:00) Johnston',
'Pacific/Rarotonga' => '(UTC-10:00) Rarotonga',
'Pacific/Tahiti' => '(UTC-10:00) Tahiti',
'Pacific/Marquesas' => '(UTC-09:30) Marquesas',
return array(
'Pacific/Midway' => '(UTC-11:00) Midway',
'Pacific/Niue' => '(UTC-11:00) Niue',
'Pacific/Pago_Pago' => '(UTC-11:00) Pago Pago',
'America/Adak' => '(UTC-10:00) Adak',
'Pacific/Honolulu' => '(UTC-10:00) Honolulu',
'Pacific/Johnston' => '(UTC-10:00) Johnston',
'Pacific/Rarotonga' => '(UTC-10:00) Rarotonga',
'Pacific/Tahiti' => '(UTC-10:00) Tahiti',
'Pacific/Marquesas' => '(UTC-09:30) Marquesas',
@AleksandrChukhray
AleksandrChukhray / README.md
Created January 18, 2018 11:41 — forked from hsablonniere/README.md
scrollIntoViewIfNeeded 4 everyone!!!

scrollIntoViewIfNeeded 4 everyone!!!

This gist provides a simple JavaScript implementation of the non-standard WebKit method scrollIntoViewIfNeeded that can be called on DOM elements.

Usage

Just use the code in index.js in your app or website. You can see usage in the test page test.html.

The parent element will only scroll if the element being called is out of the view. The boolean can force the element to be centered in the scrolling area.

@AleksandrChukhray
AleksandrChukhray / install_lamp_16.sh
Created April 7, 2017 23:23 — forked from ankurk91/install_lamp_ubuntu.sh
Prepare Ubuntu 16.04 for PHP development (php 7.0, MySQL 5.6, apache 2.4)
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Ubuntu 16.04 Dev Server
# Don't source it, run like - bash install_lamp.sh
# Script will auto terminate on errors
# Prevent source