Skip to content

Instantly share code, notes, and snippets.

View rg3915's full-sized avatar
🏠
Working from home

Regis Santos rg3915

🏠
Working from home
View GitHub Profile
@rg3915
rg3915 / colorbrewer.js
Last active January 8, 2016 03:15
Relationship make with D3js
// This product includes color specifications and designs developed by Cynthia Brewer (http://colorbrewer.org/).
var colorbrewer = {YlGn: {
3: ["#f7fcb9","#addd8e","#31a354"],
4: ["#ffffcc","#c2e699","#78c679","#238443"],
5: ["#ffffcc","#c2e699","#78c679","#31a354","#006837"],
6: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#31a354","#006837"],
7: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"],
8: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"],
9: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"]
},YlGnBu: {
@rg3915
rg3915 / bootstrap.sh
Created January 16, 2016 14:34 — forked from cuducos/bootstrap.sh
Computer Bootstraps
#!/bin/bash
##############################################################################
# Install system packages #
##############################################################################
# if apt-get exists, probably it's a Linux
if which apt-get > /dev/null; then
# update & clean up
@rg3915
rg3915 / xclip.sh
Created January 19, 2016 23:33
xclip ssh id_rsa.pub
xclip -sel clip < ~/.ssh/id_rsa.pub
@rg3915
rg3915 / rec_screencast.md
Last active February 23, 2016 14:34
How to record screencast on the Linux with ffmpeg

Install ffmpeg.

$ sudo apt-get install ffmpeg

Run command on terminal or create a rec.sh

ledate=$(date +"%Y%m%d-%H%M%S")
ffmpeg -f x11grab -s 1366x768 -r 25 -i :0.0 -acodec pcm_s16le -f alsa -ac 2 -i pulse ~/desktop_$ledate.mkv

If run rec.sh...

@rg3915
rg3915 / forms.py
Created February 29, 2016 05:33 — forked from neara/forms.py
Django Class Based Views and Inline Formset Example
from django.forms import ModelForm
from django.forms.models import inlineformset_factory
from models import Sponsor, Sponsorship
class SponsorForm(ModelForm):
class Meta:
model = Sponsor
@rg3915
rg3915 / djangocms.sh
Last active March 2, 2016 19:45
Shell script to create a project to Django-CMS.
# Shell script to create a project to Django-CMS with Python 3.5
# Download:
# curl https://gist.githubusercontent.com/rg3915/15b2100f3eeba362ebd8/raw/27d1f1374f03e89bfc26648f08c35bc86eebc978/djangocms.sh -o djangocms.sh
# Usage:
# Type the following command, you can change the project name.
# source djangocms.sh
@rg3915
rg3915 / setup.sh
Last active March 9, 2016 18:12 — forked from Benedikt1992/setup.sh
Setup apache-2.4.16 + php-5.6.11 on CentOS 6.7
#!/usr/bin/env bash
# Install dependencies
yum update -y
yum install -y gcc apr-devel apr-util-devel openssl-devel pcre-devel libxml2-devel libcurl-devel
mkdir setup && cd setup
wget wget https://olex-secure.openlogic.com/content/private/5e6a6f0815e830bba705e79e4a0470fbee8a5880//olex-secure.openlogic.com/httpd-2.4.16.tar.gz
tar -xvf httpd-2.4.16.tar.gz
@rg3915
rg3915 / core_tags.py
Created March 31, 2016 14:39
Return information in mouse over on html.
# /templatetags/core_tags.py
from django import template
from django.utils.safestring import mark_safe
register = template.Library()
@register.filter
def teste(value, arg):
@rg3915
rg3915 / ruby.md
Created June 21, 2016 01:26
Ruby Intro

Ruby intro

Objetos

#TUDO É OBJETO
puts 1.class # => Fixnun
puts "123".class  # => String
puts false.class  # => FalseClass
@rg3915
rg3915 / group_by_m2m.md
Created August 10, 2016 21:00
Group_by first item of M2M in Django
# views.py
def books_list(self):
    books_name = {}
    total = 0
    for item in Author.objects.all().order_by('books__name'):
        first_book = item.books.first()
        if first_book:
            total += 1
 books_name[first_book] = books_name.get(first_book, 0) + 1