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
module MethodDetector | |
def option_stack | |
@option_stack ||= [] | |
end | |
def method_added(method_name) | |
unless option_stack.empty? | |
option = option_stack.pop | |
puts "You added the option '#{option}' to the method: #{method_name}" | |
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
class BotController < Stealth::Controller | |
before_action :set_outbound_phone | |
private def set_outbound_phone | |
if current_message.service == "twilio" | |
Stealth.config.twilio.from_phone = current_message.target_id | |
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
import tensorflow as tf | |
import os | |
import zipfile | |
DESIRED_ACCURACY = 0.999 | |
!wget --no-check-certificate \ | |
"https://storage.googleapis.com/laurencemoroney-blog.appspot.com/happy-or-sad.zip" \ | |
-O "/tmp/happy-or-sad.zip" |
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
import tensorflow as tf | |
print(tf.__version__) | |
mnist = tf.keras.datasets.mnist | |
(training_images, training_labels), (test_images, test_labels) = mnist.load_data() | |
training_images=training_images.reshape(60000, 28, 28, 1) | |
training_images=training_images / 255.0 | |
test_images = test_images.reshape(10000, 28, 28, 1) | |
test_images=test_images/255.0 | |
model = tf.keras.models.Sequential([ | |
tf.keras.layers.Conv2D(32, (3,3), activation='relu', input_shape=(28, 28, 1)), |
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
import tensorflow as tf | |
print(tf.__version__) | |
class myCallback(tf.keras.callbacks.Callback): | |
def on_epoch_end(self, epoch, logs={}): | |
if(logs.get('loss')<0.4): | |
print("\nReached 60% accuracy so cancelling training!") | |
self.model.stop_training = True | |
callbacks = myCallback() |
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
# URL Matching | |
# Taken from Android: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.1.1_r1/android/util/Patterns.java#145 | |
GOOD_IRI_CHAR = /a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF/ | |
GOOD_GTLD_CHAR = /a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF/ | |
GTLD = /[#{GOOD_GTLD_CHAR}]{2,63}/ | |
IRI = /[#{GOOD_IRI_CHAR}]([#{GOOD_IRI_CHAR}\-]{0,61}[#{GOOD_IRI_CHAR}]){0,1}/ | |
HOST_NAME = /(#{IRI}\.)+#{GTLD}/ | |
IP_ADDRESS = /((25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[0-9]))/ | |
DOMAIN_NAME = /(#{HOST_NAME}|#{IP_ADDRESS})/ | |
WEB_URL_REGEX = /((?:(http|https|Http|Https|rtsp|Rtsp):\/\/(?:(?:[a-zA-Z0-9\$\-\_\.\+\!\*\'\(\)\,\;\?\&\=]|(?:\%[a-fA-F0-9]{2})){1,64}(?:\:(?:[a-zA-Z0-9\$\-\_\.\+\!\*\'\(\)\,\;\?\&\=]|(?:\%[a-fA-F0-9]{2})){1,25})?\@)?)?(?:#{DOMAIN_NAME})(?:\:\d{1,5})?)(\/(?:(?:[#{GOOD_IRI_CHAR}\;\/\?\:\@\&\=\#\~\-\.\+\ |
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
<a href='http://youtube.com'> | |
<img src='http://mauriciogomes.com/share/kx_video.png'> | |
</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
desc "Heroku Cron Task" | |
task :cron => :environment do | |
Rake::Task["accounts:bill"].invoke | |
Rake::Task["accounts:expire"].invoke | |
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
desc "Heroku Cron Task" | |
task :cron => :environment do | |
begin | |
Rake::Task["accounts:bill"].invoke | |
rescue | |
HoptoadNotifier.notify($!) | |
end | |
begin | |
Rake::Task["accounts:expire"].invoke |
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 Array | |
def ^(ary) | |
return (ary | self) - (ary & self) | |
end | |
end |
NewerOlder