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
public void Initialize(int newWidth, int newHeight) | |
{ | |
Random.InitState(seed + GameManager.Instance.currentLevel); | |
foreach (Transform child in transform) | |
{ | |
Destroy(child.gameObject); | |
} | |
width = newWidth; | |
height = newHeight; |
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
from keras.applications.resnet50 import ResNet50 | |
from keras.preprocessing import image | |
from keras.applications.resnet50 import preprocess_input, decode_predictions | |
import numpy as np | |
model = ResNet50(weights='imagenet') | |
def save_tags(filename): | |
img = image.load_img(filename, target_size=(224, 224)) | |
x = image.img_to_array(img) |
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 matplotlib.pyplot as plt | |
def dominant_colors(img): | |
img = cv2.resize(img, (64, 64)) | |
all_colors = img.reshape(-1, 3) | |
kmeans = KMeans(n_clusters=8).fit(all_colors) | |
palette = kmeans.cluster_centers_.astype(np.uint8) | |
# sort values from brightest to darkest | |
idx = np.argsort(palette.sum(axis=1))[::-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
Processing: lena.jpg | |
Processing: monarch.png | |
Processing: https://github.com/opencv/opencv/raw/master/samples/data/aero3.jpg | |
Processing: https://github.com/opencv/opencv/raw/master/samples/data/fruits.jpg | |
Processing: https://www.somewhere.in/no/mans/land.jpg | |
Skipping https://www.somewhere.in/no/mans/land.jpg because of <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)> |
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
for source in SOURCES: | |
print('Processing:', source) | |
try: | |
img = io.imread(source) | |
img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) | |
filename = os.path.basename(source) | |
cv2.imwrite('processed_' + filename, img) | |
img = cv2.resize(img, (64, 64)) | |
cv2.imwrite('thumbnail_' + filename, img) |
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
for source in SOURCES: | |
print('Processing:', source) | |
try: | |
img = io.imread(source) | |
img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) | |
filename = os.path.basename(source) | |
cv2.imwrite('processed_' + filename, img) | |
except Exception as e: | |
print('Skipping', source, 'because of', e) |
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
for source in SOURCES: | |
print('Processing:', source) | |
img = io.imread(source) | |
img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) | |
filename = os.path.basename(source) | |
cv2.imwrite('processed_' + filename, img) | |
# Output | |
# Processing: lena.jpg | |
# Processing: monarch.png |
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
package snippet; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class Snippet { | |
public static void main(String[] args) { | |
String[] examples = new String[] { "configGlossary:poweredByIcon -> CONFIG_GLOSSARY_POWERED_BY_ICON", "124$32SomeSampleString_thatI_have -> SOME_SAMPLE_STRING_THAT_I_HAVE", "myJSP -> MY_JSP" }; | |
for (String s : examples) { |
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
require 'rubygems' | |
require 'mongoid' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db("test") | |
end | |
class User | |
include Mongoid::Document | |
field :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
require 'rubygems' | |
require 'mongoid' | |
class Coach | |
include Mongoid::Document | |
field :name, :type => String | |
belongs_to :coached, :class_name => 'Team', :inverse_of => :coach, :foreign_key => "coach_id" | |
belongs_to :assisted, :class_name => 'Team', :inverse_of => :assist, :foreign_key => "assist_id" | |
end |