Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ismailmechbal's full-sized avatar

Ismail Mechbal ismailmechbal

View GitHub Profile
3294 BabyCare Chamomile Baby wipes 72 pcs 2.92
2812 Babylino Sensitive Diapers No6 (13-18 Kg) 40 pcs 15.6
3406 Babylino Sensitive Diapers No5+ (13-27 Kg) 42 pcs 15.6
3527 Babylino Sensitive Diapers No5 (11-25 Kg) 44 pcs 15.6
2602 Babylino Sensitive Diapers No4+ (9-20 Kg) 46 pcs 15.6
3699 Babylino Sensitive Diapers No4 (7-18 Kg) 50 pcs 15.6
3055 Babylino Sensitive Pants Diapers No5 (10-16 Kg) 46 pcs 21.8
3074 Babylino Sensitive Pants Diapers No5 (10-16 Kg) 38 pcs 15.6
2629 Babylino Sensitive Pants Diapers No6 (15+ Kg) 42 pcs 21.8
2896 Babylino Sensitive Diapers No3 (4-9 Kg) 56 pcs 15.6
@ismailmechbal
ismailmechbal / rspec_model_testing_template.rb
Created November 30, 2020 12:44 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@ismailmechbal
ismailmechbal / example.rb
Created June 13, 2020 07:11 — forked from skunkworker/append_json_column_rails_5.rb
How to append to a json column array in Rails 5.
# assuming Model is your model and options is a json/jsonb column.
# This uses the Postgres json append || operator.
# And wraps the option inside an array.
# producing [{},{}] multiple hashes inside a top level json array.
# It is very important that the hash is [{}] NOT {} as not having the array on the
# outside will cause the hash to replace the contents instead of appending to them.
new_option = [{
name: option_name,
@ismailmechbal
ismailmechbal / svenska_stader.json
Created August 21, 2019 15:57 — forked from timbillstrom/svenska_stader.json
Svenska städer organiserade i objekt för deras respektive län. (Vissa slugs är ej hela)
{
"blekinge": [
"Blekinge",
{
"name": "Karlshamn",
"slug": "karlshamn"
},
{
"name": "Karlskrona",
"slug": "karlskrona"
@ismailmechbal
ismailmechbal / rails_webpacker_bootstrap_expose_jquery.md
Created March 24, 2019 06:09 — forked from andyyou/rails_webpacker_bootstrap_expose_jquery.md
Rails 5.2 with webpacker, bootstrap, stimulus starter

Rails 5.2 with webpacker, bootstrap, stimulus starter

This gist will collects all issues we solved with Rails 5.2 and Webpacker

Create Project

# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test
@ismailmechbal
ismailmechbal / rails-jsonb-queries
Created March 23, 2019 15:19 — forked from mankind/rails-jsonb-queries
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")
@ismailmechbal
ismailmechbal / book.rb
Created March 7, 2019 14:30 — forked from sirupsen/book.rb
Script to import books from Instapaper to Airtable. Will not work out of the box.
class Book < Airrecord::Table
class Endorser < Airrecord::Table
self.base_key = ""
self.table_name = "Endorser"
end
self.base_key = ""
self.table_name = "Books"
has_many :endorsements, class: 'Book::Endorser', column: 'Endorsements'
@ismailmechbal
ismailmechbal / docker-clear-logs
Created January 31, 2019 15:59
Docker clear container logs
docker inspect --format='{{.LogPath}}' NAME|ID
screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
echo "" > /var/lib/docker/containers/CONTAINER_ID/CONTAINER_ID-json.log
// PhantomJS Cheatsheet
$ brew update && brew install phantomjs // install PhantomJS with brew
phantom.exit();
var page = require('webpage').create();
page.open('http://example.com', function() {});
page.evaluate(function() { return document.title; });