Skip to content

Instantly share code, notes, and snippets.

☀️
hablo programación

Przemek Sobstel sobstel

☀️
hablo programación
Block or report user

Report or block sobstel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sobstel
sobstel / router.rb
Created Jul 12, 2019
Simple Ruby router
View router.rb
class Router
Route = Struct.new(:pattern, :block)
class RouteSet
def on(pattern, &block)
Router.routes.push Route.new(pattern, block)
end
end
@routes = []
@sobstel
sobstel / no_simulator.txt
Last active Jul 12, 2019
React Native "Could not find iPhone simulator"
View no_simulator.txt
❯ react-native run-ios --simulator="iPhone 7"
Found Xcode workspace Nabobil.xcworkspace
Could not find iPhone 7 simulator
Error: Could not find iPhone 7 simulator
at resolve (...)
sed -i '' 's/startsWith/includes/g' node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
@sobstel
sobstel / better_conversation.md
Last active Dec 15, 2018
10 ways to have a better conversation (by Celeste Headlee)
View better_conversation.md

10 ways to have a better conversation (by Celeste Headlee)

  1. Don't multitask (be present, be in that moment)
  2. Don't pontificate
  3. Use open-ended questions
  4. Go with the flow
  5. If you don't know, say that you don't know
  6. Don't equate your experience with theirs (it's never the same, all experiences are individual)
  7. Try not to repeat yourself
  8. Stay out of the weeds (people don't care about details)
@sobstel
sobstel / react-native-ios-third-party-build-fix.sh
Created Oct 10, 2018
React Native iOS third-party double-conversion build error fix
View react-native-ios-third-party-build-fix.sh
# error: Build input file cannot be found: '/Users/sobstel/Projects/nabobil/nabobil-mobile/node_modules/react-native/third-party/double-conversion-1.1.6/src/diy-fp.cc'
cd node_modules/react-native/scripts && ./ios-install-third-party.sh && cd ../../../
cd node_modules/react-native/third-party/glog-0.3.5/ && ../../scripts/ios-configure-glog.sh && cd ../../../../
View mvp-cheatsheet.md

MVP cheatsheet

The goal

To prove there is product market fit while taking on the least amount of risk possible.

Steps

1. Define the problem your product solves and what makes your product unique

@sobstel
sobstel / bulk_upsert.rb
Last active Nov 5, 2018
Bulk upsert (Rails/PostgreSQL)
View bulk_upsert.rb
class Data < ApplicationRecord
class << self
def bulk_upsert(values)
transaction do
values.uniq { |v| v[:key] }.each_slice(1000) do |values_slice|
connection.exec_query <<-SQL.squish
INSERT INTO #{table_name}(#{upsert_columns.join(', ')})
VALUES #{upsert_values_statement(values_slice)}
ON CONFLICT(key)
DO UPDATE SET
@sobstel
sobstel / effective_ruby.md
Last active May 13, 2019
Effective Ruby
View effective_ruby.md

Effective Ruby

#1 (Almost) Everything is true

  • Every value is true except false and nil.
  • The number zero is true in Ruby.
  • Use the nil? method to differentiate between false and nil.

#2 All objects could be nil

@sobstel
sobstel / manual_preloading.rb
Created Mar 29, 2018
Rails manual association preloading
View manual_preloading.rb
# taken from https://mrbrdo.wordpress.com/2013/09/25/manually-preloading-associations-in-rails-using-custom-scopessql/
# collection association e.g. has_many
owners = People.all
association_name = :photos
owners.each do |owner|
records = Array(whatever_you_want)
@sobstel
sobstel / loadable.js
Created Mar 4, 2018
Loader/loading Higher-Order Component
View loadable.js
// Sample usage: (taken from https://github.com/sobstel/golazon)
//
// class Competition extends Component {
// (...)
// }
//
// const fetchData = ({ id }) => {
// return competitionService.competition(id).then(competition => ({ competition }));
// };
//
View fetch_with_timeout.js
const API_URL = '...';
const TIMEOUT = 10; // seconds
export default (path) => {
/* global fetch */
const req = fetch(API_URL + path);
const timeout = new Promise((resolve, reject) => {
return setTimeout(() => reject(new Error('request timeout')), TIMEOUT * 1000);
});
You can’t perform that action at this time.