Skip to content

Instantly share code, notes, and snippets.

View anonimusprogramus's full-sized avatar

Anonimus Programus anonimusprogramus

View GitHub Profile
@koalicioous
koalicioous / get.ts
Created August 3, 2023 00:04
Get Deeply Nested Value in JavaScript
/**
* @param {Object} object
* @param {string|Array<string>} path
* @param {*} [defaultValue]
* @return {*}
*/
export default function get(object, path, defaultValue) {
const path = Array.isArray(pathParam) ? pathParam : pathParam.split('.');
let index = 0;
@koakh
koakh / gist:fbbc37cde630bedcf57acfd4d6a6956b
Last active April 6, 2024 02:04
SurrealDB : How to use signin and signup (server + client nodesjs)
**As a developer you have complete control over the signup and signin functionality...**
```shell
$ surreal sql --conn http://localhost:8000 --user root --pass root --ns test --db test
```
```sql
-- optional : this is the default see --ns test --db test start server flags
-- USE NS test DB test;
@nucklehead
nucklehead / cleanIcon.js
Last active May 20, 2024 19:04
Script to clean unused icons in ionic
#!/bin/env node
let path = require('path'), fs=require('fs');
function fromDir(startPath, filter, callback){
if (!fs.existsSync(startPath)){
console.log("no dir ",startPath);
return;
}
@mebjas
mebjas / html-file.html
Last active April 27, 2024 09:39
Demo code on using github.com/mebjas/html5-qrcode. This was used in https://blog.minhazav.dev/research/html5-qrcode.html
<html>
<head>
<title>Html-Qrcode Demo</title>
<body>
<div id="qr-reader" style="width:500px"></div>
<div id="qr-reader-results"></div>
</body>
<script src="https://raw.githubusercontent.com/mebjas/html5-qrcode/master/minified/html5-qrcode.min.js"></script>
<script src="html5-qrcode-demo.js"></script>
</head>
@naoki-sawada
naoki-sawada / client.js
Last active May 2, 2024 16:11
Simple socket.io room and auth example
const io = require('socket.io-client');
const socket = io('http://localhost:3000', {
transportOptions: {
polling: {
extraHeaders: {
'Authorization': 'Bearer abc',
},
},
},
@joeytwiddle
joeytwiddle / async-await-forEach-alternatives.md
Last active July 22, 2024 09:05
Do not use forEach with async-await

Do not use forEach with async-await

TLDR: Use for...of instead of forEach() in asynchronous code.

For legacy browsers, use for...i or [].reduce()

To execute the promises in parallel, use Promise.all([].map(...))

The problem

@twilson63
twilson63 / README.md
Created March 13, 2018 00:16
Pouchdb Server with MySQL Backend

PouchDB Server using a MySQL Backend

PouchDB server is a nodejs implementation of CouchDB. Below is the steps to use AmazonRDS and NowJS to deploy your own PouchDB Server. Using MySQL as a persistent backend.

Amazon Web Services

Create a Amazon Web Services Account

https://aws.amazon.com

@atomjar
atomjar / product_style
Last active January 22, 2024 11:57
Stylesheet for Vue Mastery's Intro to Vue course
body {
font-family: tahoma;
color:#282828;
margin: 0px;
}
.nav-bar {
background: linear-gradient(-90deg, #84CF6A, #16C0B0);
height: 60px;
margin-bottom: 15px;
@hagemann
hagemann / slugify.js
Last active October 30, 2023 09:10
Slugify makes a string URI-friendly
function slugify(string) {
const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìıİłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;'
const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------'
const p = new RegExp(a.split('').join('|'), 'g')
return string.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
.replace(/&/g, '-and-') // Replace & with 'and'
.replace(/[^\w\-]+/g, '') // Remove all non-word characters
@jstott
jstott / paginated.js
Created January 14, 2017 16:22
lodash paginated items
function getPaginatedItems(items, page, pageSize) {
var pg = page || 1,
pgSize = pageSize || 100,
offset = (pg - 1) * pgSize,
pagedItems = _.drop(items, offset).slice(0, pgSize);
return {
page: pg,
pageSize: pgSize,
total: items.length,
total_pages: Math.ceil(items.length / pgSize),