Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Macagare

  • Germany
View GitHub Profile
@Macagare
Macagare / Javascript: interval.js
Created Oct 31, 2012 — forked from manast/interval.js
Javascript: Accurate Javascript setInterval replacement
View Javascript: interval.js
function interval(duration, fn){
this.baseline = undefined
this.run = function(){
if(this.baseline === undefined){
this.baseline = new Date().getTime()
}
fn()
var end = new Date().getTime()
this.baseline += duration
@Macagare
Macagare / gist:3992769
Created Nov 1, 2012
XML: TOMAS Import example
View gist:3992769
<Images xmlns="">
<Image ObjectID="TDS00020010051505595">
<DescribingName>
<Value LanguageCode="fr">salle de bain 2</Value>
<Value LanguageCode="de">salle de bain 2</Value>
<Value LanguageCode="en">salle de bain 2</Value>
<Value LanguageCode="es">salle de bain 2</Value>
<Value LanguageCode="it">salle de bain 2</Value>
</DescribingName>
<MultimediaGroup LookupID="WBX00020010000126810">
@Macagare
Macagare / gist:3999297
Created Nov 2, 2012
Javascript: Close on Esc
View gist:3999297
function (e){
if(e.keyCode == 27){ $('.closeModalBox').click();
}
}
@Macagare
Macagare / gist:3999315
Created Nov 2, 2012
Drupal: check language
View gist:3999315
<?php if ($GLOBALS['language']->language == "fr-FR" ) { } ?>
@Macagare
Macagare / gist:3999331
Created Nov 2, 2012
Coldfusion: write text file
View gist:3999331
<cfset cacheFileName = "lorem.html" />
<cfset tmpFileDir = GetTempDirectory() />
<cfset fullCacheFileName = tmpFileDir & cacheFileName />
<cfset tmpFileContent = tmpFileContent & "<div width='100%' height='100%' id='dataBox'>">
<cfset tmpFileContent = tmpFileContent & "</div>">
<cftry>
<cffile action = "write" file = "#expandPath(".")#/filename.xml" output = "#filecontent#">
<cfcatch type="any">
@Macagare
Macagare / gist:3999337
Created Nov 2, 2012
Coldfusion: strip tags from string
View gist:3999337
<cfsavecontent variable="str">
<html>
<body>
This is the text you want
</body>
</html>
</cfsavecontent>
<cfset textstr = REReplace(str,'<[^>]*>','','all')>
@Macagare
Macagare / gist:3999339
Created Nov 2, 2012
RegEx: count stars in string
View gist:3999339
Hotel ****s
regex: "\*+"
Hotel [****]s
@Macagare
Macagare / gist:3999399
Created Nov 2, 2012
Javascript: Hiding radio buttons and styling labels with jQuery
View gist:3999399
<html>
<head>
<script type="text/javascript">
$(document).ready(function () {
$('input').click(function () {
$('input:not(:checked)').parent('label').removeClass("style1");
$('input:checked').parent('label').addClass("style1");
});
});​
</script>
@Macagare
Macagare / gist:3999324
Created Nov 2, 2012
Coldfusion: cfloop index from to
View gist:3999324
<cfloop index = "LoopCount" from = "1" to = "5">
The loop index is <cfoutput>#LoopCount#</cfoutput>.<br>
</cfloop>
@Macagare
Macagare / gist:3999353
Created Nov 2, 2012
CSS: change cursor
View gist:3999353
<head>
<style type="text/css"><!--
a:hover {cursor:move}
--></style>
</head>
You can’t perform that action at this time.