Skip to content

Instantly share code, notes, and snippets.

Suresh Sapkota newsapkota

Block or report user

Report or block newsapkota

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View sublime-text-3-windows-shortcuts.md

Sublime Text 3 - Useful Shortcuts (Windows)

General

Shortcut Description
Ctrl+Shift+P command prompt
Ctrl+Alt+P switch project
Ctrl+P go to file
Ctrl+G go to line
@newsapkota
newsapkota / export_csv.php
Created May 2, 2018 — forked from janschoepke/export_csv.php
MySQL CSV Export via PHP (PHP7 ready)
View export_csv.php
<?php
/* vars for export */
// database record to be exported
$db_record = 'XXX_TABLE_NAME_XXX';
// optional where query
$where = 'WHERE 1 ORDER BY 1';
// filename for export
$csv_filename = 'db_export_'.$db_record.'_'.date('Y-m-d').'.csv';
// database variables
@newsapkota
newsapkota / inputtitle_submit.js
Created Mar 30, 2018 — forked from jackreichert/inputtitle_submit.js
Example showing how to use AJAX in WordPress
View inputtitle_submit.js
(function ($) {
$(document).ready(function () {
$('#next').click(function () {
$.post(
PT_Ajax.ajaxurl,
{
// wp ajax action
action: 'ajax-inputtitleSubmit',
// vars
@newsapkota
newsapkota / index.html
Last active Feb 27, 2018
Site Under Maintenance HTML Simple Template
View index.html
<!doctype html>
<html>
<head>
<title>Site Under Maintenance</title>
</head>
<body>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
View bootstrap-4-classes-list.txt
/* Bootstrap 4 - https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css */
.active
.alert
.alert-danger
.alert-dark
.alert-dismissible
.alert-heading
.alert-info
.alert-light
View auto-add.php
/*
Plugin Name: Auto Add Read Posts
Description: A plugin that adds read posts to the user's read list - requires the Unread Posts plugin
Version: 1.0.0
Author: Daniel Pataki
Author URI: http://danielpataki.com/
License: GPLv2 or later
*/
add_action( 'wp', 'auto_add_post_to_read_list' );
View abstraction-1.php
<div class='post' id='post-23'>
<h2><?php the_title() ?></h2>
<div class='excerpt'>
<?php
$content = get_the_content();
if( strlen($content) < 250 ) {
echo $content;
}
else {
$content = substr( $content, 0, 250 );
View cached-posts.php
public function get_remote_posts() {
$posts = get_transient( 'remote_posts' );
if( empty( $posts ) ) {
$response = wp_remote_get( 'http://mysite.com/wp-json/wp/v2/posts/' );
if( is_wp_error( $response ) ) {
return array();
}
$posts = json_decode( wp_remote_retrieve_body( $response ) );
@newsapkota
newsapkota / laravellocal.md
Created Dec 6, 2017 — forked from hootlex/laravellocal.md
Run laravel project locally
View laravellocal.md

##Windows users:

cmder will be refered as console

##Mac Os, Ubuntu and windows users continue here:

  • Create a database locally named homestead utf8_general_ci
@newsapkota
newsapkota / media-query.css
Created Sep 27, 2017 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
View media-query.css
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
You can’t perform that action at this time.