Skip to content

Instantly share code, notes, and snippets.

@lokeshjawane
lokeshjawane / S3-to-GCS.js
Created September 25, 2018 12:43
Script to sync s3 obj to GCS in realtime
//This script is to copy S3 object to GCS in asynchronously using Lambda function
//set var "gcp_proj_id" with value of you GCP project ID
//set var "gcp_client_email" with value of your client email address from JSON key file & make sure that user has GCS create object permission
//set var "cred_bucket", here provode a s3 bucket from where lambsa will fetch the JSON creds file to GCP auth
//Set vat "cred_s3_obj", here you provide a json keyfile name which is uploaded in "cred_bucket" s23 bucket
//**NOTE**: set HOME env var with value "/tmp" in lambda function, because google-cloud/storage create file locally & in lambda only /tmp is writable. Run lambda function on S3 create object event based.
//
'use strict';
@YumaInaura
YumaInaura / ZSH.md
Last active April 26, 2024 05:04
Zsh — Mac OS option key for bindkey

Zsh — Mac OS option key for bindkey

Probably this is resolving of just binding as character.

Not related with like some escape sequences or special characters.

Example

In Mac OS bind Option + a

@fitsum
fitsum / if(array.indexOf(someObj) === -1) {add} else {next}
Last active April 26, 2024 05:02
check if obj exists in array then add if not
var source = [{name: "Fitsum", race: "blk"},{name: "Alice", race: "wht"},{name: "Jen", race: "wht"},{name: "Kim", race: "blk"},{name: "Lee", race: "asn"}],
target = [];
function userExists(name, idx, oldArr) {
return target.some(function(el) {
return el.name === name;
});
}
function addUser(name, idx, newArr) {
@maciekglowka
maciekglowka / three-to-mtl.js
Created January 2, 2022 15:21
Extracting material data for OBJ files exported from THREE.js
const url = 'https://URL-TO-YOUR-GLTF.gltf'
function imageToData (image) {
// heavily inspired by COLLADA Exporter ;)
let canvas = document.createElement('canvas')
const ctx = canvas.getContext('2d')
canvas.width = image.width
canvas.height = image.height
ctx.drawImage(image, 0, 0)
const dataUrl = canvas.toDataURL('image/png')
@piyushgarg-dev
piyushgarg-dev / Dockerfile
Created October 21, 2023 10:00
Docker In One Shot
FROM ubuntu
RUN apt-get update
RUN apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get upgrade -y
RUN apt-get install -y nodejs
COPY package.json package.json
COPY package-lock.json package-lock.json
@alexxuss1996
alexxuss1996 / deepCopy.js
Created January 4, 2023 11:13
Fuction to create obj copy w/o ref
function deepCopy(obj) {
var copy;
// Handle three simple types, null, and undefined
if (obj == null || typeof obj != "object") {
return obj;
}
// Handle Date
@fire1ce
fire1ce / oh-my-zsh on openwrt or lede-project.md
Last active April 26, 2024 05:00
Install oh-my-zsh on openwrt/lede-project

Install oh-my-zsh on OpenWrt

Install Requirements Packages

opkg update && opkg install ca-certificates zsh curl git-http

Install oh-my-zsh

@felipewget
felipewget / Chaser Test
Created October 7, 2018 07:24
This is a test of ordenation and median by obj key.
/**
* Archive to test of ordination and median
*
*
* @author Felipe Oliveira <felipe@chatnizer.com> OR <felipe.wget@gmail.com>
* @version 0.1
*/
var objSamples = [
{
@Jeff-Russ
Jeff-Russ / time_elapsed.js
Created May 15, 2016 04:40
Construct a JS obj to determine time elapsed in ms
// TimeElapsed constructs an object for use in determining
// time elapsed in milliseconds
// constructor:
function TimeElapsed(){
var start, elapsed;
function getstamp(){ return (new Date().getTime());}
this.get = function(){
@gabrielqmatos
gabrielqmatos / findInObj.js
Created September 4, 2019 14:31
easy search and extract obj path searching into object
function getPath(obj, key) {
paths = []
function getPaths(obj, path) {
if (obj instanceof Object && !(obj instanceof Array)) {
for (var k in obj){
paths.push(path + "." + k)
getPaths(obj[k], path + "." + k)
}
}