Skip to content

Instantly share code, notes, and snippets.

View humoyun's full-sized avatar
:atom:
Always Eager

Humoyun humoyun

:atom:
Always Eager
View GitHub Profile
@BretCameron
BretCameron / index.js
Created June 1, 2019 12:29
Use Node.js to get a list of files from Google Drive and save them locally
const { google } = require('googleapis');
const fs = require('fs');
const credentials = require('./credentials.json');
const scopes = [
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/spreadsheets',
];
@jsdevtom
jsdevtom / frontend-ws-connection.ts
Last active April 17, 2024 07:35
kubernetes-ingress websockets with nodejs
export const ws = webSocket<WebsocketMessage>(`wss://${location.hostname}:${location.protocol === 'https:' ? 443 : 80}/ws/`);
export const wsObserver = ws
.pipe(
retryWhen(errors =>
errors.pipe(
delay(1000)
)
)
);
@bradtraversy
bradtraversy / docker-help.md
Last active April 18, 2024 21:04
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@virolea
virolea / upload.js
Last active March 15, 2024 13:45
Tracking file upload progress using axios
upload(files) {
const config = {
onUploadProgress: function(progressEvent) {
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
console.log(percentCompleted)
}
}
let data = new FormData()
data.append('file', files[0])
@avinmathew
avinmathew / index.jsx
Created August 8, 2017 11:54
Multiple layouts with React Router v4
import React from "react"
import { Route, Switch } from "react-router-dom"
const AppRoute = ({ component: Component, layout: Layout, ...rest }) => (
<Route {...rest} render={props => (
<Layout>
<Component {...props} />
</Layout>
)} />
)
@muminoff
muminoff / pano-converter3.py
Created June 17, 2017 16:28
Equirectangular panorama to cube map (Python 3)
import sys
from PIL import Image
from math import pi,sin,cos,tan,atan2,hypot,floor
from numpy import clip
# get x,y,z coords from out image pixels coords
# i,j are pixel coords
# face is face number
# edge is edge length
def outImgToXYZ(i,j,face,edge):
@markerikson
markerikson / arrayBatchedActionsEnhancer.js
Last active December 28, 2021 09:23
Redux array batched actions enhancer
// copy-pasta'd from isarray
var toString = {}.toString;
const isArray = Array.isArray || function (arr) {
return toString.call(arr) == '[object Array]';
};
export function batchedSubscribe() {
let currentListeners = [];
@amysimmons
amysimmons / js-tricky-bits.md
Last active November 16, 2022 02:42
Understanding closures, callbacks and promises in JavaScript

#Understanding closures, callbacks and promises

For a code newbie like myself, callbacks, closures and promises are scary JavaScript concepts.

10 months into my full-time dev career, and I would struggle to explain these words to a peer.

So I decided it was time to face my fears, and try to get my head around each concept.

Here are the notes from my initial reading. I'll continue to refine them as my understanding improves.

@paulirish
paulirish / what-forces-layout.md
Last active April 19, 2024 14:42
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
@protrolium
protrolium / ffmpeg.md
Last active April 8, 2024 11:49
ffmpeg guide

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

You can get the list of installed codecs with: