Skip to content

Instantly share code, notes, and snippets.

View vincentkoc's full-sized avatar
:octocat:

Vincent Koc vincentkoc

:octocat:
View GitHub Profile
<?php
// Don't disable on dev
if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) {
// Disable core update checking
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
remove_action( 'admin_init', '_maybe_update_core' );
remove_action( 'wp_version_check', 'wp_version_check' );
@vincentkoc
vincentkoc / export.php
Last active January 14, 2019 23:14
PHP Rules for CSV exports for UTF-8 and old browsers. Dynamic Exporting with rules to support each type of format which is extendable to call a parser on inputs.
<?php
//Do Download Headers if we have nothing else to show
if($uri_page[$no] == 'export'){
//Universal
ini_set('zlib.output_compression','Off');
if($uri_page[$no+1] == 'csv'){
//CSV
header('Content-Encoding: UTF-8');
header('Content-type: text/csv; charset=UTF-8');
@vincentkoc
vincentkoc / ga.organic.js
Created June 23, 2014 15:50
ga.js Google Analytics - Organic Sources snippet
//Taken from http://www.google-analytics.com/ga.js
//And de-compressed
var Ld = "daum:q eniro:search_word naver:query pchome:q images.google:q google:q yahoo:p yahoo:q msn:q bing:q aol:query aol:q lycos:q lycos:query ask:q cnn:query virgilio:qs baidu:wd baidu:word alice:qs yandex:text najdi:q seznam:q rakuten:qt biglobe:q goo.ne:MT search.smt.docomo:MT onet:qt onet:q kvasir:q terra:query rambler:query conduit:q babylon:q search-results:q avg:q comcast:q incredimail:q startsiden:q go.mail.ru:q centrum.cz:q 360.cn:q sogou:query tut.by:query globo:q ukr:q so.com:q auone:q".split(" "),
Sd = function (a) {
if (a.get(kb) && !a.get(Mc)) {
var b;
b = !F(a.get(ic)) || !F(a.get(nc)) || !F(a.get(S)) || !F(a.get(lc));
for (var c = {}, d = 0; d < Md[w]; d++) {
var e = Md[d];
c[e] = a.get(e)
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@vincentkoc
vincentkoc / Affiliate Cookie
Last active January 14, 2019 23:13
Dead simple affiliate query string to 30 day cookie in Apache HTACCESS Config
@vincentkoc
vincentkoc / Update_Wordpress_Hostname.sql
Last active January 14, 2019 23:10
Wordpress Site Migration SQL Command - Commands to Find and Replace Meta, Site Options and Site Content for Hostnames
UPDATE wp_options SET option_value = replace(option_value, 'http://thismagicday.com.192.168.1.15.xip.io', 'http://thismagicday.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://thismagicday.com.192.168.1.15.xip.io','http://www.thismagicday.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://thismagicday.com.192.168.1.15.xip.io', 'http://thismagicday.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://thismagicday.com.192.168.1.15.xip.io','http://thismagicday.com');
@vincentkoc
vincentkoc / Wordpress_WPCONFIG_Custom.php
Last active January 14, 2019 23:09
Disable XML-RPC Pingbacks on Wordpress for Wp-Config
<?php
// Disable pingback.ping xmlrpc method to prevent Wordpress from participating in DDoS attacks
// More info at: https://docs.bitnami.com/?page=apps&name=wordpress&section=how-to-re-enable-the-xml-rpc-pingback-feature
// remove x-pingback HTTP header
add_filter('wp_headers', function($headers) {
unset($headers['X-Pingback']);
return $headers;
});
// disable pingbacks
@vincentkoc
vincentkoc / gpg_mac.md
Last active June 7, 2022 10:59
Keybase GPG and Git Setup on Mac OS

Setup Tools

brew install gpg
brew install pinentry-mac
brew install --cask gpg-suite
brew install --cask keybase

Export Keys

Keybase proof

I hereby claim:

  • I am koconder on github.
  • I am zuperduper (https://keybase.io/zuperduper) on keybase.
  • I have a public key ASBS0nvfhG7bTHtCVfLmGXDw1WPAMVHe9_LSS0q_eF5RKQo

To claim this, I am signing this object:

@vincentkoc
vincentkoc / hash.py
Created June 18, 2023 11:14
SHA256 a CSV file using Pandas
import pandas as pd
import hashlib
# Load the csv file into a pandas DataFrame
df = pd.read_csv('filename.csv')
# Define a function to hash a string
def hash_for_google(input):
if pd.isnull(input):
return None