Skip to content

Instantly share code, notes, and snippets.

View michmzr's full-sized avatar

Mike michmzr

View GitHub Profile
@michmzr
michmzr / js
Created January 25, 2018 11:36
Jquery plugin template
/*!
* jQuery lightweight plugin boilerplate
* Original author: @ajpiano
* Further changes, comments: @addyosmani
* Licensed under the MIT license
*/
// the semi-colon before the function invocation is a safety
// net against concatenated scripts and/or other plugins
@michmzr
michmzr / wordpress_table_column_exists.php
Created February 23, 2018 11:50 — forked from EricBusch/wordpress_table_column_exists.php
A function for WordPress to check if a column exists in a database table or not. Returns true if a database table column exists. Otherwise returns false.
<?php
/**
* Returns true if a database table column exists. Otherwise returns false.
*
* @link http://stackoverflow.com/a/5943905/2489248
* @global wpdb $wpdb
*
* @param string $table_name Name of table we will check for column existence.
* @param string $column_name Name of column we are checking for.
@michmzr
michmzr / gulpfile.js
Created May 9, 2018 07:12 — forked from michalochman/gulpfile.js
gulp.js: babelify + browserify + sourcemaps
/* jshint strict: false */
/* globals require, console */
var gulp = require('gulp');
var exit = require('gulp-exit');
var browserify = require('browserify');
var watchify = require('watchify');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
@michmzr
michmzr / openvpn_scripts.sh
Last active August 20, 2018 15:02
openvpn_scripts.sh
#!/bin/bash
#
# https://github.com/Nyr/openvpn-install
#
# Copyright (c) 2013 Nyr. Released under the MIT License.
# Detect Debian users running the script with "sh" instead of bash
if readlink /proc/$$/exe | grep -q "dash"; then
echo "This script needs to be run with bash, not sh"
@michmzr
michmzr / drop_all_tables.sql
Last active August 26, 2018 17:22
Drop all tables from database
SET FOREIGN_KEY_CHECKS = 0;
SET GROUP_CONCAT_MAX_LEN=32768;
SET @tables = NULL;
SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables
FROM information_schema.tables
WHERE table_schema = (SELECT DATABASE());
SELECT IFNULL(@tables,'dummy') INTO @tables;
SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables);
PREPARE stmt FROM @tables;
@michmzr
michmzr / MetricsMethodUtilsService.groovy
Last active October 5, 2018 09:12
Manual call alternative for grails.plugin.dropwizard.metrics.timers.@timed for Grails 3
import com.codahale.metrics.MetricRegistry
import com.codahale.metrics.Timer
import groovy.transform.stc.ClosureParams
import groovy.transform.stc.FirstParam
import groovy.util.logging.Log4j
@Log4j
class MetricsMethodUtilsService {
MetricRegistry metricRegistry
@michmzr
michmzr / remove_apps.ps1
Created October 18, 2018 13:33
Powershell - remove not wanted preinstalled windows app
$Applist = Get-AppXProvisionedPackage -online
$Applist | WHere-Object {$_.packagename -like “*3DBuilder*”} | Remove-AppxProvisionedPackage -online
#$Applist | WHere-Object {$_.packagename -like “*Appconnector*”} | Remove-AppxProvisionedPackage -online
$Applist | WHere-Object {$_.packagename -like “*BingFinance*”} | Remove-AppxProvisionedPackage -online
$Applist | WHere-Object {$_.packagename -like “*BingNews*”} | Remove-AppxProvisionedPackage -online
$Applist | WHere-Object {$_.packagename -like “*BingSports*”} | Remove-AppxProvisionedPackage -online
$Applist | WHere-Object {$_.packagename -like “*BingWeather*”} | Remove-AppxProvisionedPackage -online
$Applist | WHere-Object {$_.packagename -like “*CommsPhone*”} | Remove-AppxProvisionedPackage -online
#$Applist | WHere-Object {$_.packagename -like “*ConnectivityStore*”} | Remove-AppxProvisionedPackage -online
@michmzr
michmzr / pearson.ipynb
Last active October 28, 2018 17:56
Data Correlactions
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@michmzr
michmzr / build.gradle
Created January 16, 2019 10:33
Gradle configuration for testing console logging
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
tasks.withType(Test) {
testLogging {
// set options for log level LIFECYCLE
events TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT
@michmzr
michmzr / grailsDomainClassTableName.groovy
Created February 5, 2019 13:30
Get Domain object table name by hibernate
def sessionFactory = Holders.applicationContext.getBean('sessionFactory')
ClassMetadata hibernateMetaClass = sessionFactory.getClassMetadata(User)
def mappedTable = hibernateMetaClass.getTableName()
print("User domain class is mapped to database table '$mappedTable')