Skip to content

Instantly share code, notes, and snippets.

View davidleandro's full-sized avatar

David Leandro davidleandro

View GitHub Profile
@jimsynz
jimsynz / rgb_spectrum.c
Created January 5, 2011 20:59
Arduino sketch to cycle an RGB LED through the colour spectrum.
const int redPin = 11;
const int greenPin = 10;
const int bluePin = 9;
void setup() {
// Start off with the LED off.
setColourRgb(0,0,0);
}
void loop() {
@mewdriller
mewdriller / ability.rb
Last active December 19, 2021 01:48
Serializing CanCan rules to JSON for use in a client-side application
class Ability
include CanCan::Ability
def initialize(user)
can :read, Comment
if user.valid?
can :create, Comment
can :manage, Comment, author_id: user.id
end
@davinmsu
davinmsu / company.rb
Created February 3, 2014 17:34
remove duplicates from activerecord
def self.dedupe
# find all models and group them on keys which should be common
grouped = all.group_by{|model| [model.title,model.info,model.address,model.phone] }
grouped.values.each do |duplicates|
# the first one we want to keep right?
first_one = duplicates.shift # or pop for last one
# if there are any more left, they are duplicates
# so delete all of them
duplicates.each{|double| double.destroy} # duplicates can now be destroyed
end
@zulhfreelancer
zulhfreelancer / heroku_pg_db_reset.md
Last active June 17, 2024 11:44
How to reset PG Database on Heroku (for Rails app)?

It's important to note that running this reset will drop any existing data you have in the application

How to reset PG Database on Heroku?

  • Step 1: heroku restart
  • Step 2: heroku pg:reset DATABASE (no need to change the DATABASE)
  • Step 3: heroku run rake db:migrate
  • Step 4: heroku run rake db:seed (if you have seed)

One liner

@syafiqfaiz
syafiqfaiz / how-to-copy-aws-rds-to-local.md
Last active June 22, 2024 20:31
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@swnirjan
swnirjan / Canais.m3u
Created April 25, 2017 00:17
Canais Tv
#EXTM3U
#EXTINF:-1 tvg-logo="http://vertvonline.gratis/imagens/upload/prog/185b01a8085f178ce95f4cb27a3d97c9.jpg" group-title="", Record
http://wz3.dnip.com.br/tvgazetamt/tvgazetamt.sdp/playlist.m3u8
#EXTINF:-1 tvg-logo="http://vertvonline.gratis/imagens/upload/prog/d782022f4f769ce8f316f96fef5defb7.jpg" group-title="", Rede Globo
http://stream-09.vty.dailymotion.com/07/dm/1/x5j594h/live.isml/events(live-1492768706)/live-audio=128000-video=735000.m3u8
#EXTINF:-1 tvg-logo="http://vertvonline.gratis/imagens/upload/prog/196aa6b960357f9d3139bd67fc469590.jpg" group-title="", SBT - (HD)
http://srv6.zoeweb.tv:1935/z343-live/stream/livestream.m3u8
@slmingol
slmingol / AdList.txt
Created February 23, 2020 19:01 — forked from hermanjustinm/AdList.txt
Ad Block List
##StevenBlack's list
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
##MalwareDomains
https://mirror1.malwaredomains.com/files/justdomains
##Cameleon
http://sysctl.org/cameleon/hosts
##Zeustracker