Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Macagare

  • Germany
View GitHub Profile
@Macagare
Macagare / select.html
Created Sep 24, 2013
country list html dropdown
View select.html
<select>
<option value=" " selected>(please select a country)</option>
<option value="--">none</option>
<option value="AF">Afghanistan</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AS">American Samoa</option>
<option value="AD">Andorra</option>
<option value="AO">Angola</option>
<option value="AI">Anguilla</option>
@Macagare
Macagare / gist:6404224
Created Sep 1, 2013
extract tag attributes regex
View gist:6404224
(?:[\w]*) *= *"(?:(?:(?:(?:(?:\\\W)*\\\W)*[^"]*)\\\W)*[^"]*")
@Macagare
Macagare / gist:6403856
Created Sep 1, 2013
create mysql connection and do query
View gist:6403856
package main
import (
"fmt"
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
func main() {
loadData()
@Macagare
Macagare / gist:6079196
Created Jul 25, 2013
create CF Date from UNIX timestamp
View gist:6079196
createObject('java','coldfusion.runtime.OleDateTime').init(javaCast('long',timestamp * 1000))
@Macagare
Macagare / snippet.cfm
Created Jul 11, 2013
Coldfusion: call query column
View snippet.cfm
<cfset var qQuery = getQuery( arguments.filter ) />
<cfif qQuery.recordCount >
<cfreturn qQuery[arguments.column][1] />
</cfif>
@Macagare
Macagare / gist:5414370
Created Apr 18, 2013
Batch: Google Closure terminal command
View gist:5414370
java -jar compiler.jar --js input.js --js_output_file output.js --compilation_level WHITESPACE_ONLY --formatting pretty_print
@Macagare
Macagare / gist:5237311
Created Mar 25, 2013
CF: string lastIndexOf
View gist:5237311
<cfset myTeaser = "Some cool stories and news articles from yest...">
<cfset myObj = CreateObject("java", "java.lang.String")/>
<cfset myStr = myObj.init(myTeaser) />
<cfset news = mid(myTeaser,1,myStr.lastIndexOf(' ')) />
View aws_public.cfc
<!---
Parts of this are based on Tim Dawe's
http://amazonsig.riaforge.org
and
Joe Danziger's Amazon S3 REST Wrapper
http://amazons3.riaforge.org/
Written by Patrick Liess
@Macagare
Macagare / download.js
Created Mar 16, 2013
JS: download file via node.js
View download.js
var http = require('http');
var url = require('url');
var fs = require('fs');
var XmlStream = require('xml-stream');
var config = require('./config.json'); // already parsed
var downloadFile = function( targetUrl ) {
var xmlItem = "";
var timestamp = parseInt( new Date().getTime() / 1000 );
var options = {
@Macagare
Macagare / server.js
Created Mar 16, 2013
JS: create simple node.js server
View server.js
var http = require('http');
http.createServer( function( req, res ) {
res.writeHead( 200, { 'Content-Type' : 'text/plain' } );
res.end( 'Hello World\n' );
} ).listen( 1337, '127.0.0.1' );
console.log( 'Server running at http://127.0.0.1:1337/' );
You can’t perform that action at this time.