Skip to content

Instantly share code, notes, and snippets.

View Molnfront's full-sized avatar
💭
I may be slow to respond.

Göran Svensson Molnfront

💭
I may be slow to respond.
View GitHub Profile
@Molnfront
Molnfront / config.js
Last active October 14, 2015 00:23
Automatically add MongoDB settings from VCAP_SERVICES for PencilBlue running on BlueMix
/**
* This is a sample configuration meant to get users and up running on a local
* machine. The configuration will not support multi-process on a single
* server or multi-server/elastic environments. For more detailed information
* on the options provided please refer to the /include/config.js file.
*
* The file can be renamed to "config.js" in the same directory as this file
* and it will be used as the configuration when PencilBlue is started. If
* this file is used then there is no need to create a "config.json"
*/
@Molnfront
Molnfront / pathnamereplace.js
Last active July 30, 2018 12:17
URL pathname replace for conditional redirects to support multi-language sites
/* pathnamereplace.js v0.1.2, URL pathname replace for conditional redirects to support multi-language sites, now with cookies and passtrue list.
* Author & copyright (c) 2014: Göran Svensson, goran@molnsys.com. MIT license.
* Tested with Chrome 36, Firefox 29 and Safari 7.0.5 on OSX.
* Tested with Chrome 36 on Xperia V (Android 4.3) and Internet 2.3.6 on Samsung GT-S5360 (Android 2.3.6).
* Works with any number of path name items and language acronymes. Does not break the back button.
* How to use it; add this in your nav menu: javascript:changeLanguage('_se') to switch to swedish version.
* REQUIRES: CatalystScripts/Java_Cookies.js and country = '{module_visitorcountrycode}'; added
* above this script (does not work inside a js file).
* No bugs have been harmed.
* To avoid unnecesary reload, build a nav menu for each language with the right path.
@Molnfront
Molnfront / auth.cfm
Created January 4, 2014 00:37
auth for twilio
<!--- Get an instance of the capability object... --->
<cfset cap = REQUEST.TwilioLib.getCapability() />
<cfset cap.allowClientOutgoing("APf0a7xxxxxxxxxxxxxxx") />
<cfset token = cap.generateToken() />
<cfoutput>#token#</cfoutput>
@Molnfront
Molnfront / web.xml
Created December 25, 2013 14:50
web.xml file for Railo 4.1.2 with activated tuckey urlrewrite filter. Don't forget to dl latest jar file and put it in Railo lib folder.
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
metadata-complete="true"
version="2.5">
<!-- ********************************************************************* -->
@Molnfront
Molnfront / urlrewrite.xml
Created December 25, 2013 14:46
URL rewrite rules for framework one and Xindi. Works with Railo 4.1.2 and Tomcat 6. Remark the redirect/location first in admin/Application.cfc.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
"http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<urlrewrite>
<rule enabled="true" match-type="regex">
<name>Admin URLs Pass-through</name>
<condition type="request-uri" operator="equal">^/(index.cfm/|admin/main|admin/security)</condition>
<from>^/index.cfm/admin/</from>
<to type="passthrough">/index.cfm/admin:main</to>
@Molnfront
Molnfront / maintain.cfm
Created December 25, 2013 14:37
Date picker view
<input class="input-xlarge" type="date" name="published" id="published" value="#DateFormat( rc.Article.getPublished(),'yyyy-mm-dd')#" title="The date the article is to be published" placeholder="Date">
@Molnfront
Molnfront / postMessage.cfm
Last active December 15, 2015 03:39
This gist will POST to StackMob and create a new schema if it does not exist and post two messages. Based on an implementation of Harry Klein´s (http://oauth.riaforge.org/) oAuth for ColdFusion. It uses oAuth 1.0 for signing requests. Tested on Railo Server 4.0.2, with PostgreSQL on OSX 10.7.5. For this to work you do not need a database. If you…
<cfprocessingdirective pageencoding="utf-8" />
<!--- cfcontent is also important for unicode --->
<cfcontent type="text/html charset=utf-8">
<!--- set up the parameters --->
<cfset sConsumerKey = 'yourPublickey'> <!--- Paste your dev or prod keys here --->
<cfset sConsumerSecret = 'youPrivatekey'> <!--- Paste your dev or prod keys here --->
<cfset OAUTH_VERIFIER = '' /> <!--- You get back these when doing oauth registration --->
<cfset token = '' /> <!--- You get back these when doing oauth registrationt --->
<cfset tokenSecret = '' /> <!--- You get back these when doing oauth registration --->
@Molnfront
Molnfront / getMarket.cfm
Last active December 15, 2015 03:19
A StackMob test implementation of Harry Klein´s (http://oauth.riaforge.org/) oAuth for ColdFusion. It uses oAuth 1.0 to read a list of markets. Tested on Railo Server 4.0.2, with PostgreSQL on OSX 10.7.5. For this to work you do not need a database. If you do you have to add tables manually in pqAdmin, the db script does not work in Railo.
<cfprocessingdirective pageencoding="utf-8" />
<!--- cfcontent is also important for unicode --->
<cfcontent type="text/html charset=utf-8">
<!--- set up the parameters --->
<cfset sConsumerKey = 'yourPublickey'> <!--- Paste your dev or prod keys here --->
<cfset sConsumerSecret = 'youPrivatekey'> <!--- Paste your dev or prod keys here --->
<cfset OAUTH_VERIFIER = '' /> <!--- You get back these when doing oauth registration --->
<cfset token = '' /> <!--- You get back these when doing oauth registrationt --->
<cfset tokenSecret = '' /> <!--- You get back these when doing oauth registration --->
@Molnfront
Molnfront / urlrewrite.xml
Created January 23, 2013 18:06
Works with tuckey urlrewrite filter 4.0.3 and Mura!
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
"http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<!--
Configuration file for UrlRewriteFilter
http://www.tuckey.org/urlrewrite/
-->
@Molnfront
Molnfront / web.xml
Created January 23, 2013 18:02
web.xml for Railo 4 with urlrewrite filter.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Railo</display-name>
<servlet>
<servlet-name>CFMLServlet</servlet-name>
<description>CFML runtime Engine</description>
<servlet-class>railo.loader.servlet.CFMLServlet</servlet-class>