Skip to content

Instantly share code, notes, and snippets.

View prajwal-stha's full-sized avatar

Prajwal Shrestha prajwal-stha

View GitHub Profile
@prajwal-stha
prajwal-stha / README.md
Created August 10, 2018 11:43 — forked from sixertoy/README.md
ES6 Tips & Tricks

JavaScript Tips

Array

  • Fill N
  • Flatten
  • Remove duplicates
  • Convert an NodeList to Array

Object

@prajwal-stha
prajwal-stha / README.md
Created June 29, 2018 01:21 — forked from jxson/README.md
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation

@prajwal-stha
prajwal-stha / media-query.css
Created February 5, 2018 11:05 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@prajwal-stha
prajwal-stha / hex2rgb.js
Created October 8, 2017 11:08 — forked from polotek/hex2rgb.js
Convert hex colors to rgba
/**
* hex2rgb - function for converting hex colors to rgb(a)
*
* Shout out to http://hex2rgba.devoth.com/
*
* @hex (String) - The hex value. Can be prefixed with "#" or not. Can be
* long format (6 chars) or short format (3 chars)
* @opacity (number between 0 and 1) - This is an optional float value that
* will be used for the opacity
*
@prajwal-stha
prajwal-stha / Mark parent navigation active when on custom post type single page Mark (highlight) custom post type parent as active item in Wordpress Navigation. When you visit a custom post type's single page, the parent menu item (the post type archive) isn't marked as active. This code solves it by comparing the slug of the current post type with the navigation items, and adds a class accordingly.
<?php
add_action('nav_menu_css_class', 'add_current_nav_class', 10, 2 );
function add_current_nav_class($classes, $item) {
// Getting the current post details
global $post;
// Getting the post type of the current post
@prajwal-stha
prajwal-stha / README.md
Created November 3, 2016 07:34 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@prajwal-stha
prajwal-stha / mamp.md
Created October 17, 2016 14:21 — forked from jfloff/mamp.md
How to get MAMP to work with SSL ... Yes really.

First of all you need to be able to run MAMP in port 80. This is a "heat check" if you don't have any process jamming http ports. You can check it like this:

sudo lsof | grep LISTEN

If you do happen to have any process with something like this *:http (LISTEN), you are in trouble. Before with adventure check if it isn't MAMP itself (yeah, you should close that beforehand)

ps <pid of that process>

If you don't see MAMP, you are in good hands, I have just the thing for you:

@prajwal-stha
prajwal-stha / README.md
Created October 17, 2016 14:00 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@prajwal-stha
prajwal-stha / migrate.sh
Created October 17, 2016 01:31 — forked from tobi-pb/migrate.sh
Upgrade MAMP to Mysql 5.6
#!/bin/sh
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.24-osx10.9-x86_64.tar.gz
tar xfvz mysql-5.6*
echo "stopping mamp"
sudo /Applications/MAMP/bin/stop.sh
sudo killall httpd mysqld
echo "creating backup"
//Add Open Graph Meta Info from the actual article data, or customize as necessary
function facebook_open_graph() {
global $post;
if ( !is_singular()) //if it is not a post or a page
return;
if($excerpt = $post->post_excerpt)
{
$excerpt = strip_tags($post->post_excerpt);
$excerpt = str_replace("", "'", $excerpt);
}