Skip to content

Instantly share code, notes, and snippets.

View AleksandrChukhray's full-sized avatar

Aleksandr Chukhrai AleksandrChukhray

  • Ukraine, Kherson
View GitHub Profile
@m8r1x
m8r1x / asyncGenerator.js
Created June 17, 2018 07:15
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) {
@m8r1x
m8r1x / cache.js
Last active September 28, 2018 10:42
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;
@superjose
superjose / .gitlab-ci.yml
Last active July 24, 2025 23:21
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.
@Bellov
Bellov / All time zones in an array
Last active August 26, 2018 17:17
All time zones in an array
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',
@augbog
augbog / Free O'Reilly Books.md
Last active November 23, 2025 23:36
Free O'Reilly Books

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.
@Restuta
Restuta / HOC.js
Last active May 26, 2024 20:01
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 {
@cowboy
cowboy / HEY-YOU.md
Last active September 25, 2025 09:25
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.