Skip to content

Instantly share code, notes, and snippets.

View NetguruGist's full-sized avatar

Netguru NetguruGist

View GitHub Profile
@NetguruGist
NetguruGist / watchOS1.swift
Created October 31, 2015 14:50
watchOS1 swift
func presentAlertControllerWithTitle(_ title: String?,
message message: String?,
preferredStyle preferredStyle: WKAlertControllerStyle,
actions actions: [WKAlertAction])
@NetguruGist
NetguruGist / apache1.md
Last active December 22, 2015 09:07
apache1 markdown

This is ApacheBench, Version 2.3 <$Revision: 1604373 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking netguru.co (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests

@NetguruGist
NetguruGist / runloopexample1.ruby
Created October 31, 2015 14:50
runloopexample1 ruby
this.$().click(function() {
Ember.run(function () {
Ember.debug('In my own runloop');
$('body').css('background-color', 'pink');
Ember.run(function () {
Ember.debug('In a nested runloop');
$('body').css('background-color', 'red');
});
});
Ember.run(function () {
@NetguruGist
NetguruGist / runloopexample2.ruby
Created October 31, 2015 14:50
runloopexample2 ruby
actions: {
scheduleTasks: function() {
Ember.run.schedule('afterRender', this, function() {
console.log("CUSTOM: I'm in afterRender");
Ember.run.schedule('sync', this, function() {
console.log("CUSTOM: I'm back in sync");
});
});
}
}
@NetguruGist
NetguruGist / runloopexample3.ruby
Created October 31, 2015 14:50
runloopexample3 ruby
App.SomeValueComponent = Ember.Component.extend({
valueChanged: function(val) {
this.set('value', val);
this.sendAction('valueChange');
},
didInsertElement: function() {
this.$("input").on("keyup", Ember.run.bind(this, function() {
this.valueChanged(this.$("input").val());
}));
}
@NetguruGist
NetguruGist / runloopexample4.ruby
Created October 31, 2015 14:50
runloopexample4 ruby
App.IndexController = Ember.Controller.extend({
actions: {
handleChange: function() {
console.log(this.get("value"));
}
},
});
@NetguruGist
NetguruGist / testlevel1.ruby
Created October 31, 2015 14:50
testlevel1 ruby
# app/models/user.rb
class User < ActiveRecord::Base
attr_accessible :first_name, :last_name
def full_name
[first_name, last_name].reject(&:blank?).join(' ')
end
end
@NetguruGist
NetguruGist / testlevel2.ruby
Created October 31, 2015 14:50
testlevel2 ruby
# spec/models/user_spec.rb
require 'spec_helper'
describe User do
describe '#full_name' do
let(:normal_user) { build_stubbed :user, first_name: 'John', last_name: 'Doe' }
let(:nameless_user) { build_stubbed :user, first_name: ' ', last_name: ' ' }
it 'returns user name' do
expect(normal_user.full_name).to eq 'John Doe'
@NetguruGist
NetguruGist / testlevel3.ruby
Created October 31, 2015 14:50
testlevel3 ruby
require 'spec_helper'
feature 'User profile page' do
let!(:user) { create :user, first_name: 'John', last_name: 'Doe' }
scenario 'displays user fullname' do
visit users_path, id: user.id
expect(page).to have_content user.full_name
end
end
@NetguruGist
NetguruGist / techworkshop1.ruby
Created October 31, 2015 14:51
techworkshop1 ruby
{
"ensure_newline_at_eof_on_save": true,
"rulers":
[
100
],
"tab_size": 2,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true
}