This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function telLinkTag($str = '') { | |
$delimeter = ', '; | |
$tels = explode($delimeter, $str); | |
$res = array(); | |
foreach($tels as $tel) { | |
$invalidChar = array('(', ')', ' ', '-'); | |
array_push($res, '<a href="' . | |
'tel:+' . str_replace($invalidChar, '', $tel) . | |
'">' . | |
$tel . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function subsiteLink($subdomain = false) { | |
$ret = ''; | |
$hostAry = explode('.', SITE_HOST); | |
if (sizeof($hostAry) == 3 && in_array($subdomain, array('vl', 'lr'))) { | |
if ($subdomain) { | |
// return a link of the requested subdomain | |
$ret = implode('.', array($subdomain, $hostAry[1], $hostAry[2])); | |
} else { | |
// return a link of the main domain | |
$ret = implode('.', array($hostAry[1], $hostAry[2])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem install pg -v '0.17.1' -- --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'date' | |
def next_n_work_days n | |
today = Date.today | |
number_of_weekends_days = ((n / 5) *2) | |
(1..(number_of_weekends_days + n) - 1).reduce([today]) do |days, plus_num_days| | |
day = today + plus_num_days | |
# or | |
# day = days.last.next |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = {:name => "test" , :description => "test"}.to_json | |
allow(File).to receive(:read).and_return(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*globals React, Turbolinks*/ | |
/* Modified react_ujs to prevent the components polluting global scope whenever possible. | |
* Since I use subdirs for my components, it also flattens the structure making | |
* _componentStore[className] possible. | |
* Creds for the react_ujs.js file to the people from react-rails (https://github.com/reactjs/react-rails) | |
*/ | |
var path = require('path'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat db/seeds/countries.json | ruby -rubygems -e 'require "json";a=JSON.pretty_generate JSON.parse gets;File.open("db/seeds/countries.json", "w"){|f| f << a}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
country_list = [ | |
[ "Germany", 81831000 ], | |
[ "France", 65447374 ], | |
[ "Belgium", 10839905 ], | |
[ "Netherlands", 16680000 ] | |
] | |
country_list.each do |name, population| | |
Country.create( name: name, population: population ) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(function (position) { | |
var latitude = position.coords.latitude; | |
var longitude = position.coords.longitude; | |
//code for displaying results | |
//document.getElementById('show-lat-lon').innerHTML='<p>' + latitude + ' ' + longitude + '</p>'; | |
}); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(function (position) { | |
var latitude = position.coords.latitude; | |
var longitude = position.coords.longitude; | |
var coord = new google.maps.LatLng(latitude,longitude); | |
geocoder = new google.maps.Geocoder(); | |
geocoder.geocode({'latLng': coord}, function(results, status) { | |
for (var i = 0; i < results[4].address_components.length; i++) { |
OlderNewer