Skip to content

Instantly share code, notes, and snippets.

@gmarokov
gmarokov / .bash_profile
Created February 4, 2019 15:14 — forked from ethyde/.bash_profile
Bash profile load ssh-agent and add all key in ~/.ssh/id_rsa*
# SSH Agent
# Note: ~/.ssh/environment should not be used, as it
# already has a different purpose in SSH.
# source : https://www.schoonology.com/technology/ssh-agent-windows/
env=~/.ssh/agent.env
# Note: Don't bother checking SSH_AGENT_PID. It's not used
# by SSH itself, and it might even be incorrect
# (for example, when using agent-forwarding over SSH).
# Matching only Wordpress.com calls. RPC disable due security issue.
<FilesMatch "xmlrpc\.php$">
Satisfy Any
Allow from all
</FilesMatch>
Along with a Plugin here: Disable XML-RPC Pingback.
@gmarokov
gmarokov / update-wp-old-hostname.sql
Last active October 22, 2019 06:57
Update old hostname WP query
UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://olddomain.com','http://newdomain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://olddomain.com', 'http://newdomain.com');
@gmarokov
gmarokov / url-snippets.php
Last active October 22, 2019 06:57
PHP snippets for URLs
//Get host name from URL
preg_match('@^(?:https?://)?([^/]+)@i',
"http://www.php.net/index.html", $matches);
$host = $matches[1];
//Get last two segments of host name
preg_match('/[^.]+\.[^.]+$/', $host, $matches);
echo "domain name is: {$matches[0]}\n";
//Check for valid domain
using System;
namespace TaxCalculator
{
class TaxCalculator
{
static void Main(string[] args)
{
int salary;
@gmarokov
gmarokov / github-api-repo-search.php
Last active October 22, 2019 06:53
Search repos on GitHub by given search string
<?php
$searchTerm = 'mail';
$language = 'php';
$reposPerPage = 100;
$repoUrls = array();
$page = 1;
// Start paging
@gmarokov
gmarokov / git-aliases
Last active October 22, 2019 06:51
Git alias for displaying migration files for ASP.NET projets
git config --global alias.migrations 'log -- **/Migrations/**/*.cs'
@gmarokov
gmarokov / git-hook-post-merge
Last active October 22, 2019 06:51
ASP.NET post merge git hook for displaying available migrations
#!/usr/bin/env bash
changed_files="$(git diff ORIG_HEAD HEAD --name-only | grep "/Migrations/")" [[ ! -z $changed_files ]] && echo -e "\e[91mIncoming Migrations!\e[39m $changed_files"
@gmarokov
gmarokov / .vimrc
Created January 8, 2019 11:49
Vim configuraton
set numbers
@gmarokov
gmarokov / jquery-sticky-sidebar.js
Last active October 22, 2019 06:50
JQuery sticky sidebar
var stickySidebar = $('.sticky');
if (stickySidebar.length > 0) {
var stickyHeight = stickySidebar.height(),
sidebarTop = stickySidebar.offset().top;
}
// on scroll move the sidebar
$(window).scroll(function () {
if (stickySidebar.length > 0) {