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
(1..100).each do |num| | |
result = 'Tit' if num % 3 == 0 | |
if num % 5 == 0 | |
result &&= result + 'ForTat' | |
result ||= 'Tat' | |
end | |
result ||= num | |
puts result | |
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
TreeniApp.directive('chosen', function() { | |
var linker = function(scope, element, attr) { | |
// update the select when data is loaded | |
scope.$watch(attr.chosen, function(oldVal, newVal) { | |
element.trigger('chosen:updated'); | |
}); | |
// update the select when the model changes | |
scope.$watch(attr.ngModel, function() { | |
element.trigger('chosen:updated'); |
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
factory.CSVtoArray = function (text) { | |
var re_valid = /^\s*(?:'[^'\\]*(?:\\[\S\s][^'\\]*)*'|"[^"\\]*(?:\\[\S\s][^"\\]*)*"|[^,'"\s\\]*(?:\s+[^,'"\s\\]+)*)\s*(?:,\s*(?:'[^'\\]*(?:\\[\S\s][^'\\]*)*'|"[^"\\]*(?:\\[\S\s][^"\\]*)*"|[^,'"\s\\]*(?:\s+[^,'"\s\\]+)*)\s*)*$/; | |
var re_value = /(?!\s*$)\s*(?:'([^'\\]*(?:\\[\S\s][^'\\]*)*)'|"([^"\\]*(?:\\[\S\s][^"\\]*)*)"|([^,'"\s\\]*(?:\s+[^,'"\s\\]+)*))\s*(?:,|$)/g; | |
// Return NULL if input string is not well formed CSV string. | |
if (!re_valid.test(text)) return null; | |
var a = []; // Initialize array to receive values. | |
text.replace(re_value, // "Walk" the string using replace with callback. | |
function(m0, m1, m2, m3) { | |
// Remove backslash from \' in single quoted values. | |
if (m1 !== undefined) a.push(m1.replace(/\\'/g, "'")); |
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
unit_types = [ | |
{ name: 'length' }, | |
{ name: 'area' }, | |
{ name: 'weight' }, | |
{ name: 'volume' } | |
].each do |tag_info| | |
puts "Added #{UnitType.create(tag_info).inspect}" | |
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
<div class="control labelMove bottomSpace4"> | |
<select | |
id="org_node" | |
name="orgNode" | |
class="chosen-select" | |
chosen="treeDropOptions" | |
required | |
ng-model="indicator.org_node_id"> | |
<option ng-repeat="opt in treeDropOptions" ng-value="opt.id"> | |
{{Array(opt.lvl * 7).join(" ")}} {{opt.name}} |
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
class YourDynamicModelSerializer < ActiveModel::Serializer | |
attributes :_id, :name | |
def _id | |
object._id.to_s | |
end | |
def attributes | |
fields = object.attributes |
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
# place code in config/initializers/bson.rb | |
module BSON | |
class ObjectId | |
def as_json(*args) | |
to_s | |
end | |
end | |
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
# Patch for mongoid to return $oid instead of active record id | |
class << self | |
def serialize_from_session(key, _salt) | |
to_adapter.get(key[0]) | |
end | |
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
development: | |
# Configure available database sessions. (required) | |
sessions: | |
# Defines the default session. (required) | |
default: | |
# Defines the name of the default database that Mongoid can connect to. | |
# (required). | |
database: treeni_development | |
# Provides the hosts the default session can connect to. Must be an array | |
# of host:port pairs. (required) |
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
{ | |
'source' => { | |
'type' => 'csv', | |
'file' => { | |
'path' => '/home/webonise/Projects/Data-Integration/dump/test.csv' | |
}, | |
'options' => { | |
'col_sep' => ',' | |
} | |
}, |
OlderNewer