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
macro swap { | |
rule { $x and $y } => { | |
var tmp = $x; | |
$x = $y; | |
$y = tmp | |
} | |
} | |
// Let's go! | |
var a = "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
function isNull( str ){ | |
return str === null ? true : false; | |
} |
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 tmpl(text, o){ | |
return text.replace(/({(.+)})/gm, function( exp, conj, innerExp ){ | |
return eval(innerExp); | |
}); | |
} |
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
Security.defineMethod("ifHasUserId", { | |
fetch: [], | |
transform: null, | |
deny: function (type, args, userId, document) { | |
return userId !== arg; | |
} | |
}); |
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
ArgumentsSchema = function(args, schema, extra){ | |
var orderedArgs = {}; | |
for(var arg in args){ | |
for(var field in schema){ | |
if(schema.hasOwnProperty(field)){ | |
if(args[arg].constructor === schema[field]){ | |
orderedArgs[field] = args[arg]; | |
} | |
} |
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
SessionHandler = { | |
_deps: new Tracker.Dependency, | |
get(target, name){ | |
this._deps.depend(); | |
return target[name]; | |
}, | |
set(target, name, value){ | |
target[name] = value; | |
this._deps.changed(); |
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
// @locus: server | |
if(Meteor.isServer){ | |
Tracker.autorun(() => { | |
CollectionObserved.find(); | |
collectAndSaveData(); | |
}); | |
function collectAndSaveData(){ | |
var aggregateData = CollectionObserved.aggregate(...); | |
var aggregateDocId = ...; |
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
#!/usr/bin/ruby | |
require 'find' | |
if ARGV[0] | |
puts "Wait..." | |
Find.find( ARGV[0] ) do |f| | |
totalLength += IO.readlines(f).size if File.file? f | |
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
#!/usr/bin/ruby | |
# Troca vogais e coloca um hifen no lugar das mesmas | |
# passe como argumento o arquivo de texto i.e. -> | |
# matavogais.rb /home/masterboss/vogais.txt | |
File.open("#{File.dirname(ARGV[0])}/noVogals.txt",'w') do |f| | |
f << File.read( ARGV[0] ).gsub(/[aeiou]/i, '-') | |
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
#!/usr/bin/ruby | |
# Example: wordor /anything/ ruby | |
# Found: anythingruby.pdf and rubynotify.rb, after put they in ruby/ folder | |
require 'find' | |
require 'fileutils' | |
if !ARGV.empty? | |
path = "#{ARGV[0]}/#{ARGV[1]}" | |
reg = /#{ARGV[1]}/ | |
Dir.mkdir( path,0755 ) unless File.exists? path |
OlderNewer