Skip to content

Instantly share code, notes, and snippets.

@Om4ar
Om4ar / form-client.html
Created November 17, 2017 01:07
confirmation box and confirm a form before send a post request ( req.body ) / get request ( req.query )
<form action="/profile" method="post" id="myForm" >
<div class="form-group input-group-lg ">
<input type="hidden" name="dashboard" value="lock">
</div>
<input type="button" value="lock DashBoard" onclick="lockFunction()" class=" btn btn-danger btn-lg btn-fill">
</form> <!-- Dashboard lock form -->
// this is a dependecy for the confiramtion box http://bootboxjs.com/
@Om4ar
Om4ar / mongo
Created January 16, 2018 17:39
advanced query with mongodb laravel jenssegers
$take = (integer)$request->query("take");
$skip = (integer)$request->query("skip");
$filters = $request->all();
$queryArray = [];
foreach ( $filters as $key => $value){
if(($key == "take") || ($key == "skip")){
@Om4ar
Om4ar / 0. nginx_setup.sh
Created January 27, 2018 03:14 — forked from mikhailov/0. nginx_setup.sh
Nginx + secure pseudo-streaming
# Nginx can serve FLV/MP4 files by pseudo-streaming way without any specific media-server software.
# To do the custom build we use 2 modules: --with-http_secure_link_module --with-http_flv_module
# This module "secure-link" helps you to protect links from stealing away.
#
# NOTE: see more details at coderwall: http://coderwall.com/p/3hksyg
cd /usr/src
wget http://nginx.org/download/nginx-1.5.13.tar.gz
tar xzvf ./nginx-1.5.13.tar.gz && rm -f ./nginx-1.5.13.tar.gz
@Om4ar
Om4ar / handler.js
Created January 28, 2018 02:06 — forked from jeffrafter/handler.js
Simple HTTP Server and Router in node.js
exports.createHandler = function (method) {
return new Handler(method);
}
Handler = function(method) {
this.process = function(req, res) {
params = null;
return method.apply(this, [req, res, params]);
}
}
@Om4ar
Om4ar / readme.md
Created February 1, 2018 02:26 — forked from coolaj86/how-to-publish-to-npm.md
How to publish packages to NPM

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "[email protected]"
npm set init.author.url "http://yourblog.com"

npm adduser

@Om4ar
Om4ar / .js
Last active February 8, 2018 12:14
access nested variables and passing of undefined error in js
// check for empty objects/variables
isEmpty = value =>
value === null ||
value === undefined ||
value === "undefined" ||
value.length === 0 ||
value === {};
// access the nested variables or return null if undifined or doesn't exist
@Om4ar
Om4ar / Common-isEmpty.js
Created February 8, 2018 12:26 — forked from richardkundl/Common-isEmpty.js
Javascript is empty function
// Current value is empty
this.isEmpty = function(value){
return value == null // NULL value
|| value == undefined // undefined
|| value == 'undefined' // undefined
|| value.length == 0 // Array is empty
|| value == '00000000-0000-0000-0000-000000000000' // Guid empty
|| ((value instanceof Date && !isNaN(value.valueOf())) // Validate DateTime value and check min-max value
&& ((value <= new Date(1753, 01, 01)) // SQL DateTime minimum value
|| (value >= new Date(9999, 12, 31, 23, 59, 59, 999))) // SQL DateTime maximum value
@Om4ar
Om4ar / reflection.go
Created February 9, 2018 13:21 — forked from drewolson/reflection.go
Golang Reflection Example
package main
import (
"fmt"
"reflect"
)
type Foo struct {
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`
@Om4ar
Om4ar / Twelve_Go_Best_Practices.md
Created February 9, 2018 13:29 — forked from pzurek/Twelve_Go_Best_Practices.md
Twelve Go Best Practices
@Om4ar
Om4ar / ffmpeg.md
Created February 15, 2018 23:04 — forked from dvlden/ffmpeg.md
Convert video files to MP4 through FFMPEG

This is my personal list of functions that I wrote for converting mov files to mp4!

Command Flags

Flag Options Description
-codec:a libfaac, libfdk_aac, libvorbis Audio Codec
-quality best, good, realtime Video Quality
-b:a 128k, 192k, 256k, 320k Audio Bitrate
-codec:v mpeg4, libx264, libvpx-vp9 Video Codec