Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Nicholas http://organanddrums.net

« Newer Snippets
Older Snippets »
15 total  XML / RSS feed 

Fix for ExpressionEngine File Extension in PHP4

Find the following line (around 5388):

switch ($row['field_type'])


before that place this line:

$field_type = "";


So that switch should look like this:

$field_type = "";
switch ($row['field_type'])
{
    case 'text' :  $field_type = $LANG->line('text_input');
        break;
    case 'textarea' :  $field_type = $LANG->line('textarea');
        break;
    case 'select' :  $field_type = $LANG->line('select_list');
        break;
    case 'date' :  $field_type = $LANG->line('date_field');
        break;
    case 'rel' :  $field_type = $LANG->line('relationship');
        break;
} 


http://expressionengine.com/forums/viewthread/38843/#181791

Country dropdown HTML

<select>
<option value="AF">Afghanistanoption>
/option>
<option value="AL">Albaniaoption>
/option>
<option value="AS">American Samoaoption>
/option>
<option value="AO">Angolaoption>
/option>
<option value="AQ">Antarcticaoption>
/option>
<option value="AR">Argentinaoption>
/option>
<option value="AW">Arubaoption>
/option>
<option value="AT">Austriaoption>
/option>
<option value="BS">Bahamasoption>
/option>
<option value="BD">Bangladeshoption>
/option>
<option value="BY">Belarusoption>
/option>
<option value="BZ">Belizeoption>
/option>
<option value="BM">Bermudaoption>
/option>
<option value="BO">Boliviaoption>
/option>
<option value="BW">Botswanaoption>
/option>
<option value="BR">Braziloption>
/option>
<option value="BN">Brunei Darussalamoption>
/option>
<option value="BF">Burkina Fasooption>
/option>
<option value="KH">Cambodiaoption>
/option>
<option value="CA">Canadaoption>
/option>
<option value="KY">Cayman Islandsoption>
/option>
<option value="TD">Chadoption>
/option>
<option value="CN">Chinaoption>
/option>
<option value="CC">Cocos (Keeling) Islandsoption>
/option>
<option value="KM">Comorosoption>
/option>
<option value="CD">Congo, The Democratic Republic Of Theoption>
/option>
<option value="CR">Costa Ricaoption>
/option>
<option value="HR">Croatiaoption>
/option>
<option value="CY">Cyprusoption>
/option>
<option value="DK">Denmarkoption>
/option>
<option value="DM">Dominicaoption>
/option>
<option value="EC">Ecuadoroption>
/option>
<option value="SV">El Salvadoroption>
/option>
<option value="ER">Eritreaoption>
/option>
<option value="ET">Ethiopiaoption>
/option>
<option value="FO">Faroe Islandsoption>
/option>
<option value="FI">Finlandoption>
/option>
<option value="GF">French Guianaoption>
/option>
<option value="TF">French Southern Territoriesoption>
/option>
<option value="GM">Gambiaoption>
/option>
<option value="DE">Germanyoption>
/option>
<option value="GI">Gibraltaroption>
/option>
<option value="GL">Greenlandoption>
/option>
<option value="GP">Guadeloupeoption>
/option>
<option value="GT">Guatemalaoption>
/option>
<option value="GN">Guineaoption>
/option>
<option value="GY">Guyanaoption>
/option>
<option value="HM">Heard Island And Mcdonald Islandsoption>
/option>
<option value="HN">Hondurasoption>
/option>
<option value="HU">Hungaryoption>
/option>
<option value="IN">Indiaoption>
/option>
<option value="IR">Iran, Islamic Republic Ofoption>
/option>
<option value="IE">Irelandoption>
/option>
<option value="IL">Israeloption>
/option>
<option value="JM">Jamaicaoption>
/option>
<option value="JE">Jerseyoption>
/option>
<option value="KZ">Kazakhstanoption>
/option>
<option value="KI">Kiribatioption>
/option>
<option value="KR">Korea, Republic Ofoption>
/option>
<option value="KG">Kyrgyzstanoption>
/option>
<option value="LV">Latviaoption>
/option>
<option value="LS">Lesothooption>
/option>
<option value="LY">Libyan Arab Jamahiriyaoption>
/option>
<option value="LT">Lithuaniaoption>
/option>
<option value="MO">Macaooption>
/option>
<option value="MG">Madagascaroption>
/option>
<option value="MY">Malaysiaoption>
/option>
<option value="ML">Malioption>
/option>
<option value="MH">Marshall Islandsoption>
/option>
<option value="MR">Mauritaniaoption>
/option>
<option value="YT">Mayotteoption>
/option>
<option value="FM">Micronesia, Federated States Ofoption>
/option>
<option value="MC">Monacooption>
/option>
<option value="MS">Montserratoption>
/option>
<option value="MZ">Mozambiqueoption>
/option>
<option value="NA">Namibiaoption>
/option>
<option value="NP">Nepaloption>
/option>
<option value="AN">Netherlands Antillesoption>
/option>
<option value="NZ">New Zealandoption>
/option>
<option value="NE">Nigeroption>
/option>
<option value="NU">Niueoption>
/option>
<option value="MP">Northern Mariana Islandsoption>
/option>
<option value="OM">Omanoption>
/option>
<option value="PW">Palauoption>
/option>
<option value="PA">Panamaoption>
/option>
<option value="PY">Paraguayoption>
/option>
<option value="PH">Philippinesoption>
/option>
<option value="PL">Polandoption>
/option>
<option value="PR">Puerto Ricooption>
/option>
<option value="RE">Reunionoption>
/option>
<option value="RU">Russian Federationoption>
/option>
<option value="SH">Saint Helenaoption>
/option>
<option value="LC">Saint Luciaoption>
/option>
<option value="VC">Saint Vincent And The Grenadinesoption>
/option>
<option value="SM">San Marinooption>
/option>
<option value="SA">Saudi Arabiaoption>
/option>
<option value="CS">Serbia And Montenegrooption>
/option>
<option value="SL">Sierra Leoneoption>
/option>
<option value="SK">Slovakiaoption>
/option>
<option value="SB">Solomon Islandsoption>
/option>
<option value="ZA">South Africaoption>
/option>
<option value="ES">Spainoption>
/option>
<option value="SD">Sudanoption>
/option>
<option value="SJ">Svalbard And Jan Mayenoption>
/option>
<option value="SE">Swedenoption>
/option>
<option value="SY">Syrian Arab Republicoption>
/option>
<option value="TJ">Tajikistanoption>
/option>
<option value="TH">Thailandoption>
/option>
<option value="TG">Togooption>
/option>
<option value="TO">Tongaoption>
/option>
<option value="TN">Tunisiaoption>
/option>
<option value="TM">Turkmenistanoption>
/option>
<option value="TV">Tuvaluoption>
/option>
<option value="UA">Ukraineoption>
/option>
<option value="GB">United Kingdomoption>
/option>
<option value="UM">United States Minor Outlying Islandsoption>
/option>
<option value="UZ">Uzbekistanoption>
/option>
<option value="VE">Venezuelaoption>
/option>
<option value="VG">Virgin Islands, Britishoption>
/option>
<option value="WF">Wallis And Futunaoption>
/option>
<option value="YE">Yemenoption>
/option>
<option value="ZW">Zimbabweoption>
</select>

50 states dropdown HTML

<select name="state">
<option value="">Pick your stateoption>
/option>
<option value="AK">Alaskaoption>
/option>
<option value="AR">Arkansasoption>
/option>
<option value="CO">Coloradooption>
/option>
<option value="DE">Delawareoption>
/option>
<option value="FL">Floridaoption>
/option>
<option value="HI">Hawaiioption>
/option>
<option value="IL">Illinoisoption>
/option>
<option value="IA">Iowaoption>
/option>
<option value="KY">Kentuckyoption>
/option>
<option value="ME">Maineoption>
/option>
<option value="MA">Massachusettsoption>
/option>
<option value="MN">Minnesotaoption>
/option>
<option value="MO">Missourioption>
/option>
<option value="NE">Nebraskaoption>
/option>
<option value="NH">New Hampshireoption>
/option>
<option value="NM">New Mexicooption>
/option>
<option value="NC">North Carolinaoption>
/option>
<option value="OH">Ohiooption>
/option>
<option value="OR">Oregonoption>
/option>
<option value="RI">Rhode Islandoption>
/option>
<option value="SD">South Dakotaoption>
/option>
<option value="TX">Texasoption>
/option>
<option value="VT">Vermontoption>
/option>
<option value="WA">Washingtonoption>
/option>
<option value="WI">Wisconsinoption>
/option>
select>

Generate DSA Keys

// generates SSH DSA keys in ~/.ssh/

ssh-keygen -d

rsync syntax

rsync -avz --eahfs --progress --delete /source-dir-without-trailing-slash /destination-dir-with-trailing-slash


// explanation of switches
// -a, archive mode, equivalent to -rlptgoD which does things like recurse through all the dirs, preserves times, etc.
// -v, verbose mode
// -z, compress - makes the copy go faster. doesn't actually compress into a zip file
// --eahfs - (could also use -E, I think)
// --progress - show copy status of each item
// --delete, delete files on destination that aren't on source (sync)

Xinha config settings

xinha_config.toolbar =
  [
    ["popupeditor"],
    ["separator","formatblock","fontname","fontsize","bold","italic","underline","strikethrough"],
    ["separator","forecolor","hilitecolor","textindicator"],
    ["separator","subscript","superscript"],
    ["linebreak","separator","justifyleft","justifycenter","justifyright","justifyfull"],
    ["separator","insertorderedlist","insertunorderedlist","outdent","indent"],
    ["separator","inserthorizontalrule","createlink","insertimage","inserttable"],
    ["separator","undo","redo","selectall","print"], (HTMLArea.is_gecko ? [] : ["cut","copy","paste","overwrite","saveas"]),
    ["separator","killword","clearfonts","removeformat","toggleborders","splitblock","lefttoright", "righttoleft"],
    ["separator","htmlmode","showhelp","about"]
  ];


   xinha_config.fontname = {
    "— font —":         '',
    "Arial":       'arial,helvetica,sans-serif',
    "Courier New":       'courier new,courier,monospace',
    "Georgia":       'georgia,times new roman,times,serif',
    "Tahoma":       'tahoma,arial,helvetica,sans-serif',
    "Times New Roman": 'times new roman,times,serif',
    "Verdana":       'verdana,arial,helvetica,sans-serif',
    "impact":       'impact',
    "WingDings":       'wingdings'
  };

   xinha_config.fontsize = {
    "— size —"  : "",
    "1 (8 pt)" : "1",
    "2 (10 pt)": "2",
    "3 (12 pt)": "3",
    "4 (14 pt)": "4",
    "5 (18 pt)": "5",
    "6 (24 pt)": "6",
    "7 (36 pt)": "7"
  };

   xinha_config.formatblock = {
    "— format —"  : "",
    "Heading 1": "h1",
    "Heading 2": "h2",
    "Heading 3": "h3",
    "Heading 4": "h4",
    "Heading 5": "h5",
    "Heading 6": "h6",
    "Normal"   : "p",
    "Address"  : "address",
    "Formatted": "pre"
  };

Dynamic page titles in Expression Engine

// Puts the weblog name and entry title in the title tag in Expression Engine

<title>{exp:weblog:info weblog="name-of-weblog-here"}
    {blog_title}
{/exp:weblog:info} | {exp:weblog:entries}
    {title} 
{/exp:weblog:entries}title>

tar syntax

// tar:
tar -cvzf file.tar.gz inputfile1 inputfile2


// untar:
tar -xvzf file.tar.gz

Reset mysql password to old style

SET PASSWORD FOR user@localhost = OLD_PASSWORD('password');

Load external file into div

// javascript to go into head of document or external .js file

function ahah(url, target) {
  document.getElementById(target).innerHTML = ' Fetching data...';
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {ahahDone(url, target);};
    req.open("GET", url, true);
    req.send("");
  }
}  

function ahahDone(url, target) {
  if (req.readyState == 4) { // only if req is "loaded"
    if (req.status == 200) { // only if "OK"
      document.getElementById(target).innerHTML = req.responseText;
    } else {
      document.getElementById(target).innerHTML=" AHAH Error:\n"+ req.status + "\n" +req.statusText;
    }
  }
}

function load(name, div) {
        ahah(name,div);
        return false;
}


// call code with the name of the external file and the id of the div you want to put the content into

<a href="file1.html" onclick="load('file1.html','content');return false;">File 1a>

Open Firefox in Safe Mode

// opens Firefox with extensions disabled. Also gives you the ability/option to reset Firefox to defaults.

// More info and code for other platforms can be found at http://kb.mozillazine.org/Safe_mode

/Applications/Firefox.app/Contents/MacOS/firefox -safe-mode

Change root password in OS X Server

In Terminal:

passwd root

Change admin password in OS X Server

Bad things can happen if you change the administrator password on OS X server the wrong way. The right way is to change it via Workgroup Manager (NOT System Preferences) or via this command in Terminal:

passwd admin

Flush DNS cache

In Terminal, type:

lookupd -flushcache

Change Default Screen Capture Format in OS X

Enter the following into Terminal:

defaults write com.apple.screencapture type *format*


In place of *format* in the above put any of the following, depending on your preference:

jpg
pdf
tif
png - this is the default

(There may be others. Feel free to add these to the comments.)
« Newer Snippets
Older Snippets »
15 total  XML / RSS feed