Skip to content

Instantly share code, notes, and snippets.

@Om4ar
Om4ar / mongodb.service
Created April 25, 2018 01:51 — forked from Genda1ph/mongodb.service
MongoDB systemd service unit configuration
[Unit]
Description=MongoDB Database Service
Wants=network.target
After=network.target
[Service]
Type=simple
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p /var/lib/mongodb
ExecStartPre=/bin/chown mongodb:mongodb /var/lib/mongodb
@Om4ar
Om4ar / mongodb.service
Created April 25, 2018 01:51 — forked from jwilm/mongodb.service
MongoDB systemd service unit configuration
[Unit]
Description=MongoDB Database Service
Wants=network.target
After=network.target
[Service]
Type=forking
PIDFile=/var/run/mongodb/mongod.pid
ExecStart=/usr/local/bin/mongod --config /etc/mongod.conf
ExecReload=/bin/kill -HUP $MAINPID
@Om4ar
Om4ar / php curl post
Created June 14, 2018 10:28 — forked from jarontai/php curl post
php curl post
function post_to_url($url, $data) {
$fields = '';
foreach($data as $key => $value) {
$fields .= $key . '=' . $value . '&';
}
rtrim($fields, '&');
$post = curl_init();
curl_setopt($post, CURLOPT_URL, $url);
@Om4ar
Om4ar / version_compare.js
Created June 26, 2018 17:45 — forked from pc035860/version_compare.js
Function to compare two version strings (e.g. "1.6.1" is smaller than "1.7"). Developed in order to answer http://stackoverflow.com/a/6832721/50079.
/**
* Compares two software version numbers (e.g. "1.7.1" or "1.2b").
*
* This function was born in http://stackoverflow.com/a/6832721.
*
* @param {string} v1 The first version to be compared.
* @param {string} v2 The second version to be compared.
* @param {object} [options] Optional flags that affect comparison behavior:
* <ul>
* <li>
@Om4ar
Om4ar / workbox.md
Created July 24, 2018 15:17 — forked from addyosmani/workbox.md
Workbox recipes

Workbox runtime caching recipes

Your Service Worker script will need to import in Workbox and initialize it before calling any of the routes documented in this write-up, similar to the below:

importScripts('workbox-sw.prod.v1.3.0.js');
const workbox = new WorkboxSW();

// Placeholder array populated automatically by workboxBuild.injectManifest()

This describes the common mistake with using closures in JavaScript.

A function defines a new environment

Consider:

function makeCounter()
{
  var obj = {counter: 0};
@Om4ar
Om4ar / cors.md
Created July 29, 2018 01:12 — forked from liamgriffiths/cors.md
How CORS works

Guide to CORS

CORS (cross origin resource sharing) is a mechanism to allow client web applications make HTTP requests to other domains. For example if you load a site from http://domainA.com and want to make a request (via xhr or img src, etc) to http://domainB.com without using CORS your web browser will try to protect you by blocking the response from the other server. This is because browsers restrict responses coming from other domains via the Same-Origin-Policy.

CORS allows the browser to use reponses from other domains. This is done by including a Access-Control headers in the server responses telling the browser that requests it is making is OK and safe to use the response.

Header Description
Access-Control-Allow-Origin: Allow requests from `` to access t
@Om4ar
Om4ar / commit-emoji.md
Created September 22, 2018 00:48 — forked from silencesys/commit-emoji.md
List of emoji for git commits.

Git Commit Message

All Git Commit Messages MUST meet with this Text Format:

:emoji: Subject
(Only One NewLine)
Message Body
(Only One NewLine)
Ref &lt;###&gt;
@Om4ar
Om4ar / axios-configure.js
Created November 27, 2018 19:57 — forked from wisetc/axios-configure.js
Configuration of axios instance to make POST requests.
import axios from 'axios'
import { Message } from 'element-ui'
export const baseUrl = 'http://example.com/api';
const transformRequest = (data={}) => {
if (typeof data === 'string') return data;
if (!data.oauth)
data.oauth = localStorage.getItem("token")? localStorage.getItem("token"): (sessionStorage.getItem("token") || "");
@Om4ar
Om4ar / update-golang.md
Created December 1, 2018 19:22 — forked from nikhita/update-golang.md
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by: