Skip to content

Instantly share code, notes, and snippets.

View akhenda's full-sized avatar
🏠
Working from home

akhenda

🏠
Working from home
View GitHub Profile
@akhenda
akhenda / Coverage Badges
Last active October 1, 2024 18:08
Coverage Badges
Coverage Badges
@akhenda
akhenda / harden-Ubuntu2004.sh
Created August 5, 2022 18:15 — forked from aessing/harden-Ubuntu2004.sh
Harden Ubuntu 20.04 server installation
#!/bin/bash
# =============================================================================
# Harden Ubuntu Linux 20.04 (focal)
# Run commands as root (sudo su -)
# -----------------------------------------------------------------------------
# Developer.......: Andre Essing (https://www.andre-essing.de/)
# (https://github.com/aessing)
# (https://twitter.com/aessing)
# (https://www.linkedin.com/in/aessing/)
# -----------------------------------------------------------------------------
@akhenda
akhenda / vscode_shortcuts.md
Created May 31, 2021 11:42 — forked from bradtraversy/vscode_shortcuts.md
Helpful shortcuts for VSCode

VSCode Shortcuts

List of helpful shortcuts for faster coding

If you have any other helpful shortcuts, feel free to add in the comments of this gist :)

Official List of all commands

@akhenda
akhenda / randomDarkColor.js
Created April 9, 2021 12:20 — forked from chak10/randomDarkColor.js
Javascript Random Dark Color
function randDarkColor() {
var lum = -0.25;
var hex = String('#' + Math.random().toString(16).slice(2, 8).toUpperCase()).replace(/[^0-9a-f]/gi, '');
if (hex.length < 6) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
var rgb = "#",
c, i;
for (i = 0; i < 3; i++) {
c = parseInt(hex.substr(i * 2, 2), 16);
@akhenda
akhenda / setupSnapshotTest.ts
Created January 13, 2021 12:01 — forked from axelnormand/setupSnapshotTest.ts
React Native Storybook
import addons from '@storybook/addons';
import { createMockChannel } from 'src/test/storybook/storyshots/mockChannel';
//
// This runs to mock things required for the jest snapshot of a story
//
// In generated test, import this straight as `import 'src/test/storybook/storyshots/setupSnapshotTest'`
// Then require mocked storybook methods
// `const { configure, getStorybook } = require('@storybook/react-native');`
//
@akhenda
akhenda / query.js
Created January 8, 2021 21:36 — forked from sdgluck/query.js
Pagination using Mongo: populate, match, sort, count, and limit with the aggregation pipeline
/**
* Query blog posts by user -> paginated results and a total count.
* @param userId {ObjectId} ID of user to retrieve blog posts for
* @param startRow {Number} First row to return in results
* @param endRow {Number} Last row to return in results
* @param [filter] {Object} Optional extra matching query object
* @param [sort] {Object} Optional sort query object
* @returns {Object} Object -> `{ rows, count }`
*/
function queryBlogPostsByUser (userId, startRow, endRow, filter = {}, sort = false) {
@akhenda
akhenda / firebase.json
Created December 19, 2020 16:56 — forked from katowulf/firebase.json
Example of Firebase emulator unit tests and seed Firestore data
{
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"emulators": {
"firestore": {
"port": 8080
}
}
@akhenda
akhenda / Setup MongoDB on localhost as Replica Set
Created October 21, 2020 22:00 — forked from davisford/Setup MongoDB on localhost as Replica Set
Setup MongoDB replica set on local host with only a single primary
Add the `replication` section to the mongod.conf file:
```
$cat /usr/local/etc/mongod.conf
systemLog:
destination: file
path: /usr/local/var/log/mongodb/mongo.log
logAppend: true
storage:
engine: mmapv1
@akhenda
akhenda / ansible-github.yml
Created October 5, 2020 16:02 — forked from devynspencer/ansible-github.yml
Example playbook for cloning a private git repository with Ansible.
---
hosts: all
tasks:
- name: add github ssh key
copy: >
src=files/id_rsa.github
dest=/root/.ssh/id_rsa.github
owner=root
group=root
@akhenda
akhenda / deepDiffObj.js
Created April 9, 2020 18:56 — forked from tennox/deepDiffObj.js
Deep diff between two object, using lodash
import _ from 'lodash';
/**
* Deep diff between two objects - i.e. an object with the new value of new & changed fields.
* Removed fields will be set as undefined on the result.
* Only plain objects will be deeply compared (@see _.isPlainObject)
*
* Inspired by: https://gist.github.com/Yimiprod/7ee176597fef230d1451#gistcomment-2565071
* This fork: https://gist.github.com/TeNNoX/5125ab5770ba287012316dd62231b764/
*