Skip to content

Instantly share code, notes, and snippets.

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

cbmeeks cbmeeks

🏠
Working from home
View GitHub Profile
@cbmeeks
cbmeeks / bootstrap_form_builder.rb
Created December 28, 2011 03:59
Twitter Bootstrap Form Builder
class BootstrapFormBuilder < ActionView::Helpers::FormBuilder
delegate :capture, :content_tag, :tag, to: :@template
%w[text_field text_area password_field collection_select].each do |method_name|
define_method(method_name) do |name, *args|
errors = object.errors[name].any?? " error" : ""
error_msg = object.errors[name].any?? content_tag(:span, object.errors[name].join(","), class: "help-inline") : ""
content_tag :div, class: "clearfix#{errors}" do
@cbmeeks
cbmeeks / process_list.sql
Created August 9, 2012 12:36
MySQL Process List
SELECT
ID
, USER
, HOST
, DB
, COMMAND
, TIME
, time/60.0 Seconds
, (time/60.0) / 60.0 Hours
, STATE
@cbmeeks
cbmeeks / Jsonator.java
Created October 15, 2012 15:53
Jsonator
package com.mysite.model.entities;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@cbmeeks
cbmeeks / add_user.sql
Created October 16, 2012 14:28
User Table for Spring Security
/* Once the users table is created, you can add users with the SQL below. NOTE, we are using SHA1 in this example and cAsE matters */
/* New User:
Username: moehoward
Password: nyucknyuck
NOTICE: Inside the 'sha1', the string is: password{username}
In Spring, we told it to use a salt source of 'username'. But you HAVE to put it in the curly brackets. So, try not to have curly brackets in your password. :-)
*/
@cbmeeks
cbmeeks / Random.java
Created October 18, 2012 20:10
Random String in Java
/* ************************************************************************
* Class: Random.java
* Purpose: Helper class for generating random strings (for new passwords)
* Author: Cecil Meeks
* Modification History:
* 2011 - Cecil Meeks - Creation
// ************************************************************************ */
package com.example.common;
import java.math.BigInteger;
@cbmeeks
cbmeeks / PortalUserService.java
Created October 19, 2012 13:59
Portal User Interface
// not real code...but you get the idea
public interface PortalUserService {
public PortalUser get(int id);
public PortalUser updatePassword(PortalUser paUser, String paNewPassword);
}
public class PortalUser {
String username;
String password;
@cbmeeks
cbmeeks / Cleanup-Folders.ps1
Created December 14, 2012 16:28
Cleanup Folders
function Cleanup-Folders($path) {
if($path) {
Get-ChildItem -recurse | Where {$_.PSIsContainer -and @(Get-ChildItem -Lit $_.Fullname -r | Where {!$_.PSIsContainer}).Length -eq 0} | Remove-Item -recurse -whatif
}
}
Cleanup-Folders "c:\temp\blah"
var cacheBuster = function() {
return Date.now().toString() + Math.random().toString(36).substring(2,7);
}
<html>
<body style="margin:0;">
<div id="d" style="background:#ff0;left:200px;position:relative;">
Hello
</div>
</body>
</html>
declare @data table ( dateid date, timeid time(0), value decimal(19,5) );
declare @DB2_DATE table ( dateid date );
declare @DB2_TIME table ( timeid time(0) );
/* Build DB2 dim tables */
insert into @DB2_DATE values ('2013-03-01')
insert into @DB2_DATE values ('2013-03-02')
insert into @DB2_DATE values ('2013-03-03')
insert into @DB2_DATE values ('2013-03-04')
insert into @DB2_DATE values ('2013-03-05')