This file contains hidden or 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 'brazilian_cardinal_number' | |
class BrazilianCardinalCurrency | |
class << self | |
def cardinal(value) | |
return 'grátis' if value.zero? | |
abs_value = value.abs | |
cents = abs_value.to_s.split('.')[1].to_s[0, 2].to_i | |
integer = abs_value.to_i |
This file contains hidden or 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
var jsdom = require("jsdom"); | |
var _ = require("lodash"); | |
var WebCrawler = {}; | |
var Storage = {}; | |
!function (crawler) { | |
var getFreeDownloadableTracks = function(page, finishCallback) { | |
jsdom.env({ | |
url: "http://www.last.fm/music/+free-music-downloads?page=" + page, |
This file contains hidden or 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() { | |
var myURL = function(str) { | |
this.str = str; | |
this.toString = function() { return str; }; | |
} | |
function createFromString(urlString) { | |
return new myURL(urlString); | |
} |
This file contains hidden or 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
diff --git a/wordpress/wp-content/plugins/woocommerce/includes/class-wc-cart.php b/wordpress/wp-content/plugins/woocommerce/includes/class-wc-cart.php | |
index 5563396..681a859 100644 | |
--- a/wordpress/wp-content/plugins/woocommerce/includes/class-wc-cart.php | |
+++ b/wordpress/wp-content/plugins/woocommerce/includes/class-wc-cart.php | |
@@ -105,6 +105,7 @@ class WC_Cart { | |
* Constructor for the cart class. Loads options and hooks in the init method. | |
*/ | |
public function __construct() { | |
+ add_action( 'wp_head', array( $this, 'force_shipping_to_be_set_on_checkout' ) ); | |
add_action( 'wp_loaded', array( $this, 'init' ) ); // Get cart after WP and plugins are loaded. |
This file contains hidden or 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
find . -iname "*.php" > /tmp/my_php_files.txt | |
# new template | |
xgettext --from-code=utf-8 -d my_dir -f /tmp/my_php_files.txt -o languages/my_theme.pot | |
# update template | |
xgettext --from-code=utf-8 -d my_dir -j -f /tmp/my_php_files.txt -o languages/my_theme.pot | |
# To update the already translated .po files and add new strings to them, run: |
This file contains hidden or 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
class Data < ActiveRecord::Base | |
belongs_to :user | |
before_create :user_allowed_to_create? | |
private | |
def user_allowed_to_create? | |
offset = Date.today.cweek % User.count | |
User.offset(offset).limit(1).pluck(:id).first == user_id | |
end |
This file contains hidden or 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() { | |
'use strict'; | |
_.mixin({ | |
// Similar to `_.dig` but uses `window` as the starting point object. | |
import: function(namespace, initialValue) { | |
return _.dig(window, namespace, true, initialValue); | |
}, | |
// Fetch or create the nested objects referenced in @namespace@ (String or Array) |
This file contains hidden or 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
def run_with_timeout(cmd, limit) | |
Open3.popen3(cmd) do |_, stdout, stderr, wait_thr| | |
output, pid = [], wait_thr.pid | |
begin | |
Timeout.timeout(limit) do | |
output = [stdout.read, stderr.read] | |
Process.wait(pid) | |
end | |
rescue Errno::ECHILD | |
rescue Timeout::Error |
This file contains hidden or 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
#!/usr/bin/env ruby_executable_hooks | |
# | |
# This file was generated by RubyGems. | |
# | |
# The application 'compass' is installed as part of a gem, and | |
# this file is here to facilitate running it. | |
# | |
require 'rubygems' |
This file contains hidden or 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
Rails.application.routes.draw do | |
resources :fruits do | |
mount TestEngine::Engine => '/test', as: :test_1 | |
end | |
resources :vegetables do | |
mount TestEngine::Engine => '/test', as: :test_2 | |
end | |
end |