Skip to content

Instantly share code, notes, and snippets.

3dd13 3dd13

Block or report user

Report or block 3dd13

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
3dd13 / controllers.js
Created Jun 15, 2015
Testing ngCordova geolocation watchPosition and getCurrentPosition function
View controllers.js
.controller('DashCtrl', function($scope, $ionicPlatform, $cordovaGeolocation) {
var watch;
var watchOptions = {
timeout : 5000,
maximumAge: 3000,
enableHighAccuracy: true // may cause errors if true
var pollCurrentLocation = function() {
3dd13 / application.html.ejs
Created Apr 3, 2014
Working with i18n in geddy.this example shows how to see chinese translated text in http://localhost:4000/?locale=zh-tw
View application.html.ejs
<!-- app/views/layouts/application.html.ejs -->
<!-- generate a link with to switch locale -->
<li><%- linkTo(i18n.getText("nav.links.switch_to_english"), {locale: "en-us"}) %></li>
<li><%- linkTo(i18n.getText("nav.links.switch_to_chinese"), {locale: "zh-tw"}) %></li>
3dd13 / read_gmail_messages_by_label.rb
Created Feb 6, 2014
snippet to read your gmail emails by label
View read_gmail_messages_by_label.rb
require 'gmail'
require 'dotenv'
label_name = "" # label name here["GMAIL_USERNAME"], ENV["GMAIL_PASSWORD"]) do |gmail|
mail_with_label = gmail.label(label_name)
3dd13 / Gulpfile.js
Last active Mar 12, 2016 — forked from webdesserts/Gulpfile.js
Adapt the gulp hot reload file and apply to partial.js directory structure. (ignored public folder at the moment)
View Gulpfile.js
// NOTE: I previously suggested doing this through Grunt, but had plenty of problems with
// my set up. Grunt did some weird things with scope, and I ended up using nodemon. This
// setup is now using Gulp. It works exactly how I expect it to and is WAY more concise.
var gulp = require('gulp'),
spawn = require('child_process').spawn,
* $ gulp server
* description: launch the server. If there's a server already running, kill it.
3dd13 / guest_user.rb
Last active Dec 29, 2015
some helper methods for handling guest user in Rails (with devise) ecommerce website
View guest_user.rb
# User Stories:
# To start shopping easily,
# guest user wants to add items to shopping cart without signing up
# Code Explanation:
# - a guest_user is created when new user arrives to your website, so that he could have his own shopping cart, and adding items to shopping cart.
# - when the guest_user sign up, all items in the shopping cart should be transferred to the new signed up user account
3dd13 / ormat_apn_token.rb
Created Dec 19, 2012
Convert the apn token collected from iOS to the format apn_on_rails is expecting
View ormat_apn_token.rb
# the apn push token you collected from mobile is in this format:
# 00ea74e76a873e8e9c14c2dd2afe3b42abb35148e94042811e2b6985072641f2
# but actually, apn_on_rails is expecting this:
# 00ea74e7 6a873e8e 9c14c2dd 2afe3b42 abb35148 e9404281 1e2b6985 072641f2
def format_apn_token(text)
text && text.gsub(/(.{8})(?=.)/, '\1 \2')
3dd13 / Gemfile
Created Nov 27, 2012
Runing single ruby file on heroku
View Gemfile
source ''
3dd13 / ruby_ftp_example.rb
Created Nov 5, 2011
Sample code of using Ruby Net::FTP library. Login to FTP server, list out files, check directory existence, upload files
View ruby_ftp_example.rb
require 'net/ftp'
CONTENT_SERVER_FTP_LOGIN = "saucy-ftp-server-login"
CONTENT_SERVER_FTP_PASSWORD = "saucy-ftp-server-password"
# LOGIN and LIST available files at default home directory, CONTENT_SERVER_FTP_LOGIN, CONTENT_SERVER_FTP_PASSWORD) do |ftp|
files = ftp.list
3dd13 / updateClearboxTop.js
Created Sep 20, 2011
Javascript to update the "top" css style after every scroll event, to solve the mobile browser position:fixed; issue. The function is called only if the client browser (by checking user-agent) is one of the mobile browsers.
View updateClearboxTop.js
var deviceIphone = "iphone";
var deviceIpod = "ipod";
var deviceIpad = "ipad";
var deviceAndroid = "android";
//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();
function detectUserAgent(deviceName)
3dd13 / apple_green_address.rb
Created Sep 18, 2011
Scraping the address of "Apple Green" from
View apple_green_address.rb
# loading the mechanize library for scraping
# install it if you haven't done it:
# sudo gem install mechanize
require 'mechanize'
agent =
page = agent.get("")
You can’t perform that action at this time.