Skip to content

Instantly share code, notes, and snippets.

View AhmedBHameed's full-sized avatar
💭
Searching for new challenge

Ahmed HAMEED AhmedBHameed

💭
Searching for new challenge
View GitHub Profile
@harveyconnor
harveyconnor / a-mongodb-replica-set-docker-compose-readme.md
Last active June 24, 2024 15:07
MongoDB Replica Set / docker-compose / mongoose transaction with persistent volume

This will guide you through setting up a replica set in a docker environment using.

  • Docker Compose
  • MongoDB Replica Sets
  • Mongoose
  • Mongoose Transactions

Thanks to https://gist.github.com/asoorm for helping with their docker-compose file!

@virtyaluk
virtyaluk / install.sh
Last active September 12, 2021 17:52
Getting your Raspberry Pi/Asus TinkerBoard up and running: installing essential apt packages, Golang, Node.js, Docker.
sudo su
# In case of TinkerBoard, use the `tinker-config` alternative to the rpi's raspi-config
wget https://raw.githubusercontent.com/mikerr/tinker-config/master/tinker-config
# Enable multiverse repository
sed -i "/^# deb.*multiverse/ s/^# //" /etc/apt/sources.list
apt-get update
apt-get upgrade -y
@beradrian
beradrian / proxy.js
Created January 18, 2018 18:11
CORS proxy with node-http-proxy
/** If you want to use the local development environment with the dev backend,
* this will create a proxy so you won't run into CORS issues.
* It accepts the following command line parameters:
* - port the port where the proxy will listen
* - target the DEV backend target to contact.
* Example: If you set the port to 3000 and target to https://dev.nibo.ai then
* your actual "resourceBaseUrl" in NiboSettings should be http://localhost:3000/api/v1
*/
// Define the command line options
const optionDefinitions = [
git log --all --grep="search text"
@javilobo8
javilobo8 / download-file.js
Last active July 1, 2024 23:21
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@gilbarbara
gilbarbara / ReduxRouter.jsx
Last active November 28, 2019 18:01
react-router v4 with redux
import React from 'react';
import { Router } from 'react-router-dom';
import createBrowserHistory from 'history/createBrowserHistory';
const LOCATION_CHANGE = '@@router/LOCATION_CHANGE';
export const history = createBrowserHistory();
class ReduxRouter extends React.Component {
static propTypes = {
@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),
@btroncone
btroncone / rxjs_operators_by_example.md
Last active June 15, 2024 07:17
RxJS 5 Operators By Example
@danielalvarenga
danielalvarenga / terminal-colors-branch.sh
Last active July 3, 2024 08:16
Show branch in terminal Ubuntu
# Add in ~/.bashrc or ~/.bash_profile
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
RED="\[\033[01;31m\]"
YELLOW="\[\033[01;33m\]"
GREEN="\[\033[01;32m\]"
BLUE="\[\033[01;34m\]"
NO_COLOR="\[\033[00m\]"
@leipert
leipert / detectBrowserLanguage.js
Last active March 11, 2024 02:10 — forked from anonymous/detectBrowserLanguage.js
Detect browser language in javascript (utilizing lodash)
// These window.navigator contain language information
// 1. languages -> Array of preferred languages (eg ["en-US", "zh-CN", "ja-JP"]) Firefox^32, Chrome^32
// 2. language -> Preferred language as String (eg "en-US") Firefox^5, IE^11, Safari,
// Chrome sends Browser UI language
// 3. browserLanguage -> UI Language of IE
// 4. userLanguage -> Language of Windows Regional Options
// 5. systemLanguage -> UI Language of Windows
var browserLanguagePropertyKeys = ['languages', 'language', 'browserLanguage', 'userLanguage', 'systemLanguage'];