Skip to content

Instantly share code, notes, and snippets.

View Samda's full-sized avatar
🏝️
Working from home

Samda Muy Samda

🏝️
Working from home
View GitHub Profile
@Samda
Samda / rails-jsonb-queries
Created March 28, 2022 08:08 — forked from mankind/rails-jsonb-queries
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")
@Samda
Samda / gh-pages-deploy.md
Created March 12, 2021 09:55 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@Samda
Samda / Capfile
Created February 19, 2021 16:51 — forked from dv/Capfile
Capistrano 3 + Rails 4 + Whenever + DelayedJob + Nginx + Postgresql
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
# Rails (includes bundler, rails/assets and rails/migrations)
require 'capistrano/rails'
# Whenever
@Samda
Samda / byte-sizetuts.md
Created November 9, 2016 05:11 — forked from honkskillet/byte-sizetuts.md
A series of golang tutorials with youtube videos.
@Samda
Samda / deploy.rb
Created July 18, 2016 03:02 — forked from jbonney/deploy.rb
Mina deployment file to setup new host for Rails applications. Creates the folder structure, fill up the database.yml file, create the associated DB and user and set up new Apache virtual host file.
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'
# Usually mina focuses on deploying to one host and the deploy options are therefore simple.
# In our case, there is a number of possible servers to deploy to, it is therefore necessary to
# specify the host that we are targeting.
server = ENV['server']
# Since the same host can have multiple applications running in parallel, it is necessary to
@Samda
Samda / Gemfile
Created March 24, 2016 10:54 — forked from adamrobbie/Gemfile
Rails Endless pagination
gem 'will_paginate'
@Samda
Samda / deploy.rb
Last active August 29, 2015 14:18 — forked from stas/deploy.rb
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
# require 'mina/rvm' # for rvm support. (http://rvm.io)
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- Only the root user can own the Upstart name -->
<policy user="root">
<allow own="com.ubuntu.Upstart" />
</policy>
@Samda
Samda / makehub
Last active August 29, 2015 14:13 — forked from opethe1st/makehub
Arduino Powered Burglar Alarm
# Title
Arduino Powered Burglar Alarm
# Picture
media: http://www.deviantsart.com/3099afr.jpg
# Objective
Nigeria is a very hot place. Temperature averages 30 degree Celsius and even at Night the temperature is hot. The aim of this project is to regulate temperature by turning on the fan whenever the temperature reaches a certain level and turn it off whenever the temperature drops. This helps to conserve energy and also to improve comfort for the owner.
# Duration
40min
# Age Group
all
@Samda
Samda / makehub
Last active August 29, 2015 14:13 — forked from ahmedabdulaziz/makehub
AIR QUALITY STATION
# Title
AIR QUALITY STATION
# Picture
media: http://s27.postimg.org/n9159lwpf/1604581_626258354094217_2010345751_n.jpg
# Objective
the main Objective of this project is to measure pollution percentage in the air specially carbon monoxide in cities and for industrial applications. we tend to make it like as a distributed stations around the world to make a map for the pollution in the world.
# Duration
3 days
# Age Group
all