Skip to content

Instantly share code, notes, and snippets.

View obliviusm's full-sized avatar
🏠
Can't work from home because of russians

Misha Sebalo obliviusm

🏠
Can't work from home because of russians
View GitHub Profile
@mankind
mankind / rails-jsonb-queries
Last active October 8, 2025 23:13
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
import React from 'react';
import {
View,
Text,
} from 'react-native';
import { TextInputMask } from 'react-native-masked-text'
export default function maskedInputTemplate(locals) {
if (locals.hidden) {
return null;
@obliviusm
obliviusm / commands.md
Last active October 29, 2020 08:28
Commands
Rake
  1. rake -T -A Run from your Rails home directory to see all the tasks that rake knows about. Yours must be in that list for rake to run it.
  2. http://stackoverflow.com/questions/12409544/how-to-disable-rack-mini-profiler-temporarily
  3. run rails in production mode lacaly: bundle exec rake assets:clean && bundle exec rake assets:precompile && bundle exec rails s -e production_local
  4. bundle exec rake konacha:serve
  5. rake time:zones:all - all available time zones
Git
  1. Reset all changes after last commit in git First reset the changes git reset HEAD --hard then clean out everything untracked git clean -fd
  2. Removing multiple files from a Git repo that have already been deleted from disk git ls-files --deleted -z | xargs -0 git rm
@speric
speric / poodir-notes.md
Last active March 25, 2025 01:06
Notes From "Practical Object-Oriented Design In Ruby" by Sandi Metz

Chapter 1 - Object Oriented Design

The purpose of design is to allow you to do design later, and it's primary goal is to reduce the cost of change.

SOLID Design:

  • Single Responsibility Principle: a class should have only a single responsibility
  • Open-Closed Principle: Software entities should be open for extension, but closed for modification (inherit instead of modifying existing classes).
  • Liskov Substitution: Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
  • Interface Segregation: Many client-specific interfaces are better than one general-purpose interface.
@p1nox
p1nox / postgresql_configuration_on_mac_for_rails.md
Last active November 30, 2022 10:28
PostgreSQL configuration without password on Mac for Rails

Abstract

You could have postgre installed on localhost with password (or without user or password seted after instalation) but if we are developing we really don't need password, so configuring postgre server without password for all your rails project is usefull.

Install Postgre packages

Go to Postgre Download Site

Install Postgre gem

/Gemfile

@bkimble
bkimble / gist:1365005
Last active September 28, 2025 09:57
List local memcached keys using Ruby
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place.
require 'net/telnet'
headings = %w(id expires bytes cache_key)
rows = []