Skip to content

Instantly share code, notes, and snippets.

View adrianvalenz's full-sized avatar
💭
working on Rails stuff

Adrian Valenzuela adrianvalenz

💭
working on Rails stuff
View GitHub Profile
@adrianvalenz
adrianvalenz / jekyll-gulpfile.js
Last active June 22, 2016 19:57
Gulpfile for Jekyll - BrowserSync, Sass, & Autoprefixer.
var gulp = require('gulp');
var browserSync = require('browser-sync');
var sass = require('gulp-sass');
var prefix = require('gulp-autoprefixer');
var cp = require('child_process');
var messages = { jekyllBuild: '<span style="color: grey">Running:</span> $ jekyll build' };
// Build the Jekyll Site
@adrianvalenz
adrianvalenz / Markdown w pygments
Last active April 30, 2017 08:06
[Rails] Markdown support with Code Pygmentation and Embeddable Videos
# allows code pygmentation
gem 'pygments.rb'
# allows markdown functionality
gem 'redcarpet'
@adrianvalenz
adrianvalenz / application.html.erb
Created July 12, 2016 00:49
[Rails] Add this class to the body for flexible CSS customizing
<body class="<%= "#{controller.controller_name} #{controller.action_name}".strip %>">
@adrianvalenz
adrianvalenz / functions.php
Last active May 22, 2017 08:41
place this after initial php open tag to update the site's url
update_option( 'siteurl', 'http://example.com' );
update_option( 'home', 'http://example.com' );
// Allow editors to see Appearance menu
$role_object = get_role( 'editor' );
$role_object->add_cap( 'edit_theme_options' );
function hide_menu() {
// Hide theme selection page
remove_submenu_page( 'themes.php', 'themes.php' );
@adrianvalenz
adrianvalenz / Instructions to create postgresql database for Rails
Last active November 12, 2017 04:14
Rails secret && database yaml files
# make postgresql database on server
sudo su - postgres
psql
CREATE DATABASE appname_production;
CREATE USER appname_user WITH PASSWORD 'th3f1r3w1th1n';
GRANT ALL PRIVILEGES ON DATABASE appname_production TO appname_user;
\q
exit
# generate secret in local project root for production
lsof -wni tcp:3000
kill -9 PID
$ ps aux | grep spring
returned:
ubuntu 3271 0.0 0.0 569224 16672 pts/6 Sl 01:11 0:00 spring server | mh03_sample_app | started 3 hours ago
ubuntu 9265 94.3 0.1 468460 73160 ? Rsl 04:20 0:02 spring app | mh03_sample_app | started 2 secs ago | test mode
Killing the spring server:
$ kill -15 3271
@adrianvalenz
adrianvalenz / datatypes for Rails
Created May 26, 2017 19:55
postgresql datatypes
You might also find it useful to know generally what these data types are used for:
:string - is for small data types such as a title. (Should you choose string or text?)
:text - is for longer pieces of textual data, such as a paragraph of information
:binary - is for storing data such as images, audio, or movies.
:boolean - is for storing true or false values.
:date - store only the date
:datetime - store the date and time into a column.
:time - is for time only
:timestamp - for storing date and time into a column.(What's the difference between datetime and timestamp?)
Date (Year, Month, Day):
%Y - Year with century (can be negative, 4 digits at least)
-0001, 0000, 1995, 2009, 14292, etc.
%C - year / 100 (round down. 20 in 2009)
%y - year % 100 (00..99)
%m - Month of the year, zero-padded (01..12)
%_m blank-padded ( 1..12)
%-m no-padded (1..12)
%B - The full month name (``January'')
"ActivateAddons vim-snippets snipmate
autocmd BufReadPost,FileReadPost,BufNewFile,BufEnter * call system("tmux rename-window ':vim => \"" . expand("%:t") . "\"'")
"autocmd VimLeave * call system("tmux rename-window 'tmux'")
autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4
color dracula
let g:airline_theme='dracula'
# Tmux prefix...most people use Control-A
set-option -g prefix C-f
#No delay when hitting escape key
set -sg escape-time 0
#No or little delay in repeat time
set-option -g repeat-time 500
set -g mouse on