Skip to content

Instantly share code, notes, and snippets.

View harishkotra's full-sized avatar
🏠
Working from home

Harish Kotra harishkotra

🏠
Working from home
View GitHub Profile
@harishkotra
harishkotra / gist:89a5f00f830ac3aefe1103ab8b8884e1
Created March 19, 2017 04:35
Ionic 1 directive to disable special characters in an input field
.directive('noSpecialChar', function() {
return {
require: 'ngModel',
restrict: 'A',
link: function(scope, element, attrs, modelCtrl) {
modelCtrl.$parsers.push(function(inputValue) {
if (inputValue == null)
return ''
cleanInputValue = inputValue.replace(/[^\w\s]/gi, '');
if (cleanInputValue != inputValue) {
@harishkotra
harishkotra / search-in-action-bar.js
Created March 19, 2017 04:39
Ionic 1: Directive to add search bar in the Nav/Action bar of the app
.directive('searchBar', [function () {
return {
scope: {
ngModel: '='
},
require: ['^ionNavBar', '?ngModel'],
restrict: 'E',
replace: true,
template: '<ion-nav-buttons side="right">'+
'<div class="searchBar item-input-inset">'+
@harishkotra
harishkotra / wordpress_change_db_urls.sql
Created April 2, 2017 02:09
Change and Update WordPress URLS in Database When Site is Moved to new Host. After migrating a WordPress site to a new URL either to a live production site or a testing development server, the new URL strings in the mysql database need to be changed and updated in the various mysql database tables.
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
@harishkotra
harishkotra / wordpress-title-custom-theme.php
Created April 3, 2017 01:39
Generate Perfect WordPress Title Tags without a Plugin.
<title><?php if (function_exists('is_tag') && is_tag()) { echo 'Tag Archive for &quot;'.$tag.'&quot; - '; } elseif (is_archive()) { wp_title(''); echo ' Archive - '; } elseif (is_search()) { echo 'Search for &quot;'.wp_specialchars($s).'&quot; - '; } elseif (!(is_404()) && (is_single()) || (is_page())) { wp_title(''); echo ' - '; } elseif (is_404()) { echo 'Not Found - '; } if (is_home()) { bloginfo('name'); echo ' - '; bloginfo('description'); } else { bloginfo('name'); } ?></title>
@harishkotra
harishkotra / v-show.html
Created April 11, 2017 02:44
Vue.js - v-show directive example to hide an element if no input is received in a text field.
<html>
<head>
<!-- just any other regular html tag -->
<title>Vue Demo App with v-show directive</title>
<!-- Fetch vue.js from the following library -->
<!-- Other alternatives are to download the original library from https://vuejs.org/ -->
<script src="https://unpkg.com/vue"></script>
<style>
#app {
font-family: 'Montserrat', Helvetica, Arial, sans-serif;
@harishkotra
harishkotra / v-if-else.html
Created April 11, 2017 02:52
Vue.js - Using v-if and v-else to display a different message to the user based on what is typed in the input field.
<html>
<head>
<!-- just any other regular html tag -->
<title>Vue Demo App with v-if & v-else directives</title>
<!-- Fetch vue.js from the following library -->
<!-- Other alternatives are to download the original library from https://vuejs.org/ -->
<script src="https://unpkg.com/vue"></script>
<style>
#app {
font-family: 'Montserrat', Helvetica, Arial, sans-serif;
@harishkotra
harishkotra / stock-data.txt
Created April 29, 2017 09:20
Pull stock market data
Links to help get stock market data:
http://finance.google.com/finance/info?client=ig&q=NASDAQ%3AGOOG
Using Google API:http://digitalpbk.com/stock/google-finance-get-stock-quote-realtime
External Website: https://www.quandl.com/
@harishkotra
harishkotra / .htaccess
Created October 9, 2017 10:47
.htaccess hacks for speeding up WordPress
#Enable Keep-Alive
#Keep alive is a method to allow the same tcp connection for HTTP conversation instead of opening a new one with each new request.
#More simply put, it is a communication between the web server and the web browser that says "you can grab more than just one file at a time".
#Keep alive is also known as a persistant connection
<IfModule mod_headers.c>
Header set Connection keep-alive
</IfModule>
#Enable gzip
@harishkotra
harishkotra / decryptor.php
Last active April 16, 2018 13:10
Decrypt CodeIgniter Password
<?php
$encrypted_password = 'ENCRYPTED_PASSWORD_HERE';
$key = 'KEY_FROM_CONFIG_FILE_HERE';
$decrypted_string = $this->encrypt->decode($encrypted_password, $key);
echo $decrypted_string;
?>
@harishkotra
harishkotra / npm-updater.txt
Created May 6, 2018 07:36
Steps to update npm on Windows
**This is the new best way to upgrade npm on Windows.**
**Run PowerShell as Administrator**
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install -g npm-windows-upgrade
npm-windows-upgrade