Skip to content

Instantly share code, notes, and snippets.

View matthewpoer's full-sized avatar

Matthew Poer matthewpoer

View GitHub Profile
@justincase
justincase / gist:5469009
Created April 26, 2013 17:45
Print struct with field names and values. From http://blog.golang.org/2011/09/laws-of-reflection.html
type T struct {
A int
B string
}
t := T{23, "skidoo"}
s := reflect.ValueOf(&t).Elem()
typeOfT := s.Type()
for i := 0; i < s.NumField(); i++ {
@eggsurplus
eggsurplus / setFieldRequired
Created August 22, 2012 17:51
Make a field required/not required in edit view of SugarCRM
function setFieldRequired(fieldName, req, msgStr){
if(!msgStr){ msgStr = fieldName; }
for(var i = 0; i < validate["EditView"].length; i++){
if(validate["EditView"][i][nameIndex] == fieldName) {
validate["EditView"][i][msgIndex] = msgStr;
validate["EditView"][i][requiredIndex] = req;
break;
}
}
}
@maxrice
maxrice / us-state-names-abbrevs.php
Created May 23, 2012 18:32
US State Names & Abbreviations as PHP Arrays
<?php
/* From https://www.usps.com/send/official-abbreviations.htm */
$us_state_abbrevs_names = array(
'AL'=>'ALABAMA',
'AK'=>'ALASKA',
'AS'=>'AMERICAN SAMOA',
'AZ'=>'ARIZONA',
'AR'=>'ARKANSAS',