Skip to content

Instantly share code, notes, and snippets.

@akirasosa
akirasosa / gist:6374297
Created August 29, 2013 04:31
add encrypted_data_bag_secret to starter kit
openssl rand -base64 512 > .chef/encrypted_data_bag_secret
echo 'encrypted_data_bag_secret "#{current_dir}/encrypted_data_bag_secret"' >> .chef/knife.rb
# knife bootstrap myhost -x user -N node-name -r 'role[somerole]' --sudo
@akirasosa
akirasosa / gist:6505112
Created September 10, 2013 04:50
force poltergeist to use 'Accept-Language' as "en"
# spec/spec_helper.rb
RSpec.configure do |config|
config.before(:each) do
if Capybara.current_driver == :poltergeist
page.driver.headers = { 'Accept-Language' => "en" }
end
end
end
@akirasosa
akirasosa / github.json
Last active December 22, 2015 21:19
I provision jenkins slaves by using chef. Jenkins slaves have to access to the github.com, heroku.com and so on via ssh. They have to know know_hosts.
echo "cookbook 'ssh_known_hosts', github: 'opscode-cookbooks/ssh_known_hosts'" >> Berksfile
berks install
berks upload
knife data bag create ssh_known_hosts
knife data bag from file ssh_known_hosts data_bags/ssh_known_hosts/github.json
knife data bag from file ssh_known_hosts data_bags/ssh_known_hosts/heroku.json
knife role from file roles/jenkins-slave.rb
@akirasosa
akirasosa / Gemfile
Created September 12, 2013 10:18
speed up rspec tests using elasticsearch by bypass useless connections to the elasticsearch server
# Gemfile
group :test do
gem "webmock"
end
@akirasosa
akirasosa / gist:6547654
Created September 13, 2013 07:26
I have a tons of rspec test cases. Here is an easy way to distribute them between Jenkins slaves.
# LABEL was passed from an upstream job. It will be in 0, 1 or 2.
find ./spec -name "*_spec.rb" | awk "NR % 3 == ${LABEL} {print}" | xargs rspec
@akirasosa
akirasosa / gist:6697643
Last active April 18, 2019 10:28
Volley. Use cache if there is no internet connection.
public class MyStringRequest extends StringRequest{
public MyStringRequest(int method, String url, Response.Listener<String> listener, Response.ErrorListener errorListener) {
super(method, url, listener, errorListener);
}
@Override
public void deliverError(VolleyError error) {
if (error instanceof NoConnectionError) {
Cache.Entry entry = this.getCacheEntry();
if(entry != null) {
@akirasosa
akirasosa / gist:6709058
Created September 26, 2013 02:29
It is required before build by gradle on Jenkins.
echo y | ${ANDROID_HOME}/tools/android update sdk -u -a -t platform-tools,build-tools-18.0.1
{
"email": "test@gmail.com",
"email_verified": true,
"family_name": "Sosa",
"gender": "male",
"given_name": "Akira",
"hd": "gmail.com",
"locale": "en",
"name": "Akira Sosa",
"picture": "https://lh3.googleusercontent.com/path/to/photo.jpg",
@akirasosa
akirasosa / keras_prime_number.py
Last active January 3, 2023 16:37
Chalenging to find prime numbers by Keras...
import numpy as np
from keras.layers import Dense, Dropout, Activation
from keras.layers.advanced_activations import PReLU
from keras.models import Sequential
from matplotlib import pyplot as plt
seed = 7
np.random.seed(seed)
num_digits = 14 # binary encode numbers
@akirasosa
akirasosa / bench.py
Created November 8, 2017 06:52
Benchmark conv block and depthwise conv block.
import time
import numpy as np
from keras import Input
from keras.applications.mobilenet import DepthwiseConv2D
from keras.engine import Model
from keras.layers import Conv2D
batch_num = 16