Skip to content

Instantly share code, notes, and snippets.

View dwelch2344's full-sized avatar

David Welch dwelch2344

View GitHub Profile
angular.module('admin.stats', [])
.config(function($stateProvider) {
$stateProvider
.state('admin-stats', {
url: '/admin/stats',
templateUrl: 'admin/admin.stats/admin.stats.tpl.html',
controller: 'AdminStatController'
});
})
@Slf4j
@ControllerAdvice
public class ControllerConfig {
@ExceptionHandler(Exception.class)
public ModelAndView handleException(Exception ex, HttpServletResponse response) {
log.warn("Unchaught Exception", ex);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
// TODO handle AJAX calls differently
@dwelch2344
dwelch2344 / test-plugin.php
Created November 22, 2013 17:32
A simple (ugly) test plugin admin screen for Wordpress
<?php
/*
Plugin Name: TestPlugin
*/
function test_plugin_menu(){
add_options_page('TestPlugin Settings', 'TestPlugin', 'manage_options', 'test-plugin-menu', 'test_plugin_options');
}
add_action('admin_menu','test_plugin_menu');
#!/bin/bash
_old=oldDB
_new=newDB
_user=user1234
_pass=pass1234
_oldDomain=staging.site.com
_newDomain=new.site.com
_db=db.site.com
mysqldump --databases "$_old" --user="$_user" --password="$_pass" --host "$_db" --add-drop-database > "$_file"
sed -e "s/$_old/$_new/g" "$_file" > "$_newFile"
<!DOCTYPE html>
<html lang="en" class="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="http://getbootstrap.com/docs-assets/ico/favicon.png">
@dwelch2344
dwelch2344 / pom.xml
Created November 4, 2013 22:27
Tomcat7 Embedded config for Maven pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!-- project settings -->
<properties>
<tomcat.version>7.0.42</tomcat.version>
</properties>
<?php
/**
*
* Safe Search and Replace on Database with Serialized Data v2.0.1
*
* This script is to solve the problem of doing database search and replace when
* developers have only gone and used the non-relational concept of serializing
* PHP arrays into single database columns. It will search for all matching
* data on the database and change it, even if it's within a serialized PHP
* array.
"""Be sure to use the latest selenium version
as there might be some problems with JSON serialization
Before running the test make sure you started appium server
with TestApp app: grunt appium:TestApp
"""
import unittest
import os
import sys
from random import randint
brew install rbenv ruby-build
echo 'eval "$(rbenv init -)"' >> $HOME/.bash_profile
source ~/.bash_profile
rbenv install 2.0.0-p0
rbenv local 2.0.0-p0
gem install cocoapods
@dwelch2344
dwelch2344 / Symmetric.java
Last active December 1, 2021 14:41
A simple example of decrypting a symmetrically encrypted file (via GPG)
import org.apache.commons.io.FileUtils;
import org.bouncycastle.bcpg.SymmetricKeyAlgorithmTags;
import org.bouncycastle.openpgp.*;
import org.bouncycastle.openpgp.examples.ByteArrayHandler;
import org.bouncycastle.openssl.PEMReader;
import org.bouncycastle.util.io.Streams;
import java.io.*;
import java.security.NoSuchProviderException;
import java.security.Security;