Skip to content

Instantly share code, notes, and snippets.

View maneja81's full-sized avatar
💭
eat; sleep; code; repeat;

Mohit Aneja maneja81

💭
eat; sleep; code; repeat;
View GitHub Profile
@maneja81
maneja81 / run-in-terminal
Last active September 2, 2021 03:00
Commands to generate RSA private and public keys of 4096 bits encrypted via AES256
# Private key
$ openssl genrsa -passout pass:{STRONG-PASSWORD} -out {PATH}/private.pem -aes256 4096
# Pulbic key from the
$ openssl rsa -passin pass:{STRONG-PASSWORD} -pubout -in {PATH}/private.pem -out {PATH}/public.pem
@maneja81
maneja81 / CSS Close Symbol
Created December 26, 2019 08:21
Close button in pure css
.close-button {
position: absolute;
top: 0;
right: 0;
width: 48px;
height: 48px;
background: #41415B;
border-radius: 48px;
margin-top: -24px;
@maneja81
maneja81 / custom-menu-panel.php
Created September 27, 2017 14:28 — forked from nikolov-tmw/custom-menu-panel.php
This registers a custom meta box for nav menus and renders it. Obviously $my_items would ideally be not hard-coded and instead it would come somewhere from the DB. The custom items add to the menu and save properly, but will probably not be displayed correctly. You might need to hook to the 'wp_setup_nav_menu_item' filter in order to fix the men…
<?php
function my_register_menu_metabox() {
$custom_param = array( 0 => 'This param will be passed to my_render_menu_metabox' );
add_meta_box( 'my-menu-test-metabox', 'Test Menu Metabox', 'my_render_menu_metabox', 'nav-menus', 'side', 'default', $custom_param );
}
add_action( 'admin_head-nav-menus.php', 'my_register_menu_metabox' );
/**
@maneja81
maneja81 / script.js
Created May 26, 2017 12:17
jQuery run function after user finished typing
let typingTimer; //timer identifier
let doneTypingInterval = 1500; //time in ms, 5 second for example
let $input = $('.search-sidebar-ui-blocks');
//on keyup, start the countdown
$input.on('keyup', function () {
clearTimeout(typingTimer);
typingTimer = setTimeout(doneTyping, doneTypingInterval);
});
@maneja81
maneja81 / functions.php
Last active August 29, 2015 14:24
Remove author from WordPress Author Url
add_filter('author_rewrite_rules', 'no_author_base_rewrite_rules');
function no_author_base_rewrite_rules($author_rewrite) {
global $wpdb;
$author_rewrite = array();
$authors = $wpdb->get_results("SELECT user_nicename AS nicename from $wpdb->users");
foreach($authors as $author) {
$author_rewrite["({$author->nicename})/page/?([0-9]+)/?$"] = 'index.php?author_name=$matches[1]&paged=$matches[2]';
$author_rewrite["({$author->nicename})/?$"] = 'index.php?author_name=$matches[1]';
}
return $author_rewrite;
@maneja81
maneja81 / index.html
Created April 24, 2015 05:33
jQuery get css rules of DOM Element
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
#test{
background: #222;
color: #fff;
@maneja81
maneja81 / Passing-variables-between-iframe-and-parent-window.markdown
Created April 20, 2015 13:41
Passing variables between iframe and parent window
@maneja81
maneja81 / Vertical-Align-with-Pure-CSS.markdown
Created March 2, 2015 17:35
Vertical Align with Pure CSS
.directive('prettyp', function(){
return function(scope, element, attrs) {
$("[rel^='prettyPhoto']").prettyPhoto({deeplinking: false, social_tools: false});
}
})
@maneja81
maneja81 / angular-serialize-objects-and-array
Created November 20, 2014 21:15
Function to format angular objects and arrays to URI Component
function serialize(obj) {
var str = [];
for (var p in obj) {
if (angular.isArray(obj[p])) {
for (var i = 0; i < obj[p].length; i++) {
str.push(encodeURIComponent(p) + "[]=" + obj[p][i]);
};
}
if (obj.hasOwnProperty(p) && !angular.isArray(obj[p])) {
// str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));