Skip to content

Instantly share code, notes, and snippets.

View ianva's full-sized avatar

ianva ianva

  • EF
  • Saltanat Balghymbayev St 69
View GitHub Profile
@jamesfulford
jamesfulford / useTime.js
Last active December 13, 2022 09:07
useTime() React hook
//
// useTime hook
//
import { useEffect, useState } from 'react';
export const useTime = (refreshCycle = 100) => {
// Returns the current time
// and queues re-renders every `refreshCycle` milliseconds (default: 100ms)
const [now, setNow] = useState(getTime());
@shirakaba
shirakaba / setup.md
Last active May 16, 2024 13:57
Configuring Nexus as a private registry for npm packages

Get the details to connect to your Nexus-managed npm repository

Note: Nexus group repositories (good example in this StackOverflow question) are out of this tutorial's scope. In any case, deployment to group repositories is currently still an open issue for Nexus 3 (and not intended ever to be implemented in Nexus 2). Thus, it is assumed that we'll push & pull to/from the same repository, and ignore the idea of groups hereon in.

  1. Ask your sysadmin for a username & password allowing you to log into your organistation's Nexus Repository Manager.

  2. Test the login credentials on the Nexus Repository manager at: http://localhost:8081/nexus/#view-repositories (localhost in our case is replaced by a static IP, and can only be connected to over VPN). If your organisation requires a VPN to connect to it, connect to that VPN before proceeding with this tutori

@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active July 22, 2024 06:03
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@thorsten
thorsten / setUserAgent.js
Created May 9, 2016 15:12
Override user agent on all browsers
function setUserAgent(window, userAgent) {
// Works on Firefox, Chrome, Opera and IE9+
if (navigator.__defineGetter__) {
navigator.__defineGetter__('userAgent', function () {
return userAgent;
});
} else if (Object.defineProperty) {
Object.defineProperty(navigator, 'userAgent', {
get: function () {
return userAgent;
@paullewis
paullewis / requestIdleCallback.js
Last active June 11, 2024 21:10
Shims rIC in case a browser doesn't support it.
/*!
* Copyright 2015 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@paulirish
paulirish / what-forces-layout.md
Last active July 22, 2024 06:32
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@rsms
rsms / 0 input.js
Last active November 15, 2020 04:51
Pattern-matching parse-time macros for Babel
macro { mul(...$args) sdf } -> { [not_matched, $args] }
macro { mul(...$args) } -> { [matched, $args] }
macro { foo $a x ...$b y } -> { mul($a, $b) + 3 }
lol()
console.log( foo 1 x 2, 3 y, 6 )
@roman01la
roman01la / index.jsx
Created July 30, 2015 14:03
Maybe monad in React
// this will fail on if there's no data
React.createClass({
render() {
return <div>renderComplexWidget(this.props.data)</div>;
}
});
// this will not; if no data — return null
React.createClass({
@wojons
wojons / README
Last active February 19, 2019 05:18 — forked from sasha-id/README
mongos mongoc mongod upstart
MongoDB upstart scripts for Ubuntu.
Run following commands after installing upstart scripts:
ln -s /lib/init/upstart-job /etc/init.d/mongoconf
ln -s /lib/init/upstart-job /etc/init.d/mongodb
ln -s /lib/init/upstart-job /etc/init.d/mongos
To start services use:
@stavxyz
stavxyz / mongodb-master-no-fork.conf
Last active February 19, 2019 14:05
supervisor - redis + mongo
master = true
#vv = true
port = 27017
bind_ip = 0.0.0.0
auth = false
noauth = true
jsonp = true
rest = true
fork = false
#upgrade = true